2008年6月29日 星期日

ant

like makefile

use xml

create a file called build.xml.  Then run ant.  Then the project is compiled 
( ant -verbose will print more information)

the top level element is project, its default attribute decides which target to do
ex:
<project name="Test"  default="compile">

the target's depends property decides what targets must be done before it
ex:
<target name="compile"  depends="init>

how to run ant:
1. ant  
   this will execute default target
2. ant  targetName

show information about build.xml
ant -projecthelp
show the targets with their description
( the description is described by description property of each target)

some useful tasks:
1. javac  srcdir="src", destdir="bin"
compile java codes

2.  <echo>hello</echo>
print message when running ant 

3, <mkdir  dir="test/bin"/>

4. <jar  destfile="dist/test.jar"  basedir="bin" />

5. <delete dir="bin" />

6. <java classname="Test.Main"  classpath="bin">
    <arg value="peter"/>
    <arg value="andy"/>
   <arg file="."/>
   </java>

沒有留言: