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, click Miscellaneous in the left panel of the window, and expand the Ant node. Use the Classpath section to manage the Ant classpath.
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.