eclipse eclipse中的ant junit构建错误

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

ant junit build error inside eclipse

javaeclipseantjunit

提问by Tuan

I am hoping there are some people who have seen and have a solution for the problem that I am having right now with ant script. I am using an ant script to compile my java codes in eclipse but eclipse keeps giving me these errors

我希望有些人已经看到并解决了我现在使用 ant 脚本遇到的问题。我正在使用 ant 脚本在 eclipse 中编译我的 java 代码,但是 eclipse 不断给我这些错误

[junitreport] Processing E:\workspace\DataOrchestrationDevelopment\DataOrchestration\Logs\jsreports\junit\html\TESTS-TestSuites.xml to C:\Users\u0160235\AppData\Local\Temp\null1503375679
[junitreport] Loading stylesheet jar:file:/E:/software/apache/apache-ant-1.8.2/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 E:\workspace\DataOrchestrationDevelopment\DataOrchestration\Logs\jsreports\junit\html\TESTS-TestSuites.xml

BUILD FAILED
E:\workspace\DataOrchestrationDevelopment\DataOrchestration\ant\developerbuild.xml:124: The following error occurred while executing this line:
E:\workspace\DataOrchestrationDevelopment\DataOrchestration\ant\QunitAntScript.xml:20: Errors while applying transformations: Fatal error during transformation

My environment settings:

我的环境设置:

  • Windows 7
  • Eclipse 3.6 RC2 32 bit
  • JDK 1.6 update 32 32 bit
  • Ant 1.7.2
  • Junit 4 (within eclipse): in my project jar folder I have junit-dep-4.8.2.jar
  • Windows 7的
  • Eclipse 3.6 RC2 32 位
  • JDK 1.6 更新 32 32 位
  • 蚂蚁 1.7.2
  • Junit 4(在 Eclipse 中):在我的项目 jar 文件夹中,我有 junit-dep-4.8.2.jar

One thing to mention that if I compile my codes outside eclipse using the same ant script, everything works just fine, but it doesn't work inside eclipse. I tried to google the errors above the stylesheet above, but that didn't help me much. My guess is somehow, within eclipse different version of junit is being used, but I might be wrong.

有一件事要提到,如果我使用相同的 ant 脚本在 eclipse 之外编译我的代码,一切正常,但它在 eclipse 中不起作用。我试图用谷歌搜索上面样式表上方的错误,但这对我没有多大帮助。我的猜测是不知何故,在 eclipse 中使用了不同版本的 junit,但我可能是错的。

回答by Steven Darnell

I experienced the same stylesheet problem within Eclipse using the following environment:

我在使用以下环境的 Eclipse 中遇到了相同的样式表问题:

  • Windows 7 x64
  • Eclipse 3.7.2 (SR2) 32-bit
  • JDK 1.6.0_32 32-bit
  • Ant 1.7.2 (from Eclipse) or 1.7.4 (from Apache, current)
  • Junit 4.8.1 (project dependency)
  • 视窗 7 x64
  • Eclipse 3.7.2 (SR2) 32 位
  • JDK 1.6.0_32 32 位
  • Ant 1.7.2(来自 Eclipse)或 1.7.4(来自 Apache,当前)
  • Junit 4.8.1(项目依赖)

My build succeeds while using JDK 1.6.0_31, so it appears the stylesheet problem is an Ant or Java bug introduced with the release of Java 6 build 32. I could not find any reports in Apache's Bugzilla system. If it helps someone, these are the bug fixes included in build 32: http://www.oracle.com/technetwork/java/javase/2col/6u32bugfixes-1579554.html

我的构建在使用 JDK 1.6.0_31 时成功,因此样式表问题似乎是随 Java 6 build 32 发布而引入的 Ant 或 Java 错误。我在 Apache 的 Bugzilla 系统中找不到任何报告。如果它对某人有帮助,这些是构建 32 中包含的错误修复:http: //www.oracle.com/technetwork/java/javase/2col/6u32bugfixes-1579554.html

My current workaround is to use Java 6 JDK build 31.

我目前的解决方法是使用 Java 6 JDK build 31。

Update: Workaround to use a newer JDK

更新:使用较新 JDK 的解决方法

The Ant failures from withinEclipse started with a defect introduced in Java 6u32 and Java7u4. The saga is reported in Eclipse Bug #384757, including a workaround allowing you to use newer JDKs.

从Ant失败启动Eclipse在Java 6u32和Java7u4引入了缺陷。该传奇在Eclipse Bug #384757 中报告,包括一个允许您使用较新 JDK 的解决方法。

  • Download the org.apache.xalanand org.apache.xml.serializerplug-ins from the Eclipse Orbit project
  • Copy them to a directory listed in the Java java.ext.dirsproperty
  • Eclipse Orbit 项目下载org.apache.xalanorg.apache.xml.serializer插件
  • 将它们复制到 Javajava.ext.dirs属性中列出的目录

I use the following directories because they are defined by default and independent of JDK version:

