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

Source: Internet
Author: User

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)

Related Article

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.