Compiling Projects With Ant

If you want to compile an entire project using an Ant script, you should execute the Ant script or one of its targets by double-clicking its Explorer node or using target shortcuts. Alternatively, you can specify Indirect Ant Compilation as the default compiler for the files in a project and point it to the desired Ant script.

You may, however, need to compile and build part of your project using your Ant script and the rest using the IDE's native compilation. You can do so by adding the Ant script to the Project tab and setting it to run when the project is compiled using the Compile Project command.

The default Compiler setting for all Ant scripts is (do not compile). Thus if the IDE runs across an Ant script in the Project tab while compiling a project, it ignores it and continues compiling according to the project's compiler settings. When an Ant script's Compiler is set to Ant Script Compilation, the IDE runs the script and compiles the rest of the project natively.

To compile a project using both an Ant script and the IDE's native compilation:

  1. Add the Ant script to the Project tab by right-clicking its Explorer node and choosing Tools and choosing Add to Project.
  2. Right-click the Ant script and choose Properties. In the Execution tab of the property sheet, click the ellipsis in the Compiler setting. In the Compiler property editor, select Ant Script Compilation.

    The Compiler property editor also lets you change the targets that the IDE runs whenever you use the Compile Project, Build Project, and Clean Project commands. Type the targets in the Compile, Build, and Clean properties, respectively.

    The targets you set here are used by all scripts that use Ant Script Compilation. To apply your changes only to the present project, set the Ant Script Compilation at the project level in the Options window. Alternatively, you can create a copy of Ant Script Compilation, set the targets for the copy, and set the Ant script to use the customized copy.

  3. Choose Project and choose Compile Project from the main window.
tip

By default, the IDE compiles your sources before executing them. If you have an Ant script in the Project tab, and the Ant script uses Ant Script Compilation, the IDE runs the Ant script every time you choose Execute Project. To turn off automatic compilation before execution, choose Tools and choose Options. Then expand the Debugging and Executing node, select Execution Settings, and set the Run Compile property to False. This change applies to all forms of execution in the IDE, and not just to Ant Script Execution.

See also
Compiling Files With Ant
Running an Ant Script
Executing a Target
Creating a Shortcut to a Target
Editing an Ant Script
Configuring Ant Settings

Legal Notices