Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Intellij IDEA support debugging a project built with ant?

This project is using Ant as its build system. Can I debug the project when I run it via Ant?

like image 920
calvin Avatar asked Nov 28 '14 23:11

calvin


People also ask

What debugger does IntelliJ use?

IntelliJ provides inbuilt Java debugger.

How do you debug an Ant app?

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.

Does IntelliJ support Ant?

IntelliJ IDEA supports the latest stable Ant version. Ant is a flexible, platform-independent build tool from Apache Ant Project.


2 Answers

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.

like image 183
peter.petrov Avatar answered Sep 20 '22 03:09

peter.petrov


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).

like image 22
Gayan Weerakutti Avatar answered Sep 21 '22 03:09

Gayan Weerakutti