I need to download a set of specific jars with there dependency and place it in a separate folder. Below is my code from pom.xml
<profile>
<id>copy-dep</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>xxx</version>
</artifactItem>
<artifactItem>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>xxx</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>
When I use the below command only the specific dependencies get downloaded not it's transitive dependencies. Also with artifactItem if I am not able to use exclude tag.
mvn dependency:copy -Pcopy-dep
If I use mvn dependency:copy-dependencies
it looks for the all the dependencies in pom.xml, which I don't want.
I tried replacing <artifactItems>
with <dependencies>
but also didn't work, getting below error
Caused by: org.apache.maven.plugin.MojoFailureException: Either artifact or artifactItems is required
Is there a way I can get all the selected dependencies(with transitive dependencies) and also excluding some dependencies? If there is any better plugin available please suggest.