Matthias
Matthias

Reputation: 3556

copy dependencies transitive and not transitive

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

Upvotes: 2

Views: 6713

Answers (1)

Matthias
Matthias

Reputation: 3556

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.

Upvotes: 4

Related Questions