Ant build file

Ant build file is a file named build.xml which resides in the root directory of Java or Scala projects and allows building and testing of the project without the need to compile each file separately by hand. It is an XML based file format.

Example


 Information Compiler for Anonymous XML Standard

         





  <fileset dir='${lib}' includes='*.jar'/>

<taskdef name='xjc' classname='com.sun.tools.xjc.XJCTask'> <classpath refid='classpath'/>

<target name='mkdir' description='Prepare directories for server'> <echo message='Creating needed directories...'/> <mkdir dir='${build}'/> <mkdir dir='${dist}'/> <mkdir dir='${build-test}'/> <mkdir dir='${src}/net/anonymity/freenet/frost/message'/>

<target name='env' depends='mkdir' description='Learn about the environment of the build machine'> <available file='${junit.location}' property='junit.present'/>

<target name='compile' depends='generate' description='Compile'> <echo message='Compiling the source...'/> <javac srcdir='${src}' destdir='${build}' debug='on' optimize='on' nowarn='false' source='${source-version}' target='${source-version}'>

<include name='**/*.java'/> <exclude name='**/*Test.java'/>

<target name='generate' depends='mkdir' description='Generate all the autogenerated code'>

<echo message='Compiling the schema...'/> <xjc schema='${data}/frostMessage.xsd' destdir='${src}' package='net.anonymity.freenet.frost.message' extension='true' removeOldOutput='yes'> <produces dir="${src}/net/anonymity/freenet/frost/message" includes="*.java"/>

<echo message='Copying xsd files...'/> <copy todir="${build}/net/anonymity/freenet/frost" overwrite="true"> <fileset dir="${data}"/>

<target name='dist' depends='compile,unit' description='Generate the distribution' > <jar jarfile='${distfile}' basedir='${build}'>

<attribute name='Main-Class' value='net.anonymity.freenet.fms2frost.FMS2Frost'/> <attribute name='Built-By' value='${user.name}'/> <section name='common'> <attribute name='Specification-Title' value='freekiwiki'/> <attribute name='Specification-Version' value='${product-version}'/> <attribute name='Specification-Vendor' value='freekiwiki.sf.net'/> <attribute name='Implementation-Title' value='freekiwiki'/> <attribute name='Implementation-Version' value='${product-version} ${TODAY}'/> <attribute name='Implementation-Vendor' value='freekiwiki.sf.net'/>

<target name='run' description='Run the distribution' > Not yet implemented

<target name='clean' description='Delete class files and docs dir.'> <echo message='Removing old build and distribution...'/> <delete dir='${build}'/> <delete dir='${build-test}'/> <delete dir='${dist}'/>

<echo message='Removing old JAXB implementations...'/> <delete dir="${src}/net/anonymity/freenet/frost/message"/>

<target name='unit-build' depends='compile,env' if='junit.present' description='Build the JUnit files'> <echo message='Building the JUnit tests'/> <javac srcdir='${test}' destdir='${build-test}' debug='on' optimize='on' source='1.6'> <pathelement path='${build}'/> <pathelement location='${junit.location}'/> <include name='**/*.java'/>

<target name='unit' depends='unit-build,env' if='junit.present' description='Run the JUnit tests'> <echo message='Running JUnit test'/> <junit printsummary='yes' fork='yes' haltonfailure='yes'> <pathelement path='${build}'/> <pathelement path='${build-test}'/> <pathelement location='${junit.location}'/>

<formatter type='plain' usefile='false'/>

<batchtest fork='yes'> <fileset dir='${build-test}'> <include name='**/*Test.class'/>

<target name='javadoc' depends='mkdir'> <javadoc sourcepath='${src}' destdir='${javadoc}'> <fileset dir='${src}' includes='**/*.java' />