It seems that the Maven dependency plugin is not intended for this, since they closed one request for this function as "WONTFIX" and another request has been open since 2007.
However, you can use the maven-assembly-plugin to perform a similar task.
Below I have attached two POM samples. The first is a dependent project (the one you wanted to copy) that itself has one dependency (for example). The second is an aggregate project in which you copy another project and its dependency. I also added an assembly descriptor file that you will use to copy the dependencies.
Essentially, this will copy the first project, and it will depend on the target / dest (configurable) directory of the second project.
First POM (dependent project): / sample-dependency / pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>sample-dependency</groupId> <artifactId>sample-dependency</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.5</version> </dependency> </dependencies> </project>
Second POM (aggregation project): / sample-dependency-aggregator / pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>sample-dependency-aggregator</groupId> <artifactId>sample-dependency-aggregator</artifactId> <version>0.0.1-SNAPSHOT</version> <name>sample-dependency-aggregator</name> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.2</version> <executions> <execution> <id>aggregate</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptor>src/main/assembly/default.xml</descriptor> </configuration> </execution> </executions> <configuration> <attach>false</attach> <finalName>dest</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>sample-dependency</groupId> <artifactId>sample-dependency</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> </dependencies> </project>
Assembly handle: /sample-dependency-aggregator/src/main/assembly/default.xml
<?xml version="1.0" encoding="UTF-8"?> <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.1 http://maven.apache.org/xsd/assembly-1.1.1.xsd "> <id>default</id> <formats> <format>dir</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <dependencySets> <dependencySet> <outputDirectory>/</outputDirectory> <includes> <include>sample-dependency:sample-dependency</include> </includes> <useTransitiveDependencies>true</useTransitiveDependencies> <useTransitiveFiltering>true</useTransitiveFiltering> </dependencySet> </dependencySets> </assembly>
jeckhart
source share