10

I am trying to add a 3rd party vendor's jar to our internal nexus repository.

I have tried to do so using this command:

mvn deploy:deploy-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar 
-DrepositoryId=Nexus 
-Durl=http://myserver:8888/nexus/content/repositories/thirdparty/

With the following entry in my settings.xml:

  <servers>
        <server>
            <id>Nexus</id>
            <username>myusername</username>
            <password>mypassword</password>
        </server>
  </servers>

But I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts:
 Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/c
ontent/repositories/thirdparty) -> [Help 1]

Any suggestions?

Some related info... I can install to my local repository just fine, using this command:

mvn install:install-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar

I have also tried 'Artifact Upload' via the Nexus web interface, using GAV parameters:

Group: acme
Artifact: acme
Version: 1.0
Packaging: jar

And selecting & adding the acme-1.0.jar. This completes fine, but "mvn install" on the project depending on this jar results in:

Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/content/groups/public)

My pom contains:

<repositories>
  <repository>
    <id>Nexus</id>
    <url>http://myserver:8888/nexus/content/groups/public</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
  </repository>
</repositories>

Any help much appreciated...

PS I know this question is very similar to this one, but the issue there seemed to be the use of a jenkins url, instead of a nexus url.

Community
  • 1
  • 1
Shaun Abram
  • 281
  • 1
  • 4
  • 10

2 Answers2

6

Answering my own question. I resolved this as follows:

1) If you are behind a proxy server (i.e. you have a proxy server setup in your maven settings.xml) but your nexus server is internal, you may need to add the nexus server as a nonProxyHost in settings.xml e.g.

<proxies>
  <proxy>
    ...
    <nonProxyHosts>myserver</nonProxyHosts>
  </proxy>
</proxies>

I realized I needed to do this because the "mvn deploy:deploy-file" command I was running did not seem to be reaching the nexus repo at all. For example, I could change the repo id, username or password in the server section of my settings.xml, and still get exactly the same error. I could also change the url in the deploy command to gibberish (For example to -Durl=notexist), or even completely shutdown my nexus repo, and STILL get the same error.

2) Make sure your 3rd party repository is set up as Release, rather than Snapshot. To do this, go to the web GUI, select Configuration tab of the 3rd party repository, and make sure that Repository Policy is set to to Release.

I found this out by looking at the catalina.out log (I run nexus as a war in Tomcat) and seeing the following:

ERROR org.sonatype.nexus.rest.ContentPlexusResource - Got exception during processing request "PUT http://myserver:888/nexus/content/repositories/thirdparty/acme/acme/1.0/acme-1.0.pom": Storing of item thirdparty:/acme/acme/1.0/acme-1.0.pom is forbidden by Maven Repository policy. Because thirdparty is a SNAPSHOT repository

With those 2 fixes in place, both the "mvn deploy:deploy-file" command, and uploading via the 'Upload Artifacts' option in the web GUI work.

Shaun Abram
  • 281
  • 1
  • 4
  • 10
  • Just to clarify .. the 3rd party repo is a release repository by default so there is not need to change it to that unless somebody changed it to snapshot. Always keep in mind that Nexus Maven repositories are either snapshot or release and use groups to mix them together. – Manfred Moser Apr 29 '13 at 19:37
0

Login to the nexus web console and check the Public Repository configuration and see if the 3rd party is in the Ordered Group Repositories list.

Bhushan Bhangale
  • 10,921
  • 5
  • 43
  • 71
  • Thanks Bhushan, but I already have the 3rd party repository in the Ordered Group Repositories list. Good suggestion though. – Shaun Abram Apr 26 '13 at 16:05