Software By JeffMain Page | About | Help | FAQ | Special pages | Log in
The Free Encyclopedia
Printable version | Disclaimers

Ant

From Software By Jeff

The Apache Ant (http://ant.apache.org/) project offers very powerful methods for creating, maintaining, and even distributing software. Its XML build file format is intuitive once you're familar with it, and its acceptance by the community is widespread enough that Ant is integrated into the most common Open Source development environments.

Ant File Format

Straight from the Ant documentation's Example Buildfile (http://ant.apache.org/manual/using.html#example) we see a simple build file that works for most simple projects without modification. This text is put into a file named build.xml in the root of the project. It assumes the source is in a directory named "src" and it does the rest for us.

<project name="MyProject" default="dist" basedir=".">

   <description>
       simple example build file
   </description>
 <property name="src" location="src"/>
 <property name="build" location="build"/>
 <property name="dist"  location="dist"/>
 <target name="init">
   <tstamp/>
   <mkdir dir="${build}"/>
 </target>
 <target name="compile" depends="init"
       description="compile the source " >
   <javac srcdir="${src}" destdir="${build}"/>
 </target>
 <target name="dist" depends="compile"
       description="generate the distribution" >
   <mkdir dir="${dist}/lib"/>
   <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
 </target>
 <target name="clean"
       description="clean up" >
   <delete dir="${build}"/>
   <delete dir="${dist}"/>
 </target>

</project>

To execute a build of this project it is simply done from the command line. Assuming Ant has been installed correctly and is in the execution path of the shell, simply type ant in the directory with the build.xml and the project will be comipled and a Java archive file (.jar file) will be built in the "dist" directory.

IDE integration

Eclipse has used Ant as its build tool for some time. Its easy integration into the IDE is such that one doesn't even need to do anything and the tracking of changes and building of dependencies is done for you.

NetBeans has had an Ant plug-in for some time, but as of Version 4 integrates Ant by default as its project management tool.

Retrieved from "http://www.swbyjeff.com/index.php/Ant"

This page has been accessed 2865 times. This page was last modified 20:31, 21 Dec 2004.


Find
Browse
Main Page
Community portal
Current events
Recent changes
Random page
Help
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Create an account or log in
Special pages
New pages
Image list
Statistics
Bug reports
More...