2

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...

Matthias
  • 3,458
  • 4
  • 27
  • 46

1 Answers1

4

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.

Matthias
  • 3,458
  • 4
  • 27
  • 46
  • 1
    Yes, it appears that include/exclude applies to the entire, resolved list of specified and derived (transitive) deps, which is a pain... – Chris2048 Jan 03 '14 at 18:34
  • thanks for the inspiration that i realize there are some other configurations, like `true `will only copy the first level dependency. – coldestlin Jul 28 '23 at 04:35