从 Eclipse 调试 Ant 任务 [英] Debug Ant task from eclipse

查看:37
本文介绍了从 Eclipse 调试 Ant 任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 eclipse ide 中使用 java 开发自定义 ant 任务.

I am developing a custom ant task with java in the 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?

由于这个问题已被重复关闭,我想详细说明为什么它完全不同.

edit: since this question has been closed as duplicate, i want to elaborate why it is quite different.

我希望调试构成 ant 任务的 Java 代码,而不仅仅是 ant 构建的步骤.答案已经部分帮助了我,但我仍然需要弄清楚为什么我的 Eclipse 没有调试远程 Java 应用程序.

i am looking to debug the java code that makes up an ant task and not the just the steps of an ant build. the answers already helped me partially, but i still need to figure out why my eclipse doesnt have Debug Remote Java Application.

推荐答案

在运行 ANT 之前,您需要通过输入以下内容来启动 ANT,并启用远程调试.

You need to start ANT with the remote debug enabled by entering the following before you run ANT.

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

这将导致运行 ANT 的 JVM 暂停,直到您连接调试器.

This will cause the JVM running ANT to pause until you attach your debugger.

接下来,您需要修改 ANT 正在使用的类路径,以便选取构成您正在编写的自定义任务的类.我不认为有一种方法可以使用环境变量轻松完成此操作,因此最快的方法是编辑 ant.bat 文件.

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

现在,当您的自定义任务运行时,它将在您的 IDE 中的任何断点处停止.

Now when your custom task is run, it will stop at any breakpoints in your IDE.

这篇关于从 Eclipse 调试 Ant 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