我使用以下目录,因为它们是默认定义的并且与 JDK 版本无关:

  • On Windows: C:\Windows\Sun\Java\lib\ext
  • On Mac: /Users/$USER/Library/Java/Extensions
  • 在 Windows 上: C:\Windows\Sun\Java\lib\ext
  • 在 Mac 上: /Users/$USER/Library/Java/Extensions

The root problem was reported to Oracle, but the bug is no longer in their bug database. I am not optimistic it will ever be fixed.

根本问题已报告给 Oracle,但该错误不再存在于他们的错误数据库中。我并不乐观它会被修复。

Update: Apache fixed the problem in Ant

更新:Apache 修复了 Ant 中的问题

Apache has fixed the root problem; it may be available in the Ant 1.9.0 release (Apache Bug #54641).

Apache 已经修复了根本问题;它可能在 Ant 1.9.0 版本(Apache Bug #54641)中可用

Update: Ant 1.9.1 scheduled for Eclipse 4.4

更新:Ant 1.9.1 计划用于 Eclipse 4.4

As @OliBlogger mentioned, Apache fixed the root problem in Ant 1.9.1. Eclipse plans to update to Ant 1.9.1 in Eclipse 4.4(perhaps sooner, the Eclipse bug system does not yet have 4.3.x milestones).

正如@OliBlogger 提到的,Apache 修复了 Ant 1.9.1 中的根本问题。Eclipse 计划在 Eclipse 4.4 中更新到 Ant 1.9.1(也许更快,Eclipse 错误系统还没有 4.3.x 里程碑)。

Update: Fixed in Eclipse 4.4

更新:在 Eclipse 4.4 中修复

I confirmed that my build now succeeds using Java 7 JDK build 67 and Ant 1.9.2 distributed with Eclipse 4.4.1 (Windows 7) without using the Orbit plug-in workaround.

我确认我的构建现在成功使用 Java 7 JDK build 67 和 Ant 1.9.2 与 Eclipse 4.4.1 (Windows 7) 一起分发,而不使用 Orbit 插件解决方法。

回答by Jan Arciuchiewicz

Please try to go to Preferences->Ant->Runtimeand set the Ant Home... there to your ant installation folder. By default eclipse comes with and uses an ant contributed as a plug-in.

请尝试转到Preferences->Ant->Runtime并设置 Ant Home... 到您的 ant 安装文件夹。默认情况下,eclipse 附带并使用一个 ant 作为插件提供。

You can also add there additional jars, folders if needed.

如果需要,您还可以在那里添加其他 jars、文件夹。

回答by Bill

It was stated in https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757#c18that the fix for this was in Ant 1.9 but unfortunately it seems to be sechduled for 1.9.1 now. So in the mean time this worked for me.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=384757#c18中指出,对此的修复是在 Ant 1.9 中,但不幸的是它现在似乎已用于 1.9.1。所以同时这对我有用。

You can use the style sheets from http://svn.apache.org/viewvc?view=revision&revision=1453414. Then add "stledir"to the report tag. example: styledir="c:\utils"

您可以使用来自http://svn.apache.org/viewvc?view=revision&revision=1453414的样式表。然后将“stledir”添加到报告标签。例子:styledir="c:\utils"

回答by jm0

I've tried using a few different JRE/JDK settings (all 1.6 and 1.7) with problems ineach.

我尝试使用一些不同的 JRE/JDK 设置(所有 1.6 和 1.7),但每个设置都有问题。

It's not a perfect solution obviously but I don't seem to run into these issues if the JUnit report is "raw" in the buildfile -- not wrapped in a target.

显然,这不是一个完美的解决方案,但如果 JUnit 报告在构建文件中是“原始的”——而不是包含在目标中,我似乎不会遇到这些问题。

Poor workaround obviously in that targets are an important aspect of Ant but sometimes for reporting build targets/dependencies aren't so mission critical. It's not so much of an issue for me yet because I'm running these reports in kindof a one-off fashion rather than as part of a build.

糟糕的解决方法显然是因为目标是 Ant 的一个重要方面,但有时报告构建目标/依赖项并不是那么关键的任务。这对我来说还不是什么大问题,因为我正在以一种一次性的方式运行这些报告,而不是作为构建的一部分。

Hope it helps someone but also hope this gets fixed properly.

希望它对某人有所帮助,但也希望这能得到妥善解决。

回答by Pallavi Singh

I had a similar issue. I had this combination for my project:

我有一个类似的问题。我的项目有这个组合:

Java: jdk1.6.0_45 Ant: eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030 Java compiler: 1.6

Java:jdk1.6.0_45 Ant:eclipse\plugins\org.apache.ant_1.8.2.v20120109-1030 Java编译器:1.6

I changed my java to JRE6 and it worked absolutely fine

我把我的 java 改成了 JRE6,它工作得很好

回答by IqbalHamid

According to the documentation hereand here, the Ant task, <JUnitReport>requires Apache Xalan 2.4.1+ or Xalan XSLT. They can be obtained from the external library, xalan.jar. Make sure you have these dependencies.

根据此处此处的文档,Ant 任务<JUnitReport>需要 Apache Xalan 2.4.1+ 或 Xalan XSLT。它们可以从外部库xalan.jar 获得。确保您有这些依赖项。