Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure Maven to log in to username/password protected repository hosted by Nexus?

Tags:

maven

nexus

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?

like image 434
Jules Avatar asked Nov 10 '22 06:11

Jules


1 Answers

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.

like image 139
Manfred Moser Avatar answered Nov 15 '22 07:11

Manfred Moser