Blog "ant--using Ant to build a simple Java Project (ii)" We have simplified the command to execute the main method in the test class, this blog describes how to make the build.xml file and the properties it uses to define the property tag Separation:
1. Create a new file named Build.properties in the test folder, and enter the attributes and their property values as "Key=value" in the file that you originally defined in the Build.xml file as follows:
Src=srclib=build/libdest=build/classesnp_jar=build/lib/test.jar
2. Modify the code in the Build.xml file:
<?xml version= "1.0" encoding= "UTF-8"? ><project name= "Test" default= "Run-test" basedir= "." ><property file= "./build.properties"/><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>
Now that the Build.xml file is implemented and the attribute is separated using the property tag definition , how are the two files associated with the separation? Oh oh, please note that the <property file= "./build.properties"/>--in the Build.xml file is clearly understood, and they are associated with the file attribute in the property tag.
The result of the DOS window executing the ant command alone is as follows:
ant--building A simple Java project with Ant (iii)