ant--building A simple Java project using Ant (ii)

Source: Internet
Author: User

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)

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.