Kohei Nozaki's blog 

Getting dependencies with Maven dependency plugin


Posted on Friday Feb 27, 2015 at 11:30AM in Maven


I want to get all of dependencies of:

<dependency>
    <groupId>org.jboss.as</groupId>
    <artifactId>jboss-as-controller-client</artifactId>
    <version>7.2.0.Final</version>
</dependency>

So, create pom.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<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>org.nailedtothex</groupId>
    <artifactId>get-dependencies</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-controller-client</artifactId>
            <version>7.2.0.Final</version>
        </dependency>
    </dependencies>

</project>

Then issue:

$ mvn dependency:copy-dependencies

Then you will get:

$ ls -l target/dependency/
total 2824
-rw-r--r--+ 1 kyle  staff    3933 Feb 27 11:25 jboss-as-build-config-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff  177511 Feb 27 11:25 jboss-as-controller-client-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff   96612 Feb 27 11:25 jboss-as-protocol-7.2.0.Final.jar
-rw-r--r--+ 1 kyle  staff   92053 Feb 27 11:25 jboss-dmr-1.1.6.Final.jar
-rw-r--r--+ 1 kyle  staff   55248 Feb 27 11:25 jboss-logging-3.1.2.GA.jar
-rw-r--r--+ 1 kyle  staff  229373 Feb 27 11:25 jboss-marshalling-1.3.16.GA.jar
-rw-r--r--+ 1 kyle  staff  238355 Feb 27 11:25 jboss-remoting-3.2.14.GA.jar
-rw-r--r--+ 1 kyle  staff   89315 Feb 27 11:25 jboss-sasl-1.0.3.Final.jar
-rw-r--r--+ 1 kyle  staff  119912 Feb 27 11:25 jboss-threads-2.1.0.Final.jar
-rw-r--r--+ 1 kyle  staff  241808 Feb 27 11:25 xnio-api-3.0.7.GA.jar
-rw-r--r--+ 1 kyle  staff   80070 Feb 27 11:25 xnio-nio-3.0.7.GA.jar
$