Blogant-using Ant to build a simple Java Project (ii)we have simplified the command to run the main method in the test class, this blog describes how to make the build.xml file and the properties defined by the property tag in it Separation:
1, a new file named Build.properties in the test directory, the file in the form of "Key=value" entered the original in the build.xml file defined properties and their property values such as the following:
Src=srclib=build/libdest=build/classesnp_jar=build/lib/test.jar
2. Change 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 has been implemented and the attributes defined in the property tag are separated, 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 only as clear as they are associated with the file attribute in the property tag.
At this point the DOS form runs independently of the results of the ant command, for example:
ant-building A simple Java project with Ant (iii)