Ant<junitreport>由于 Xalan 的 (XSLT) 安全处理功能而失败 [英] Ant <junitreport> fail because of Xalan's (XSLT) secure processing feature

查看:25
本文介绍了Ant<junitreport>由于 Xalan 的 (XSLT) 安全处理功能而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 junit 测试在我的 Eclipse 环境中通过 ant 1.7 运行,但在执行 junitreport 任务时构建失败:

My junit tests run via ant 1.7 from within my Eclipse environment but the build failes when the junitreport task is performed:

构建失败.../build.xml:222: 应用转换时出错:javax.xml.transform.TransformerException: java.lang.RuntimeException:扩展函数'xalan://org.apache.tools.ant.util.StringUtils:replace'的使用安全处理功能设置为 true 时不允许.

BUILD FAILED .../build.xml:222: Errors while applying transformations: javax.xml.transform.TransformerException: java.lang.RuntimeException: Use of the extension function 'xalan://org.apache.tools.ant.util.StringUtils:replace' is not allowed when the secure processing feature is set to true.

我试图弄清楚如何让 junitreport 任务禁用安全处理功能(我不需要,目前只在我的方式中)但我不知道如何,因为该任务没有属性来禁用它.或者我应该做其他事情来完成这项工作吗?

I tried to figure out how to make the junitreport task disable the secure processing feature (which I don't need and is only in my way at this point) but I have no clue how since the task doesn't have an attribute to disable it. Or should I do something else to make this work?

推荐答案

这可能与一个非常相似的Ant 1.8.2 中的已知错误.

This may be related to a very similar known bug in Ant 1.8.2.

Ant 1.8.3 的错误修复 已经提交,但是截至 2012 年 1 月 25 日,Apache Ant 1.8.3 尚未发布.此错误修复的最新消息说明是:

The bugfix for Ant 1.8.3 has been committed, but Apache Ant 1.8.3 has yet to be released as of Jan 25 2012. The WHATSNEW description for this bugfix is:

<junitreport> did not work in embedded environments on JDK 7.
Bugzilla Report 51668.

一旦 Ant 1.8.3 发布并被合并到 Eclipse Ant 插件中,这个问题就应该得到解决.

Once Ant 1.8.3 is released and is incorporated into the Eclipse Ant plugin, this issue should be resolved.

与此同时,您可以编辑您的构建脚本,使其仅在从命令行运行 Ant 时才运行 JUnitReport 目标,而不是从 Eclipse 中运行.要做出此决定,请在您的常规 %ANT_HOME%/lib 文件夹中查找一个文件,而该文件在您的 Eclipse Ant 插件文件夹中不存在(或在那里创建一个文件),然后设置一个属性,如果文件被检测到.E.G.

In the meantime, you can edit your build script so it only runs the JUnitReport target if running Ant from a command line, rather than from within Eclipse. To make this determination, look for a file present in your regular %ANT_HOME%/lib folder that is not present in your Eclipse Ant plugin folder (or create a file there), then set a property if the file is detected. E.G.

就在您的 JUnit 目标结束之前:

Just before the end of your JUnit target:

<available file="${ant.home}/lib/ant.pom" property="full.ant"/>

在 JUnitReport 目标的开头:

At the beginning of your JUnitReport target:

  <target name="junitreport" description="Create a consolidated test results report" if="full.ant">

上述 Ant 片段之所以有效,是因为 ant.home 仅在从 Eclipse 中运行 Ant 时才设置为 Eclipse Ant Plugin 文件夹.当从命令行运行 Ant 时,ant.home 将匹配您的 ANT_HOME 环境变量.还应该有一个 eclipse.running Ant 属性,但我无法检测到此属性.

The above Ant fragments work because ant.home is set to the Eclipse Ant Plugin folder only when Ant is run from within Eclipse. When Ant is run from a command line, ant.home will match your ANT_HOME environment variable. There is also supposed to be an eclipse.running Ant property, but I could not detect this property.

另一个临时选项是从 此链接下载 Ant nightly builds 的最新 JAR 文件Apache Ant 项目页面,然后将这些 JAR 文件放在相应的 Eclipse Ant 插件子文件夹中.不保证这会起作用.

Another interim option is to download the newest JAR files of Ant nightly builds from this link on the Apach Ant project page, then placing those JAR files within the corresponding Eclipse Ant plugin sub-folder. No guarantees this will work.

这篇关于Ant&lt;junitreport&gt;由于 Xalan 的 (XSLT) 安全处理功能而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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