In Java development, Ant provides us with a very powerful project building capability. In daily development, the most commonly used functions are: Compile, package, run JUnit testcase, check coding specifications. Here are some of the most common features of an ant template file, shared with you.
<?xml version= "1.0" encoding= "gb2312"?>
<project name= "Test project" default= "All" basedir= "." >
<property name= "Src.code" value= "src"/>
<property name= "Src.junit" value= "JUnit"/>
<property name= "Lib.dir" value= "Lib"/>
<property name= "Lib.jar" value= "Testclass.jar"/>
<!--checkstyle configuration-->
<property name= "Checkstyle.config" value= "Checkstyle.xml"/>
<taskdef resource= "Checkstyletask.properties"
Classpath= "${lib.dir}/checkstyle-all-3.1.jar"/>
<!--output document-->
<property name= "Doc.dir" value= "Doc"/>
<property name= "Doc.api" value= "${doc.dir}/api"/>
<property name= "Javadoc.package" value= "com.*"/>
<!--output binary file-->
<property name= "Dist.root" value= "dist"/>
<property name= "dist.proj" value= "${dist.root}/proj"/>
<property name= "dist.classes" value= "${dist.proj}/classes"/>
<property name= "Dist.lib" value= "${dist.proj}/lib"/>
<property name= "Dist.junit" value= "${dist.root}/junit"/>
<!--classpath-->
<path id= "Classpath" >
<fileset dir= "${lib.dir}" >
<include name= "**/*.jar"/>
</fileset>
</path>
<path id= "Proj.libs" >
<fileset dir= "${dist.lib}" >
<include name= "**/*.jar"/>
</fileset>
</path>
<target name= "Init" >
<mkdir dir= "${doc.dir}"/>
<mkdir dir= "${dist.root}"/>
<mkdir dir= "${dist.proj}"/>
<mkdir dir= "${dist.lib}"/>
<tstamp/>
<echo message= "${tstamp}" ></echo>
</target>
<target name= "All" depends= "compilesrc, Javadoc, Checkstyle"/>