Reputation: 438
I want to copy each dependency and their transitive dependencies into own dedicated folder. I find this hard to explain so here's an example.
Project - let's call it 'myProject' - has two dependencies
Dependency A
Dependency B
Both dependencies has transitive dependencies.
Lets call A's dependencies as A1 and A2.
Lets call B's dependencies as B1, B2 and B3
I want to create following directory structure when building the project:
/myProject.jar
/projects/A/A.jar
/projects/A/jarlib/A1.jar
/projects/A/jarlib/A2.jar
/projects/B/B.jar
/projects/B/jarlib/B1.jar
/projects/B/jarlib/B2.jar
/projects/B/jarlib/B3.jar
Is this possible to do by using maven assembly plugin, maven dependency plugin or by using both of them? Or is there any other plugin to achieve what I'm seeking? I've been trying to use both of the plugins but so far I've been able to get results where all the transitive depencies gets copied only to a single folder
Upvotes: 0
Views: 72
Reputation: 438
I didn't even remember I have asked this question. Well, it's been nine months since I asked and I already have found an answer. One way to do this is to create parent pom for all those projects and use module sets in maven assembly plugin. This way it is possible to determine output directories for each module and that way desired directory structure is achieved.
Upvotes: 0
Reputation: 820
To illustrated the idea of "Puce". This example is ok for me.
<project>
...
<profiles>
<profile>
<id>qa</id>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Upvotes: 0
Reputation: 38132
Try the copy-dependencies goal of the Maven Dependency Plugin and set useRepositoryLayout to true.
It's not exactly the same structure, but the structure of a Maven Repository.
Upvotes: 1