Eclipse IDE for Java 中的 Ant 构建错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11785698/
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 18:44:23  来源:igfitidea点击:

Ant Build Error in Eclipse IDE for Java

eclipseantjunitjdk1.6

提问by Matthew Helfgott

I have been receiving the following error and have done a lot of research and tried all of the offered solutions to no avail.

我一直收到以下错误,并进行了大量研究并尝试了所有提供的解决方案均无济于事。

junitreport:
 [junitreport] Processing C:\workspace\test123\junit\TESTS-TestSuites.xml to C:\Users\Matt\AppData\Local\Temp\null1903337257
 [junitreport] Loading stylesheet jar:file:/C:/Users/Matt/Documents/Selenium/eclipse/plugins/org.apache.ant_1.8.3.v20120321-1730/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl
 [junitreport] : Error! The first argument to the non-static Java function 'replace' is not a valid object reference.
 [junitreport] : Error! Cannot convert data-type 'void' to 'reference'.
 [junitreport] : Fatal Error! Could not compile stylesheet
 [junitreport] Failed to process C:\workspace\test123\junit\TESTS-TestSuites.xml

BUILD FAILED
C:\Users\Matt\workspace\Test1\build.xml:122: Errors while applying transformations: Fatal error during transformation

I found a solution at ant junit build error inside eclipseand saying that the issue was caused by a newer version of JDK and using 1.6_31 would solve it and I tried that following instructions I found online on how to change the version of Java eclipse is using. Every time I run the build ant it returns the same error regardless of which version of Java I am using. I have tried JRE7, jdk1.7.0_05, jdk1.6.0, jdk1.6.0_31 and others that I don't have installed anymore.

在 Eclipse中的ant junit build error找到了一个解决方案,并说这个问题是由较新版本的 JDK 引起的,使用 1.6_31 可以解决它,我尝试按照我在网上找到的关于如何更改 Java eclipse 版本的说明进行操作使用。每次运行构建 ant 时,无论我使用的是哪个版本的 Java,它都会返回相同的错误。我已经尝试过 JRE7、jdk1.7.0_05、jdk1.6.0、jdk1.6.0_31 和其他我不再安装的东西。

I am running the following

我正在运行以下

  • Windows 7 Pro SP1 x64
  • Eclipse IDE for Java Developers Version: Juno Release Build id: 20120614-1722
  • org.apache.ant_1.8.3.v20120321-1730
  • Windows 7 专业版 SP1 x64
  • 适用于 Java 开发人员的 Eclipse IDE 版本:Juno 发布版本 ID:20120614-1722
  • org.apache.ant_1.8.3.v20120321-1730

If anyone could provide any assistance in getting this report running it would be greatly appreciated. I'm new to programming and this is very frustrating especially since I'm still learning all of the jargon and trying to be sure I am following the instructions properly. If you require anymore information from me I will provide it and I will follow any instruction given to the best of my ability. Thank you very much in advance.

如果有人可以提供任何帮助来运行此报告,我们将不胜感激。我是编程新手,这非常令人沮丧,尤其是因为我仍在学习所有术语并试图确保我正确地遵循了说明。如果您需要我提供更多信息,我将提供,并且我将尽我所能遵循任何指示。非常感谢您提前。

采纳答案by Christian Fries

While an Ant Bug Report 384757claims that this is caused by the XSL Tranformer build into the Oracle JDK - which may be true - the problem can be fixed by changing the Ant version:

虽然Ant 错误报告 384757声称这是由 Oracle JDK 中内置的 XSL Transformer引起的(这可能是真的),但可以通过更改 Ant 版本来修复该问题:

I tried some of the workarounds mentioned there. After a while, I found that the bug appears with Ant 1.8.3 (distributed in Eclipse), but not with Ant 1.8.2 (distributed in Eclipse 3.7).

我尝试了那里提到的一些解决方法。一段时间后,我发现该错误出现在 Ant 1.8.3(在 Eclipse 中分发)中,但在 Ant 1.8.2(在 Eclipse 3.7 中分发)中没有出现。

The bug also does not appear with Ant 1.9.0.

该错误也不会出现在 Ant 1.9.0 中。

I have downloaded Ant 1.9.0and in configured Eclipse's "Run As -> Ant build..." to use the Ant 1.9.0 folder as ANT HOME. This worked.

我已经下载了 Ant 1.9.0并在配置的 Eclipse 的“Run As -> Ant build...”中使用 Ant 1.9.0 文件夹作为 ANT HOME。这奏效了。

PS: My Eclipse used Ant 1.8.3 (which did not work), but running Ant from the console used Ant 1.8.2 (which worked). This was confusing at first.

PS:我的 Eclipse 使用 Ant 1.8.3(不起作用),但从控制台运行 Ant 使用 Ant 1.8.2(起作用)。这起初令人困惑。

回答by user2447601

I have solved the issue by downloading apache-ant-1.9.1 and configuring it in Eclipse by changing the ANT HOME from windows--> Preferences and setting the ANT HOME to apache-ant-1.9.1.

我通过下载 apache-ant-1.9.1 并在 Eclipse 中通过从 windows--> 首选项更改 ANT HOME 并将 ANT HOME 设置为 apache-ant-1.9.1 来配置它解决了这个问题。

回答by QaTester

Below workaround fixed the build issue I had...

以下解决方法修复了我遇到的构建问题...

Download the 2 jar files from the urls given below and add those to Ant-Runtime Classpath located on Eclipse at: Window>Preferences> Ant>Runtime>Ant Home Entries

从下面给出的 url 下载 2 个 jar 文件,并将它们添加到位于 Eclipse 上的 Ant-Runtime Classpath 中:Window>Preferences> Ant>Runtime>Ant Home Entries

Restart eclipse and run the Ant build.

重新启动 eclipse 并运行 Ant 构建。