concept Project in category ant

appears as: A Project, Project, Project
Ant in Action

This is an excerpt from Manning's book Ant in Action.

Figure 17.1 shows the main Ant classes. A Project hosts Target and Task instances; targets (and any other TaskContainer) can also contain tasks. Task classes are themselves extensions of the abstract ProjectComponent class, which is an indirect parent of everything from datatypes to conditions.

The <script> task provides two fixed-name implicit objects to the script context: project and self. The project object is a reference to the current Ant Project instance, offering all the methods covered in chapter 17. The self object is a reference to the Script task instance. This reference is useful for logging messages, using the log methods that Task provides. In listing 18.1 we used both project and self, calling project.setNewProperty to assign a property and self.log to generate a message at the debugging level.

Ant can be used within any Java program. You can either create a build.xml file and hand it off, or create a Project instance with tasks and targets via Java operations. Interestingly, there’s one way that is hard to use Ant: its static entry point, Main.main() calls System.exit() at the end. If you want to embed this class, you have to subclass its Main and override its exit() method. You can still use Ant’s launcher application, specifying the new entry point via the -main argument. However, we’ll ignore this route, as fully embedded Ant is more interesting.

Listing 18.10 shows Ant running inside another Java program. It doesn’t do much—just runs the <echo> task. What’s important is that a Project instance has been created and set up, with logging all wired up and running at the “info” level.