homebrew-core/Formula/spotbugs.rb

48 lines
1.4 KiB
Ruby

class Spotbugs < Formula
desc "Tool for Java static analysis (FindBugs's successor)"
homepage "https://spotbugs.github.io/"
url "https://repo.maven.apache.org/maven2/com/github/spotbugs/spotbugs/3.1.12/spotbugs-3.1.12.tgz"
sha256 "9c475d6c7096ed7af783e04dc2db40462145291de75a80029391600b6eb2d401"
revision 1
head do
url "https://github.com/spotbugs/spotbugs.git"
depends_on "gradle" => :build
end
bottle :unneeded
depends_on "openjdk@12"
def install
ENV["JAVA_HOME"] = Formula["openjdk@12"].opt_prefix
if build.head?
system "gradle", "build"
system "gradle", "installDist"
libexec.install Dir["spotbugs/build/install/spotbugs/*"]
else
libexec.install Dir["*"]
end
(bin/"spotbugs").write_env_script "#{libexec}/bin/spotbugs", :JAVA_HOME => "${JAVA_HOME:-#{ENV["JAVA_HOME"]}}"
end
test do
(testpath/"HelloWorld.java").write <<~EOS
public class HelloWorld {
private double[] myList;
public static void main(String[] args) {
System.out.println("Hello World");
}
public double[] getList() {
return myList;
}
}
EOS
system "#{Formula["openjdk@12"].bin}/javac", "HelloWorld.java"
system "#{Formula["openjdk@12"].bin}/jar", "cvfe", "HelloWorld.jar", "HelloWorld", "HelloWorld.class"
output = shell_output("#{bin}/spotbugs -textui HelloWorld.jar")
assert_match /M V EI.*\nM C UwF.*\n/, output
end
end