homebrew-core/Formula/javacc.rb

52 lines
1.6 KiB
Ruby

class Javacc < Formula
desc "Parser generator for use with Java applications"
homepage "https://javacc.org/"
url "https://github.com/javacc/javacc/archive/javacc-7.0.10.tar.gz"
sha256 "656cb9aaed498bcfa5faae40aa8d006760d5431c276fda5bb46cff4225d7c3cc"
license "BSD-3-Clause"
livecheck do
url "https://github.com/javacc/javacc/releases/latest"
regex(%r{href=.*?/tag/javacc[._-]v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
cellar :any_skip_relocation
sha256 "81fa6c9cfa14578b76e7baa27ef7ac27ad0038558f4d372ecac6486f2eadc35a" => :big_sur
sha256 "54792663583f44565206d4728237a9452859c162cea1e9c7ff782bf33daf6d99" => :catalina
sha256 "f954f391fb286509601a18d87042c3f6d218a7b57414e719cd37786723d71106" => :mojave
end
depends_on "ant" => :build
depends_on "openjdk"
def install
system "ant"
libexec.install "target/javacc.jar"
doc.install Dir["www/doc/*"]
(share/"examples").install Dir["examples/*"]
%w[javacc jjdoc jjtree].each do |script|
(bin/script).write <<~SH
#!/bin/bash
export JAVA_HOME="${JAVA_HOME:-#{Formula["openjdk"].opt_prefix}}"
exec "${JAVA_HOME}/bin/java" -classpath '#{libexec}/javacc.jar' #{script} "$@"
SH
end
end
test do
src_file = share/"examples/SimpleExamples/Simple1.jj"
output_file_stem = testpath/"Simple1"
system bin/"javacc", src_file
assert_predicate output_file_stem.sub_ext(".java"), :exist?
system bin/"jjtree", src_file
assert_predicate output_file_stem.sub_ext(".jj.jj"), :exist?
system bin/"jjdoc", src_file
assert_predicate output_file_stem.sub_ext(".html"), :exist?
end
end