I managed to work around my issues. It turns out that the findbugs POM
on ibiblio.org has at least one incorrect dependency and is missing
several dependencies. And to make things even more interesting, when you
add the dom4j dependency it pulls in a couple of libraries that break
findbugs again. Here is the list of dependencies that got me going finally:
<!-- Download findbugs from Maven repository -->
<dependencies pathId="findbugs.classpath"
useScope="runtime">
<remoteRepository refid="remote.repository"/>
<dependency groupId="findbugs" artifactId="findbugs"
version="1.0.0">
<exclusion groupId="bcel" artifactId="bcel"/>
</dependency>
<dependency groupId="findbugs" artifactId="bcel"
version="5.1"/>
<dependency groupId="dom4j" artifactId="dom4j"
version="1.5.2">
<!-- Don't know which of the exlusions are really necessary.
I just added one at a time until things worked
out. -->
<exclusion groupId="xml-apis" artifactId="xml-apis"/>
<exclusion groupId="jaxme" artifactId="jaxme-api"/>
<exclusion groupId="pull-parser" artifactId="pull-parser"/>
</dependency>
</dependencies>
Fabian
Fabian Ritzmann wrote:
Hi,
I've been trying to implement an Ant target that downloads findbugs
from a public Maven repository and then runs it on my code. The Ant
target itself is fairly straight-forward, but it appears that I'm
caught in dependency hell. I'd appreciate any suggestions.
These are my Ant targets:
<target name="maven-tasks">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml">
<classpath>
<pathelement
location="../etc/lib/maven-artifact-ant-2.0.4-dep.jar" />
</classpath>
</typedef>
<remoteRepository id="remote.repository"
url="http://www.ibiblio.org/maven2/" />
</target>
<target name="findbugs" depends="init, maven-tasks"
description="Run findbugs on all code">
<!-- Download findbugs from Maven repository -->
<dependencies pathId="findbugs.classpath"
useScope="runtime">
<remoteRepository refid="remote.repository"/>
<dependency groupId="findbugs" artifactId="findbugs"
version="1.0.0"/>
</dependencies>
<!-- We need to pass a classpath property into the findbugs
task -->
<!-- Convert the path that was created by the depencies task
into a property -->
<pathconvert property="findbugs.classpath">
<path refid="findbugs.classpath"/>
</pathconvert>
<typedef name="findbugs"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
<classpath refid="findbugs.classpath"/>
</typedef>
<findbugs output="xml" outputFile="${build.dir}/findbugs.xml"
classpath="${findbugs.classpath}"
pluginList="${user.home}/.m2/repository/findbugs/coreplugin/1.0.0/coreplugin-1.0.0.jar">
<class location="${build.classes.dir}"/>
<auxClasspath path="${javac.classpath}"/>
<sourcePath path="${src.dir}"/>
</findbugs>
</target>
When I run that target, I'm getting this:
init:
maven-tasks:
findbugs:
Running FindBugs...
Exception in thread "main" java.lang.NoClassDefFoundError:
org/dom4j/DocumentException
at
edu.umd.cs.findbugs.BugCollectionBugReporter.<init>(BugCollectionBugReporter.java:34)
at
edu.umd.cs.findbugs.XMLBugReporter.<init>(XMLBugReporter.java:42)
at
edu.umd.cs.findbugs.FindBugs$TextUICommandLine.createEngine(FindBugs.java:811)
at edu.umd.cs.findbugs.FindBugs.createEngine(FindBugs.java:1882)
at edu.umd.cs.findbugs.FindBugs.main(FindBugs.java:1822)
I've manually added a few dependencies and that got me a little
further (Maven is supposed to do that for you, I guess the POM isn't
exactly complete):
<dependencies pathId="findbugs.classpath"
useScope="runtime">
<remoteRepository refid="remote.repository"/>
<dependency groupId="findbugs" artifactId="findbugs"
version="1.0.0"/>
<dependency groupId="dom4j" artifactId="dom4j"
version="1.5.2"/>
<dependency groupId="jaxen" artifactId="jaxen"
version="1.1-beta-4"/>
<dependency groupId="jdom" artifactId="jdom"
version="b10"/>
<dependency groupId="bcel" artifactId="bcel"
version="5.1"/>
</dependencies>
But I'm stuck here right now:
init:
maven-tasks:
findbugs:
Running FindBugs...
org.dom4j.DocumentException: null Nested exception: null
at org.dom4j.io.SAXReader.read(SAXReader.java:353)
...
at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:1897)
at edu.umd.cs.findbugs.FindBugs.main(FindBugs.java:1825)
Warning: could not load plugin
/Users/fr159072/.m2/repository/findbugs/coreplugin/1.0.0/coreplugin-1.0.0.jar:
java.security.PrivilegedActionException:
edu.umd.cs.findbugs.PluginException: Couldn't parse "messages.xml"
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.bcel.Repository.getRepository()Lorg/apache/bcel/util/Repository;
at
edu.umd.cs.findbugs.ba.AnalysisContext.clearRepository(AnalysisContext.java:200)
at edu.umd.cs.findbugs.FindBugs.execute(FindBugs.java:1154)
at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:1897)
at edu.umd.cs.findbugs.FindBugs.main(FindBugs.java:1825)
(BTW, the findbugs Ant documentation does not mention the findbugs
pluginList attribute.)
Fabian
|