Ant 构建不会在 Eclipse 中运行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3729686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:07:15  来源:igfitidea点击:

Ant build won't run in Eclipse

eclipseant

提问by James Adams

I have an Ant build.xml which no longer runs when launched in Eclipse.
I click on the External Tools Configuration, select the Ant Build I've been running, and click Run.
Nothing happens -- no console window and the build doesn't appear to launch (the classes are not compile nor is the WAR file created).

我有一个 Ant build.xml,它在 Eclipse 中启动时不再运行。
我单击 External Tools Configuration,选择我一直在运行的 Ant Build,然后单击 Run。
什么都没有发生——没有控制台窗口,构建似乎没有启动(类没有编译,也没有创建 WAR 文件)。

I recently added a plugin (Spring IDE), this is the only thing I can think of that has changed recently as far as my Eclipse configuration.
I can run the Ant build fine from the command line.

我最近添加了一个插件(Spring IDE),这是我能想到的唯一改变了我的 Eclipse 配置的东西。
我可以从命令行正常运行 Ant 构建。

Can anyone suggest where I might look to track down my error?

谁能建议我在哪里可以追踪我的错误?

I'm using the Eclipse Helios release, Build id: 20100617-1415 on Windows XP.

我在 Windows XP 上使用 Eclipse Helios 版本,构建 ID:20100617-1415。

回答by Vipin

I faced same problem today , reason behind this was ANT_HOME path variable explained in other answers also.

我今天遇到了同样的问题,这背后的原因是其他答案中也解释了 ANT_HOME 路径变量。

Initially I added ANT_HOME at 2 places given below and it was not working.

最初我在下面给出的 2 个地方添加了 ANT_HOME,但它不起作用。

window->preferences->ant->runtime->properties Tab

窗口->首选项->ant->运行时->属性选项卡

window->preferences->ant->runtime->Classpath Tab

窗口->首选项->ant->运行时->类路径选项卡

But when I remove Classpath tab ant home entry( by setting it to default using Restore default option on right bottom of preferences window ) it worked :). So far it is just a surprise for me because I added same ant home path at both the places.

但是,当我删除 Classpath 选项卡 ant home 条目时(通过使用首选项窗口右下角的恢复默认选项将其设置为默认值),它起作用了:)。到目前为止,这对我来说只是一个惊喜,因为我在两个地方都添加了相同的蚂蚁回家路径。

回答by shonky linux user

As per pstanton's comment this symptom will occur if your ANT_HOME folder is not correctly defined in Eclipse. Eclipse seems to ignore the ANT_HOME system property.

根据 pstanton 的评论,如果您的 ANT_HOME 文件夹未在 Eclipse 中正确定义,则会出现此症状。Eclipse 似乎忽略了 ANT_HOME 系统属性。

window->preferences->ant->runtime->Classpath Tab

窗口->首选项->ant->运行时->类路径选项卡

回答by VonC

You can check out the example in this Apache Ant tutorial.

您可以查看此Apache Ant 教程中的示例

But you can also try to run your same build.xmlant files through a Java Launcher, with org.apache.tools.ant.Mainas the Main class.
That would at least prove your scripts are working in an Eclipse environment.

但是您也可以尝试build.xml通过 Java Launcher运行相同的ant 文件,org.apache.tools.ant.Main作为 Main 类。
这至少可以证明您的脚本在 Eclipse 环境中工作。

When you look at the Ant FAQ, you also see:

当您查看Ant 常见问题解答时,您还会看到:

I installed Ant 1.6.x and now get java.lang.InstantiationException: org.apache.tools.ant.Main

The cause of this is that there is an old version of ant somewhere in the class path or configuration.

我安装了 Ant 1.6.x 现在得到 java.lang.InstantiationException: org.apache.tools.ant.Main

造成这种情况的原因是类路径或配置中某处存在旧版本的 ant。

Maybe your error message is somehow hidden, but it can be worth checking your classpath and see if no other ant library is there.

也许您的错误消息以某种方式隐藏了,但检查您的类路径并查看是否有其他 ant 库是值得的。