The blog "ant--using ant to build a simple Java project (i)" demonstrates the use of ant tools to build a simple Java project, followed by this example to further study Ant:
The above example executes the Build.xml file script more cumbersome, can not simplify the execution of the script it? The answer is yes, you can change the script in the Build.xml file to the following script:
<?xml version= "1.0" encoding= "UTF-8"? ><project name= "Test" default= "Run-test" basedir= "." ><property name= "src" value= "src"/><property name= "Lib" value= "Build/lib"/><property name= "Dest" Value= "build/classes"/><property name= "Np_jar" value= "Build/lib/test.jar"/><target name= "Create-path" ><mkdir dir= "${dest}"/><mkdir dir= "${lib}"/></target><target name= "Create-class" depends= " Create-path "><javac srcdir=" ${src} "destdir=" ${dest} "/></target><target name=" Create-jar " depends= "Create-class" ><jar destfile= "${np_jar}" basedir= "${dest}" > <manifest> <attribute name= " Main-class "value=" Test "/> </manifest></jar></target><target name=" run-Test "depends=" Create-jar "><java classname=" Test "classpath=" ${np_jar} "/></target><target name=" clean ">< Delete file= "${np_jar}"/><delete dir= "${dest}"/><delete dir= "${lib}"/></target></projeCt>
Just execute the ant command to do what you need to do "Ant Create-path", "Ant Create-class", "Ant Create-jar", and "Ant run-test" command in order to complete the operation
ant--building A simple Java project using Ant (ii)