Ant Basics
To compile our source code with Ant we need the source file:
public class Main {
public static void main(String args[]) {
for(int i=0;i<args.length;i++) {
System.out.println(args[i]);
}
}
}
This should be placed in a folder called src
to match the srcdir
variable in the build file.
and an Ant build.xml
:
<?xml version="1.0"?>
<project name="firstbuild" default="compile" >
<target name="compile">
<javac srcdir="src" includeAntRuntime="no"/>
<echo>compilation complete!</echo>
</target>
</project>
This places the .class
files in the src
directory.
Ant will compile all the files in the src
directory and sub-directories.
Ant XML
Ant expects a build file with the following hierachy:
<?xml version="1.0"?>
<project>
<target>
<task/>
</target>
</project>
We can use the syntax of <tagname/>
to make the tag self closing.
Tasks
We can reference the following link for the tasks available in Ant: