class TomcatAT8 < Formula desc "Implementation of Java Servlet and JavaServer Pages" homepage "https://tomcat.apache.org/" url "https://www.apache.org/dyn/closer.lua?path=tomcat/tomcat-8/v8.5.85/bin/apache-tomcat-8.5.85.tar.gz" mirror "https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.85/bin/apache-tomcat-8.5.85.tar.gz" sha256 "0e86bb75e7166ebe6d48527727744245ec03e1be81797c6f5855af2d86812d97" license "Apache-2.0" livecheck do url :stable end bottle do sha256 cellar: :any_skip_relocation, all: "a21a3d74f34fdc753d4e77a82aa105a231d87aa94adb8e78279203fcafac82eb" end keg_only :versioned_formula # https://tomcat.apache.org/tomcat-85-eol.html deprecate! date: "2024-03-31", because: :unsupported depends_on "openjdk" def install # Remove Windows scripts rm_rf Dir["bin/*.bat"] # Install files prefix.install %w[NOTICE LICENSE RELEASE-NOTES RUNNING.txt] pkgetc.install Dir["conf/*"] (buildpath/"conf").rmdir libexec.install_symlink pkgetc => "conf" libexec.install Dir["*"] (bin/"catalina").write_env_script "#{libexec}/bin/catalina.sh", JAVA_HOME: Formula["openjdk"].opt_prefix end def caveats <<~EOS Configuration files: #{pkgetc} EOS end service do run [opt_bin/"catalina", "run"] keep_alive true end test do ENV["CATALINA_BASE"] = testpath cp_r Dir["#{libexec}/*"], testpath rm Dir["#{libexec}/logs/*"] pid = fork do exec bin/"catalina", "start" end sleep 3 begin system bin/"catalina", "stop" ensure Process.wait pid end assert_predicate testpath/"logs/catalina.out", :exist? end end