Does Intellij IDEA support debugging a project built with ant?

我是研究僧i 提交于 2019-12-10 04:37:09

问题


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


回答1:


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.




回答2:


There is a specialized IDEA plugin for debugging ant scripts sources with breakpoints:

https://plugins.jetbrains.com/plugin/7195?pr=idea

https://github.com/opticyclic/antdebugger/

Or the same approach can be used as for ant debugging in eclipse.




回答3:


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



来源:https://stackoverflow.com/questions/27197005/does-intellij-idea-support-debugging-a-project-built-with-ant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!