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.