Mapping a Target to an IDE Command


When you use the Java Project With Existing Ant Script project template, the New Project wizard enables you to map specific build targets to IDE commands, including the following:

  • Build Project

  • Clean Project

  • Generate Javadoc

  • Run Project

  • Test Project

You can also use the Project Properties dialog box (Build and Run page) to map targets to these commands. Other commands (such as Debug Project, Compile File, Run File, Debug File, and Apply Code Changes) need to have targets created for them and then be mapped in the project.xml file if you want them to work in the IDE.

If you let the IDE generate an Ant target for a command, the IDE handles this mapping automatically. In NetBeans IDE 5.0, the IDE offers to generate targets for the Debug Project and Compile File commands the first time you run those commands. In future versions of the IDE, target generation will be offered for other commands as well.

See Table 16-1 for a list of commands that you can map to your build script. The IDE Action column gives the code name for the command that you use when mapping a build target to the command.

Table 16-1. IDE Commands and Corresponding Action Names Used in the project.xml File

Command

IDE Action

Build Project

build

Clean and Build Project

rebuild

Compile Selected Files

compile.single

Clean Project

clean

Run Project

run

Run Selected File

run.single

Redeploy Project (for web applications)

redeploy

Test Project

test

Test File

test.single

Debug Test For File

debug.test.single

Debug Project

debug

Debug File

debug.single

Apply Code Changes

debug.fix

Step Into

debug.stepinto

Generate Javadoc

javadoc


The next several topics provide examples of how to create Ant targets for specific commands and then map them to the IDE.

The IDE comes bundled with XML schemas for the project.xml file and auto-matically validates them every time you edit and save them. If you make invalid changes to a project.xml file, the IDE reports the errors in the Output window.

If you would like to inspect the schemas yourself, you can view them online. See Table 16-2 for a list of the schemas used.

Table 16-2. Free-Form Project Schema

Schema

Description

www.netbeans.org/ns/freeform-project/1.xsd

Defines the <general-data> part of the project.xml file for all free-form project types.

www.netbeans.org/ns/freeform-project-java/1.xsd

Defines the <java-data> part of the project.xml file for all free-form project types.

www.netbeans.org/ns/freeform-project-web/1.xsd

Defines the <web-data> part of the project.xml file for web applications.




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