質問

I am trying to run findbugs-sbt plugin (https://bitbucket.org/jmhofer/findbugs4sbt/wiki/Home) for my project. However I got this error when trying to run findbugs in sbt console

[error] Exception in thread "main" java.lang.NoClassDefFoundError: edu/umd/cs/findbugs/LaunchAppropriateUI
[error] Caused by: java.lang.ClassNotFoundException: edu.umd.cs.findbugs.LaunchAppropriateUI
[error]         at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[error]         at java.security.AccessController.doPrivileged(Native Method)
[error]         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[error]         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[error] Could not find the main class: edu.umd.cs.findbugs.LaunchAppropriateUI.  Program will exit.

in project/Build.scala, I just include this as described in their wiki

import de.johoop.findbugs4sbt.FindBugs._

lazy val foo = Project(..., settings = ... ++ findbugsSettings)

in project/plugins.sbt, I added this

addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.2.0") // because I am using sbt 0.12

I tried to add the findbugs dependency in project/plugins.sbt

libraryDependencies ++= Seq(
  "com.google.code.findbugs" % "findbugs" % "2.0.1")

but still no go.

役に立ちましたか?

解決

After looking at the source code of this plugin, I found out I had to specify the findbugs classpath to make the sbt action work. For those who run into the same problem, here is the solution.

findbugsClasspath := IO.listFiles(file(<your findbugs lib location>)).filter(_.getName.endsWith("jar")).toSeq.classpath

This should've been pointed out clearly in the wiki.

BTW - I believe this could also solve the similar issue by the cpd sbt plugin.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top