views:

364

answers:

3

In eclipse, the m2eclipse plugin will prompt me for my credentials when I'm building a maven2 project. And it compiles fine.

But if I now try to run "mvn install" from the command line, I get an artifact not found error. How do I add the username/password into my pom.xml in order to solve this problem. Thanks

+1  A: 

As far as I know there are no maven xml tags to configure that. Of course you could try prefixing the domain name with username and password like so:

http://username:password@yournexusserver/..
Kees de Kooter
This works for me, although I'm using buildr instead of maven. It only happens to work because the underlying http library supports it, not because of any explicit support on the part of buildr, but the key point is that Nexus supports using http auth, rather than the cookie-based auth I imagine it uses for the admin interface.
Jeremy Huiskamp
+2  A: 

Which username password you talking about? If its the username defined in nexus repository then you can define in settings.xml where you defined the nexus repository.

  <servers>
    <server>
      <id>releases</id>
      <username>xxxxxxxxx</username>
      <password>yyyyyyyy</password>
    </server>
    </server> 
  </servers>
Bhushan
Does this apply to retrieving artifacts too? I thought this was for artifact upload.
Jeremy Huiskamp
Yes it applies for retrieving artifacts also. The value in the id attribute should match the value of mirror id, you defined for nexus repository.
Bhushan
+1  A: 

Maven will use the entries defined in your settings for the auth when prompted by Nexus. Just enter a server entry with the same Id that you are using for your repository (or mirror if using one), and that's all.

Brian Fox