class Pmd < Formula desc "Source code analyzer for Java, JavaScript, and more" homepage "http://pmd.sourceforge.net/" url "https://downloads.sourceforge.net/project/pmd/pmd/5.3.2/pmd-src-5.3.2.zip" sha256 "721d0fbfe970d6507233517c92c4541ffa7490d8f7bf1b1ed8dafc28e5abc5b9" depends_on "maven" => :build def install 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 "tar", "-xf", 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