ANT (Another Neat Tool)

ANT is a tool for automating software build processes, implemented in Java, and best suited to build Java projects. Ant uses an XML file to describe the build process and its dependencies.

Ant is an Apache project, it is open source software, released under the Apache Software License

Project Template

Here follows a simple buildfile that:

  • initializes properties and classpath
  • compile java classes
  • build jar and javadoc
<?xml version="1.0" encoding="UTF-8"?>
<project name="project" default="build" >
    <description>simple project buildfile</description>

    <target name="init" 
    		description="initialize properties and classpath">
        <property name="dir.sources" value="src"/>
        <property name="dir.lib" value="lib"/>
        <property name="dir.build" value="build"/>
        <property name="dir.build.classes" value="${dir.build}/classes"/>
        <path id="classpath.project">
	        <fileset dir="${dir.lib}"></fileset>
        </path>
    </target>

    <target name="build" depends="compile" 
    		description="builds the project">
        <jar jarfile="${dir.build}/jar/${ant.project.name}.jar">
        	<fileset dir="${dir.build.classes}" includes="**" />
        	<manifest/>
        </jar>
    	<javadoc destdir="${dir.build}/doc">
    		<fileset dir="${dir.sources}" defaultexcludes="yes" includes="**/*.java"/>
    	</javadoc>
    </target>

    <target name="compile" depends="init" 
    		description="compile java classes">
    	<javac srcdir="${dir.sources}" destdir="${dir.build.classes}">
    		<classpath refid="classpath.project"/>
    	</javac>
    </target>

</project>

thithi

References

http://ant.apache.org/
http://en.wikipedia.org/wiki/Apache_Ant
http://www.apache.org/