By default, the IDE ignores your environment's CLASSPATH variable whenever it runs Ant. For your build script to use custom tasks, you must add the tasks to Ant's classpath in the IDE.
You can add custom tasks to Ant's classpath within the IDE by:
If you cannot declare a classpath in your build script, or you are using third-party
build scripts which you cannot alter, you can add the tasks to Ant's classpath
in the IDE. Open the Options window, select Building Ant
Settings, and type the full path to the binary in the Additional Classpath property.
Using an explicit classpath is the recommended method, as it ensures that your build scripts will be fully portable. You can write your tasks and include instructions to compile them and produce a JAR file in the build file. To use these tasks, include the long form of taskdef, which includes a classpath. Here is a simple of such a task.
The advantage of this method is that no special preparation is needed to begin using the script. The script is entirely self-contained and portable. This method also makes it easier to develop your tasks within the IDE, as the script compiles them for you automatically.
To make the your build scripts even more robust, use a property instead of a hard-coded location to specify the classpath to your tasks. You can store the property in the build script itself or in a separate ant.properties file. You can then change the classpath setting throughout your script by simply changing the value of the specified property.
If you do not plan to use your build script outside of the IDE, you can mount the filesystem containing the source code for your tasks in the IDE's Filesystems window. In your build script, add the following subelements to your taskdef:
<classpath> <pathelement path="${netbeans.library.path}"/> <pathelement path="${netbeans.filesystems.path}"/> </classpath>You do not need to provide values for {netbeans.library.path} and {netbeans.filesystems.path}. These properties are global Ant properties which the IDE expands to classpaths containing the IDE's own libraries (including Ant, parsers, and other libraries) and all of your mounted filesystems.
See Also | |
---|---|
Creating a Custom Ant Task Optional Ant Tasks Configuring Ant Settings Creating an Ant Script |