ANT Import Task
Introduction
One way to write re-usable/extensible ANT scripts, is to make use of the the import task. This task allows you to easily override targets of the same name and build upon more foundational scripts, like layers:

(each top layer inherits from the layer below it)
The following illuminates this task a bit more and assumes you are familiar with ANT scripting.
Getting Started
You might want to download and play with these example scripts.
Targets & Outputs
If you look at the one.xml script, you will see that the following targets are called in this order:
- init
- compile
- one
- assemble
- finalize
The output from the one.xml script yields the following:

With the two.xml script, you will see that it has the same targets as the one.xml script called in the same order (minus the one target) as shown here:
- init
- compile
- assemble
- finalize
The output from the two.xml script yields the following:
Analysis
The significance of the two.xml output, shown above, is where the “init” and “compile” targets depend on targets originally defined in the one.xml script:
Note that each dependency is qualified with a “one.” prefix. For example: “one.init” and “one.compile”. You need to do this otherwise ANT will think you are referring to targets of the same name as defined in two.xml.
The “one” prefix come from the name of the project as shown here:

Conclusion
None of what has been discussed here is ground breaking but sometimes it is helpful to remember how useful the import task really is. I also believe that in some cases it is not used more when it should be. If you build a well written foundational script (lowest level to be imported) then you should be able to build upon that script with more complicated scripts.
No comments yet.
Leave a comment
You must be logged in to post a comment.
Search
Categories
- Adventures
(91)
- Announcements
(28)
- Business
(16)
- Electronics
(21)
- Epicurean
(9)
- Games
(3)
- Literature
(1)
- Mechanical
(4)
- Meetings
(14)
- Movies
(2)
- Music
(26)
- Photography
(1)
- Services
(24)
- Software
(102)