简体   繁体   English

从eclipse调试Ant任务

[英]Debug Ant task from eclipse

I am developing a custom ant task with java in the eclipse ide. 我正在eclipse ide中用java开发一个自定义ant任务。

is it somehow possible to debug it? 是否有可能调试它? that is put a breakpoint on the java line and when ant is executed, it stops there and i can step through the code? 这是在java行上设置一个断点,当执行ant时,它会停在那里,我可以单步执行代码?

edit: since this question has been closed as duplicate, i want to elaborate why it is quite different. 编辑:因为这个问题已被关闭为重复,我想详细说明为什么它是完全不同的。

i am looking to debug the java code that makes up an ant task and not the just the steps of an ant build. 我期待调试构成ant任务的java代码,而不仅仅是ant构建的步骤。 the answers already helped me partially, but i still need to figure out why my eclipse doesnt have Debug Remote Java Application. 答案已经部分帮助了我,但我仍然需要弄清楚为什么我的eclipse没有调试远程Java应用程序。

You need to start ANT with the remote debug enabled by entering the following before you run ANT. 在运行ANT之前输入以下内容,需要启用远程调试启动ANT。

set ANT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

This will cause the JVM running ANT to pause until you attach your debugger. 这将导致JVM运行ANT暂停,直到您附加调试器。

Next you'll need to modify the classpath ANT is using in order to pickup the classes that form the custom task you're writing. 接下来,您需要修改ANT正在使用的类路径,以便拾取构成您正在编写的自定义任务的类。 I don't think there's a way to do this easily with environment vars, so the quickest thing is to just edit the ant.bat file. 我不认为有一种方法可以轻松地使用环境变量,所以最快的方法是编辑ant.bat文件。

Now when your custom task is run, it will stop at any breakpoints in your IDE. 现在,当您运行自定义任务时,它将在IDE中的任何断点处停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM