问题
In a pom.xml (jar packaging) i want to make use of the maven dependency plugin to download two kinds of dependencies. One kind i want to be downloaded with transitives and one without. Up to now, my plugins section contains follwing element:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>Copy dependencies transitive</id>
<phase>initialize</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeTransitive>false</excludeTransitive>
<outputDirectory>lib</outputDirectory>
<includeArtifactIds>artifact_1</includeArtifactIds>
</configuration>
</execution>
<execution>
<id>Copy dependencies not transitive</id>
<phase>initialize</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>samples</outputDirectory>
<excludeTransitive>true</excludeTransitive>
<includeArtifactIds>artifact_2,artifact_3</includeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
after doing
mvn initialize
artifact_1 is located in lib and artifact_2 and 3 are located in samples. However artifacts_1's transitive dependencies cannot be found. Is this a right way to go? I somehow expect this solution to work already, but as it seems it does not... Corrections would be welcome...
回答1:
Just found whats going on...
includeArtifactIds affects also the transitive dependencies. So if artifact_4 and artifact_5 are transitive dependencies of artifact_1 they are just not copied because i did not include them. I consider this a little unexpected, but well... thats how it was implemented (but not documented). Now i just changed from includeArtifacts to excludeArtifacts and it works.
来源:https://stackoverflow.com/questions/11973889/copy-dependencies-transitive-and-not-transitive