copy artifact from local maven repository

Seems like the problem was the _maven.repositories file in conjunction with the particular maven setup at my company.

We don't put the info about the local repo in our settings.xml. It's all in the parent pom that all our projects use. But if you want to do some pure mvn-CLI magic you don't have the parent-pom so you have to provide the URL to the local repo yourself. This is possible with the dependecy:get goal, which is why I was able to download my artifact from our Nexus into my local repo.

When using copy, however, you can't specify a URL. But why would I want to? I just downloaded that artifact into my local repo, right?

That's where the _maven.repositories file comes into play. Even with the -o switch, maven3 consults that file, which specifies the original repo that the artifact came from. (thanks to the guys in this thread for posting their findings!). If it can't reach the repo, it will claim that your file isn't there. (Btw., this is not helpful imho. It should say something about the original repo not being reachable and that the file therefore won't be copied.)

This was the reason why copy didn't work for me.

Simply renaming that file does the trick.

I will have to investigate a cleaner solution to this, though.

To make things even more complicated, I couldn't use dependency:copy or dependency:copy-dependecies. For some reasons they require a pom, which I don't have in my usecase. What does work is org.apache.maven.plugins:maven-dependency-plugin:2.8:copy which I believe is supposed to be the same thing, but that's another story.

Thanks for your answers!


Just tried this, and it worked for me:

mvn dependency:copy-dependencies -DincludeArtifactIds=jcharts -DincludeGroupIds=jcharts -DoutputDirectory=/tmp/

This copied the artifact jcharts:jcharts to /tmp/ It was in my local (and remote) repo when this was executed.

Tags:

Maven

Nexus