Sometimes you may need to debug your custom Java ANT task (or even occasionally debug ANT source itself) when running from the command line. This can be achieved by setting ANT_OPTS as given below before running the “ant” command.
It might be a good idea to specify “suspend=y” as shown above since this will make the Java Virtual Machine (JVM) in which ANT executes to wait until you attach your debugger (from NetBeans of any IDE) along with the sources containing breakpoints.
This method can be used to debug ANT tasks running on a remote (build) server too without having to install an IDE and mounting source code in that particular server. This is made possible because the JVM opens a port for remote debugging which comes in handy not only for debugging ANT tasks but basically any java program that executes remotely.