ant-building A simple Java project with Ant (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.