80 lines
2.6 KiB
Ruby
80 lines
2.6 KiB
Ruby
class Pmd < Formula
|
|
desc "Source code analyzer for Java, JavaScript, and more"
|
|
homepage "https://pmd.github.io"
|
|
url "https://github.com/pmd/pmd/releases/download/pmd_releases/5.6.1/pmd-src-5.6.1.zip"
|
|
sha256 "7c1e17ad78abb0d97c621965c44b7ef6a8e1330165bf16700df11b1cd64e0349"
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "9ea81dd4bf673c041de893a5d3ac15ab88d610639ca229152403805028e35cf4" => :sierra
|
|
sha256 "8d90b22c380e298fadb2e1b0a39330be3f3894050a9f60c69b6bf83a0e9f0445" => :el_capitan
|
|
sha256 "c6fbb50ff531f46d7f1d0679662501088329fea217f75e56f52ec22936991114" => :yosemite
|
|
end
|
|
|
|
depends_on :java => "1.8+"
|
|
depends_on "maven" => :build
|
|
|
|
def install
|
|
java_user_home = buildpath/"java_user_home"
|
|
ENV["_JAVA_OPTIONS"] = "-Duser.home=#{buildpath}/java_user_home"
|
|
java_cache_repo = HOMEBREW_CACHE/"java_cache/.m2/repository"
|
|
java_cache_repo.mkpath
|
|
(java_user_home/".m2").install_symlink java_cache_repo
|
|
|
|
(java_user_home/".m2/toolchains.xml").write <<-EOS.undent
|
|
<?xml version="1.0" encoding="UTF8"?>
|
|
<toolchains>
|
|
<toolchain>
|
|
<type>jdk</type>
|
|
<provides>
|
|
<version>#{ENV["JAVA_HOME"][/((\d\.?)+)\.\d/, 1]}</version>
|
|
</provides>
|
|
<configuration>
|
|
<jdkHome>#{ENV["JAVA_HOME"]}</jdkHome>
|
|
</configuration>
|
|
</toolchain>
|
|
<toolchain>
|
|
<type>jdk</type>
|
|
<provides>
|
|
<version>1.7</version>
|
|
</provides>
|
|
<configuration>
|
|
<jdkHome>#{ENV["JAVA_HOME"]}</jdkHome>
|
|
</configuration>
|
|
</toolchain>
|
|
</toolchains>
|
|
EOS
|
|
|
|
system "mvn", "clean", "package"
|
|
|
|
doc.install "LICENSE", "NOTICE", "README.md"
|
|
|
|
# The mvn package target produces a .zip with all the jars needed for PMD
|
|
safe_system "unzip", buildpath/"pmd-dist/target/pmd-bin-#{version}.zip"
|
|
libexec.install "pmd-bin-#{version}/bin", "pmd-bin-#{version}/lib"
|
|
|
|
bin.install_symlink "#{libexec}/bin/run.sh" => "pmd"
|
|
inreplace "#{libexec}/bin/run.sh", "${script_dir}/../lib", "#{libexec}/lib"
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
Run with `pmd` (instead of `run.sh` as described in the documentation).
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"java/testClass.java").write <<-EOS.undent
|
|
public class BrewTestClass {
|
|
// dummy constant
|
|
public String SOME_CONST = "foo";
|
|
|
|
public boolean doTest () {
|
|
return true;
|
|
}
|
|
}
|
|
EOS
|
|
|
|
system "#{bin}/pmd", "pmd", "-d", "#{testpath}/java", "-R",
|
|
"rulesets/java/basic.xml", "-f", "textcolor", "-l", "java"
|
|
end
|
|
end
|