This is a sample Apache Ant project illustrating the use of the Apache Ant Command Line Wrapper.
This Ant project example uses Apache Ivy as dependency manager.
Clone the project from GitHub and run the ant wrapper
command.
Take a look at the different Ant related build files: build.xml
, ivy.xml
, ivysettings.xml
.
- A valid modern Java JDK installation (1.6 or later)
- An existing Apache Ant installation
Inside your ivysettings.xml
, add a reference to the Sonatype snapshot repository.
<ivysettings> <!-- other ivysettings contents here --> <resolvers> <chain name="chain"> <!-- your other repositories --> <!-- YOU MUST HAVE SONATYPE SNAPSHOTS REPOSITORIES DECLARED TO FETCH THE WRAPPER --> <url name="sonatype-snapshots" m2compatible="true"> <artifact pattern="https://oss.sonatype.org/content/repositories/snapshots/[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"/> </url> </chain> </resolvers> </ivysetting>
Inside your ivy.xml
file, add a configuration called wrapper
.
<configurations defaultconfmapping="default"> <conf name="default" /> <!-- ... Your other configurations here ... --> <conf name="wrapper" visibility="private" /> </configurations>
:
<!-- other ivy.xml elements such as publications -->
:
<dependencies> <!-- ... Your other dependencies here ... --> <dependency org="com.rimerosolutions.ant" name="ant-wrapper" rev="0.0.1-SNAPSHOT" changing="true" conf="wrapper->default"/> </dependencies>
In your build.xml
, add a reference to the ant-wrapper
namespace to your build.xml
file.
<project name="YOUR_PROJECT_NAME_HERE" xmlns:wrapper="antlib:com.rimerosolutions.ant.wrapper.tasks" default="YOUR_DEFAULT_ANT_TARGET_HERE"> <!-- rest of your build.xml contents -->
:
</project>
Again, in your build.xml
, after doing an ivy:retrieve
, cache the path to the Apache Ant Wrapper dependencies.
<target name="-resolve" depends="-init-ivy"> <echo>Fetching dependencies.</echo> <ivy:retrieve pattern="${ivy.lib.dir}/[conf]/[artifact].[ext]" sync="true" />
:
<! -- ADD A REFERENCE TO THE WRAPPER CLASSPATH HERE --> <!-- store the Ant wrapper dependencies --> <ivy:cachepath pathid="ant.wrapper.classpath" conf="wrapper" /> <!-- Add a new task definition to make the wrapper available --> <taskdef uri="antlib:com.rimerosolutions.ant.wrapper.tasks" resource="com/rimerosolutions/ant/wrapper/tasks/antlib.xml" classpathref="ant.wrapper.classpath"/> </target>
:
<!-- other content here -->
:
<target name="wrapper" description="Generate Ant Wrapper."> <wrapper:wrapper/> </target>