This project is using Ant as its build system. Can I debug the project when I run it via Ant?
IntelliJ provides inbuilt Java debugger.
Open the Ant view (Window -> Show view -> Ant). If the build file isn't in the view then you can simply add it. Once added right click on the ant target you want to run and select Debug as -> Ant build. The Debug perspective should open up and the process should stop at your breakpoint where you can step through it.
IntelliJ IDEA supports the latest stable Ant version. Ant is a flexible, platform-independent build tool from Apache Ant Project.
Ant is mainly used for building, not for running Java apps.
But OK, I assume you're running your app using the ant Java task.
Ant Java task
If so, yes, you can do that by using remote debugging.
Remote debugging a Java application
In fact you can debug any Java app like that.
Apps started through ant are still Java apps.
Include this line in your java runtime task, in your build.xml:
<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>
So for instance if it's ant junit task, it will be like:
<target name="test" depends="test-compile">
<junit showoutput="yes" fork="true">
<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>
</junit>
</target>
Then run your target
ant clean test
Ant test will wait until we connect a debugger. It will show the output:
test:
[junit] Listening for transport dt_socket at address: 5005
Then simply create, run a remote run/debug configuration in Intellij (or in your preferred IDE).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With