< Zurück | Inhalt | Weiter >

10.2.5 Integration with Ant

If you’ve already discovered ant, either by using it on a Java project or by reading this book in chapter order, then you’ll know that it’s a plus to have ant integrated into NetBeans. As of NetBeans version 3.5, ant comes bundled with NetBeans and you don’t need to install it separately.

NetBeans recognizes a build.xml buildfile and gives it a special icon. If you click on the icon for the build.xml file in the Explorer, it will show each of the properties and then each of the targets (Figure 10.10). Right-click on a target to choose Execute to run ant with that target. As a shortcut you can ei- ther select that target and press the F6 key, or you can just double-click on the target name.

If you are making frequent use of an ant build script in your project, you may want to add a shortcut—an icon that you can put on the icon panel—that



image


Figure 10.10 Cascaded menu after choosing CVS


will run a specified ant target. You can also add a keyboard shortcut, to invoke the target with a keystroke or two. The specific steps for doing that are found in the NetBeans online help. Just look for the section titled Creating a Shortcut to a Target.

There is one other topic worth mentioning about integration with ant.

Normally in NetBeans, when you compile a Java class, the IDE does the com- pilation. You can configure the IDE to use different types and versions of Java compiler, but it is the IDE which controls the compile. You can invoke a compile with the F9 key as a shortcut. But if you are building with ant, you may want ant to do the compiles for you. Fortunately, you can configure NetBeans to do this. Again, we’ll refer you to the NetBeans online help, to a section called Indirect Ant Compilation.