Chapter 16. Integrating Existing Ant Scripts with the IDE


  • Creating a Free-Form Project

  • Mapping a Target to an IDE Command

  • Setting up the Debug Project Command for a General Java Application

  • Setting up the Debug Project Command for a Web Application

  • Setting up Commands for Selected Files

  • Setting up the Compile File Command

  • Syntax for Mapping Targets to Commands

  • Setting up the Run File Command

  • Setting up the Debug File Command

  • Setting up the Debugger's Apply Code Changes Command

  • Setting up the Profile Project Command for a General Java Application

  • Changing the Target JDK for a Free-Form Project

  • Making a Custom Menu Item for a Target

  • Debugging Ant Scripts

THE USER INTERFACE FOR STANDARD PROJECTS IN NETBEANS IDE is designed to handle common development scenarios, to be easy to use, and to encourage good programming practices (such as modular design with no circular dependencies). It is particularly well suited to creating projects from scratch.

However, the standard user interface does not cover all scenarios, particularly for projects originally developed in other environments. If this is your case, you can take advantage of the IDE's tight integration with Ant to customize the IDE to work with your existing Ant build script.

If you already have your own build script and do not want to (or cannot) re-create it through the IDE, you can set up the IDE to use that build script by creating a free-form project. Free-form projects also might be preferable to standard projects if you create multiple outputs from individual source roots or if there is anything too restrictive in standard projects.

Before committing to using your existing build script with the IDE, carefully consider whether you really need to use your own Ant script, and make sure that it is not possible to replicate your existing build processes with a combination of standard IDE projects, because standard IDE projects will likely be easier to maintain on a long-term basis.


The IDE's project system is based on Ant to the degree that even incremental commands (such as for compiling a single file) and other commands that you might specifically associate with IDE use (such as debugging) are defined in the build script. Build targets for these commands are generated by default in standard projects but not in free-form projects. In free-form projects, it is left up to you to write the targets in whatever way will work with your project.

Using a build script that was created outside of the IDE entails the following steps:

  • Creating a project in the IDE using one of the free-form (With Existing Ant Script) templates.

  • Mapping key existing build targets to the IDE commands that correspond to them (such as for compiling and running applications and running tests). You can create these mappings in the New Project wizard as you set up the project or later in the Project Properties dialog box.

  • Registering classpath items (such as external source roots or JAR files) in the New Project wizard (when creating the project) or in the Project Properties dialog box (after creating the project) so that IDE-specific features such as code completion and refactoring work correctly.

  • Creating new build targets for commands that are IDE-specific and creating mappings to these targets in the project's project.xml file. For some commands, the IDE helps you by offering to generate a target (and the mapping in the project.xml file) when you first run the given command in the IDE, but you might have to modify the target to get it to work correctly for your project. For other commands, you might have to write the target from scratch and manually create the mapping in the project's project.xml file. In Net-Beans IDE 5.0, the IDE offers to generate targets and mappings for the Debug Project and Compile File commands, but leaves it to you to create targets for commands such as Run File, Test File, and Debug File. Most likely, post-5.0 versions of the IDE will offer target generation for the latter commands.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net