I have a repository configured in Nexus that contains projects that are not for public release, but need access from a variety of sites so cannot host it on my LAN. I've therefore put it on a public server and set up the repository in Nexus to require username/password access, which is working fine. But I can't figure out where to put the configuration information for Maven to access this repository... Nexus doesn't seem to understand HTTP basic authentication, so I can't use an http://username:password@host/ URL format for the job. So what can I do to make this work?
5
votes
We can pass username / password in .m2/settings.xml. Are you looking for that?
- Pramod S. Nikam
Probably. I'm finding this entire setup confusing... how do I associate a username and password with a particular repository, and how does maven know how to log in if basic auth doesn't work, as it appears not to for nexus?
- Jules
possible duplicate of Accessing an Artifactory/Maven Repo that requires basic-auth
- Joe
@Joe I'd agree, except that Nexus doesn't seem to permit basic auth, as I state in the question.
- Jules
(continued from previous comment, which I left open for editing for too long...) It turns out that this doesn't matter, and whatever login scheme Nexus does use is supported by Maven without any additional configuration, but that isn't obvious from either the documentation or the answers on the question you link to, which only discuss using basic auth.
- Jules
1 Answers
1
votes
All you have to do is set a server element in settings.xml with your username and password and an id.
For deployment rights use that id in the distributionManagement of your pom file for the snapshotRepository and repository.
For access rights via read you typically do that via a public group and use that same id in the mirror as defined in the settings file. See an example at http://books.sonatype.com/nexus-book/reference/config-maven.html
Now if you want to give access to something only for authenticated users like yourself you create a repository target for that group and then give the appropriate security rights to your user.