Nexus with Maven Dependency:get/copy Issue

2,213 views
Skip to first unread message

Karthik

unread,
Feb 12, 2018, 9:29:08 AM2/12/18
to Nexus Users
I have to setup maven to pull the artifact from nexus repo in a pipeline script.  mvn dependency:get and mvn dependency:copy worked fine to get and copy with SNAPSHOT repo artifacts but when I tried the same for release repository only get functionality works where as mvn dependency:copy through an error.

[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:copy (default-cli) @ standalone-pom ---
[INFO] Configured Artifact: my.test.testapp:APP:001:ear
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.781 s
[INFO] Finished at: 2018-02-07T00:31:29-05:00
[INFO] Final Memory: 11M/159M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (default-cli) on project standalone-pom: Unable to find artifact.: Failure to find my.test.testapp:APP:ear:001 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[ERROR] 
[ERROR] Try downloading the file manually from the project website.
[ERROR] 
[ERROR] Then, install it using the command: 
[ERROR]     mvn install:install-file -DgroupId=my.test.testapp -DartifactId=APP -Dversion=001 -Dpackaging=ear -Dfile=/path/to/file
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there: 
[ERROR]     mvn deploy:deploy-file -DgroupId=my.test.testapp -DartifactId=APP -Dversion=001 -Dpackaging=ear -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] 
[ERROR] 
[ERROR]   my.test.testapp:APP:ear:001
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR]   central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] -> [Help 1]

Brian Fox

unread,
Feb 12, 2018, 9:33:51 AM2/12/18
to Karthik, Nexus Users
Hi Karthik,

I originally wrote the dependency plugin with the get and copy goals. My suggestion would instead to use copy-dependencies as the resolution follows a more normal path instead of attempting to recreated it in the plugin.

That aside, based on the log, it only shows the plugin attempting to resolve directly against central, not against a Nexus repo. Are you sure the config is correct?

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/0685582b-a15c-4d76-9ab4-58f32b90d7e1%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

Karthik

unread,
Feb 12, 2018, 9:41:51 AM2/12/18
to Nexus Users, karthikc...@gmail.com
Yes the config is correct.

cmd: mvn dependency:get -DremoteRepositories=http://localhost:8082/nexus/content/repositories/releases -DgroupId=my.test.testapp -DartifactId=APP -Dversion=001 -Dpackaging=ear -Dtransitive=false
cmd: mvn dependency:copy -Dartifact=my.test.testapp:APP:001:ear -DoutputDirectory=./Dump/

As said if I use SNAPSHOT repo it works without errors.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.

Peter Lynch

unread,
Feb 12, 2018, 10:26:54 PM2/12/18
to Karthik, Nexus Users
On Mon, Feb 12, 2018 at 10:41 AM, Karthik <karthikc...@gmail.com> wrote:
Yes the config is correct.

cmd: mvn dependency:get -DremoteRepositories=http://localhost:8082/nexus/content/repositories/releases -DgroupId=my.test.testapp -DartifactId=APP -Dversion=001 -Dpackaging=ear -Dtransitive=false
cmd: mvn dependency:copy -Dartifact=my.test.testapp:APP:001:ear -DoutputDirectory=./Dump/

As said if I use SNAPSHOT repo it works without errors.


This could be explained by a different packaging for the snapshot version - or the snapshot version was already installed into the local repo at the time dependency:copy was run.

The build output suggests that there is no pom.xml in the directory of execution ( "standalone-pom") and therefore mvn dependency:copy will check the locations as documented at https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html , which is:

Artifacts are resolved from the following sources in order:

  • the current reactor,
  • the local repository,
  • the configured remote repositories.
 The output also suggests

- the local repository does not contain it ( dependency:get put it someplace else?)
- that there is no remote repository or mirror configured in the Maven settings being used for the executing user
https://repo.maven.apache.org/maven2 is the only remote checked as it is the one in the Maven super pom, as documented

dependency:get works because it explicitly defines a property to specify the remote repo, instead of only relying on Maven settings.xml. dependency:copy has no such property override.

The best way to isolate the problem is start with an empty local repository, then use Maven debug -X option with both commands. This will tell you what local repository is being used by both commands and should help explain why the dependency:copy command can't find it locally. My suggestions assume that dependency:get was executed first and worked during the same build.

This is not really a Nexus Repository Manager issue regardless - this is all about how Maven ( and possibly Jenkins) work and you will gain a wider audience by asking your question on a more relevant Maven Users List:



To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.

To post to this group, send email to nexus...@glists.sonatype.com.
Message has been deleted

O Carlsen

unread,
May 31, 2020, 11:22:54 PM5/31/20
to Nexus Users, karthikc...@gmail.com
I had the same problem.  Calling dependency:copy after dependency:get works fine for SNAPSHOT but wasn't working for releases.  The solution for me was to add  -Dmaven.legacyLocalRepo=true when calling dependency:copy.

HTH.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus...@glists.sonatype.com.

To post to this group, send email to nexus...@glists.sonatype.com.
Reply all
Reply to author
Forward
0 new messages