Two methods to call external ant tasks in ant

Source: Internet
Author: User

Calling external ant tasks in ant scripts is particularly useful in multi-project management. The two methods are summarized as follows:

Use antfile and Exec

 

I. Use antfile

<Target name = "copy_lib" Description = "copy library files from project1 to project2">
<Ant antfile = "build. xml"
Dir = "$ {project1dir }"
Inheritall = "false"
Inheritrefs = "false"
Target = "copy_to_project2_lib"
/>
</Target>

 

Antfile indicates the build file of the subitem.
Dir indicates the directory of the created file. The default value is the current directory.

Inheritall indicates that all attributes of the parent project can be used in the Child Project and overwrite the attributes of the same name in the Child Project. The default value is true.
Inheritrefs indicates that all references in the parent project can be used in the Child project, and does not overwrite the reference of the same name in the Child Project. The default value is false.
If the definition reference displayed in the ant task is <reference refID = "filter. Set">, the reference overwrites the reference of the same name in the sub-project.
Target indicates the target in the sub-project to be run. If not written, the default target is used.

 

Ii. Use Exec

<Target name = "copy_lib" Description = "copy library files from project1 to project2">
<Exec executable = "cmd.exe">
<Arg line = "/C & quot; CD ../project1 & amp; ant copy_to_project2_lib & quot;"/>
</Exec>
</Target>

 

The command line is: cmd.exe/C "CD ../Project & ant copy_to_project2_lib"

This means that you can directly call the system console, run the CD command, and then run the ant script to specify the task./C indicates that the subsequent tasks are executed.String
Command, and then stop.

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.