我将 findbugs 安装到我的 ant lib 目录中,并将以下代码添加到我的主 ANT 脚本中:
<target name="findbugs" depends="init">
<findbugs home="C:\\findbugs\\" output="html outputFile="C:\\findbugs\\out.html" jvmargs="-Xms512M">
<sourcePath path="${messageaggregator.src}" />
<class location="${messageaggregator.src}"/>
</findbugs>
</target>
在 init 目标中调用以下 xml:
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
运行 ANT 脚本时,我得到的只是以下输出:
findbugs: [findbugs] Executing findbugs from ant task [findbugs] Running FindBugs... [findbugs] BCEL class compatability error. [findbugs] The version of class org.apache.bcel.generic.ObjectType found was not compatible with [findbugs] FindBugs. Please remove any BCEL libraries that may be interfering. This may happen [findbugs] if you have an old version of BCEL or a library that includes an old version of BCEL [findbugs] in an "endorsed" directory. [findbugs] Output saved to C:\\findbugs\\out.html
为什么 findbugs 不起作用?
最佳答案
您与旧版本的 BCEL 存在冲突,必须消除该冲突。它可能位于您的 jre/lib/ext 目录中(坏主意),或者您项目的 CLASSPATH 的一部分,或者可能是 Ant/lib 的一部分。无论如何,您应该在 CLASSPATH 中找到所有 BCEL JAR,将其删除,然后使用 FindBugs 所需的版本更新它们。
关于java - FindBugs 不接受 ANT 脚本中的 bcel.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/627269/