mvn dependency:copy-dependencies removes the versions
-
13-10-2019 - |
Question
I'm using "mvn dependency:copy-dependencies" to get all sources of the dependencies my project uses. I use it from command line, so it looks like this:
mvn dependency:copy-dependencies -Dclassifier=sources -DincludeScope=compile
It works fine except of a small problem: For some reason the version is removed by this plugin. So instead of commons-logging-1.1.1-sources.jar, I'm getting commons-logging-sources.jar
The documentation says that "stripVersion" argument should effect this behavior, but the default value is false. Moreover, I tried to set it explicitly and it didn't help.
I'm using apache-maven-2.2.1 with jdk1.6.0_21
Thanks, Tarlog.
Solution 2
I found the root cause of a problem. Somewhere in the parent of parent of parent of ... my pom, stripVersion was set to true. I didn't know about it and anyway thought that setting the system property must override the xml. I even tried to put this property in my pom and it still didn't help. Somehow, the parent pom stayed the dominant one, so I thought that the property doesn't work.
When I ran with -X param I saw it no changing despite my configuration, so I started digging in the parent poms unless I found the problem.
Thanks to everyone!
OTHER TIPS
That's very strange, you can see in the source (Mojo, Parent Mojo, DependencyUtil) that stripVersion does what it says it does.
Several possibilities:
a) Are you using the current version of the dependencies plugin?
Either configure your pom
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
or use the fully qualified goal name:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:copy-dependencies
b) stripVersion
is the parameter name in XML configuration. The command line version is
-Dmdep.stripVersion=false
Try using that.