在使用ant 编译,生成报告时,发现一直报这样一个错,
[junitreport] Loading stylesheet jar:file:/E:/eclipse/plugins/org.apache.ant_1.8.4.v201303080030/lib/ant-junit.jar!/org/apache/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl [junitreport] : Error! 非 static Java 函数 'replace' 的第一个参数不是有效的对象引用。 [junitreport] : Error! 无法将数据类型 'void' 转换为 'reference'。 [junitreport] : Fatal Error! 无法编译样式表 [junitreport] Failed to process D:\workspace_ep\publisher\dist\testreport\TESTS-TestSuites.xml BUILD FAILED D:\workspace_ep\publisher\build.xml:128: The following error occurred while executing this line: D:\workspace_ep\publisher\build.xml:136: Errors while applying transformations: Fatal error during transformation
使用的是
Eclipse Kepler +jdk1.7
发现在使用ant的时候,eclipse 自带的是ant1.8.4版本,但是这个版本和jdk 1.7有冲突,
还好,替换上新版的ant之后,问题就解决了。
官网下载ant1.9.4, 调整eclipse 内的 jar时,我们可以单独只取lib下的jar文件,
调整eclipse下的ant编译jar。window-Preferences-Ant-Runtime-Ant Home Entries(Default),
删除其中的1.8.4.jar (我这里是全部都Remove了),然后add Extranaljar(不必要将ant导入到项目中),apply保存后,在运行ant,
ok,已经不报错了。