Wednesday, October 26, 2011

Apache Ivy

In researching Apache Ant and how to create a build.xml file, I discovered Apache Ivy. Apache Ivy is a dependency manager that can easily be integrated with Apache Ant.

The main and most frequent way to use ivy is from an ant build file. However, ivy can also be called as a standalone application. If you use ant version 1.6.0 or superior, you just have to add ivy namespace to your project (xmlns:ivy="antlib:org.apache.ivy.ant") attribute of your project tag, and you can call ivy tasks.
 <project name="sample" default="compile" xmlns:ivy="antlib:org.apache.ivy.ant"> 
The build will use Apache Ivy to download, install, and manage third party libraries of the different tools needed for the project. The retrieve task copies resolved dependencies anywhere you want in your file system. Below is an example of adding checkstyle to the project.
1:  <target name="install-checkstyle" description="Install checkstyle."> 
2: <ivy:retrieve module="checkstyle" organisation="com.puppycrawl" revision="5.4" pattern="${basedir}/lib/checkstyle/[artifact].[ext]" sync="true" conf="bundled" type="jar,report"/>
3: </target>

No comments: