< Day Day Up > |
5.3 Configuring Ant in EclipseEclipse also lets you configure its internal version of Ant. To configure how Ant will run, select Window Preferences, followed by the Ant item, as shown in Figure 5-7. In Eclipse, you don't need to name your build file build.xml; Ant will try to guess which file is the build file (the build file does need to be an XML file, with a name that has the extension .xml). You can help Eclipse out by giving an alternate name, or a list of names, in this dialog. Figure 5-7. Configuring the build fileYou can also set Ant runtime options by selecting the Runtime node, as shown in Figure 5-8. For example, to use a more recent version of Ant in Eclipse (Eclipse 2.1.1 comes with Ant 1.5.3, but the latest version of Ant, as of this writing, is 1.5.4, and Version 1.6 is out in beta; you can get alternate Ant versions directly from Apache at http://ant.apache.org), select the Runtime item and change the JAR entries you see in Figure 5-8 to the new versions of ant.jar and optional.jar. You can also set Ant variables like ANT_HOME in this dialog. Figure 5-8. Configuring Ant in EclipseYou can add new Ant tasks and types with the Tasks and Types tabs, which means that those tasks and types will be available to build files without having to use Ant taskdef or typedef elements. Eclipse also lets you set global Ant properties if you select the Properties tab in this dialog. To add a new global property, click the Add button in the Properties tab, and enter a name and value for the new property. You also have limited control over the Ant editor's options using the Preferences dialog and selecting the Ant Editor item. The Ant editor is actually little more than a simple XML editor, but you can specify such items as the colors used in syntax highlighting, or whether the editor shows an overview ruler, as you see in Figure 5-9. Figure 5-9. Configuring the Ant editor
You can also configure Ant when you're about to run it, before selecting an Ant target to build. Right-click build.xml, select Run Ant, and click the Main tab in the dialog that opens, as shown in Figure 5-10. You can set the location of the build file you want to use here, as well as the base directory for the build. You can also set Ant arguments in the Arguments field. Figure 5-10. Setting the run configuration
In addition, there's also an Ant view in Eclipse, which you open with Window Show View Other Ant. This view provides an Ant-based overview of build files; to add a build file to this view, right-click the view, select Add Buildfile, and navigate to the build file you want to display. The view will display a breakdown of the build file, as you see in Figure 5-11, and you can run various Ant targets by right-clicking them and selecting Run. Figure 5-11. The Ant view |
< Day Day Up > |