蚂蚁的 Findbugs 问题 [英] Findbugs issue with ant

查看:23
本文介绍了蚂蚁的 Findbugs 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发现错误:

[findbugs] Executing findbugs from ant task
[findbugs] Running FindBugs...
[findbugs] java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormtException
[findbugs] Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException
[findbugs]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[findbugs]     at java.security.AccessController.doPrivileged(Native Method)
[findbugs]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[findbugs]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[findbugs]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[findbugs]     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[findbugs] Could not find the main class: edu.umd.cs.findbugs.FindBugs2.  Program will exit.
[findbugs] Exception in thread "main"

我在使用 ant 执行 findbugs 时遇到了这个问题,尽管我将 findbugs 和必要的 jar 文件保存在所需的文件夹中.

I get this issue on executing findbugs with ant though I kept findbugs and essential jar files in the required folder.

我使用 findbugs 1.3.2 和 bcel 5.2.

I use findbugs 1.3.2 and bcel 5.2.

如何解决这个问题?

[findbugs] Output saved to bugs/reports/findbugs.xml

推荐答案

findbugs 文档 声明如下:

注意

强烈建议您使用 Ant 任务及其随附的 FindBugs 版本.我们不保证 Ant 任务 Jar 文件适用于除随附的 FindBugs 版本之外的任何版本.

It is strongly recommended that you use the Ant task with the version of FindBugs it was included with. We do not guarantee that the Ant task Jar file will work with any version of FindBugs other than the one it was included with.

您没有指明您使用的是哪个版本的 ANT 任务......

You do not indicate which version of the ANT task you are using....

我建议使用像 ivy 这样的依赖管理器来处理复杂的类路径,如下所示:

I would recommend using a dependency manager like ivy to take care of complex classpaths as follows:

<project name="demo" default="findbugs" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="init" description="Use ivy to manage ANT tasks">
        <ivy:cachepath pathid="findbugs.path">
            <dependency org="com.google.code.findbugs" name="findbugs-ant" rev="2.0.1" conf="default"/>
        </ivy:cachepath>

        <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.path"/>
    </target>

    <target name="findbugs" depends="init">
        ..
        <findbugs ..
        ..
    </target>

</project>

最后,还值得考虑使用 Sonar.Sonar ANT 任务为您管理所有 findbugs 依赖项,还运行其他工具,如 checkstyle 和 PMD.

Finally, it is also worth considering the use of Sonar. The Sonar ANT task manages all the findbugs dependencies for you and also runs other tools like checkstyle and PMD.

这篇关于蚂蚁的 Findbugs 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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