5/31/13

Download the additional transitive dependencies of the modules from maven pom.xml

The obvious answer is to suggest that you consider building your code using Maven. This will give you native support for the Maven Central repository.
But... I sense that you just want to download the files you need to a local directory? In that case I'd suggest using the Apache ivy command-line.

Example

The files you want are listed in a ivy.xml file. For example:
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    <info organisation="com.myspotontheweb" module="demo"/>

    <dependencies>
        <dependency org="commons-lang" name="commons-lang" rev="2.6" conf="default"/>
        <dependency org="junit" name="junit" rev="4.10" conf="default"/>
    </dependencies>

</ivy-module>
And ivy can populate a local "lib" directory as follows:
java -jar ivy-2.3.0.jar -ivy ivy.xml -retrieve "lib/[artifact]-[revision].[ext]"

The advantage of this approach is that ivy can download the additional transitive dependencies of the modules you've specified:
$ find lib -type f
lib/commons-lang.jar
lib/junit.jar
lib/hamcrest-core.jar
Note:
  • hamcrest-core is a depedency of junit.

No comments: