class Tomcat < Formula desc "Implementation of Java Servlet and JavaServer Pages" homepage "https://tomcat.apache.org/" stable do url "https://www.apache.org/dyn/closer.cgi?path=tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz" mirror "https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz" sha256 "b2cd21075a4c2a3bc04d2595a1a81ad79d6a36774c28608e04cb73ef76da3458" depends_on :java => "1.7+" resource "fulldocs" do url "https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24-fulldocs.tar.gz" mirror "https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24-fulldocs.tar.gz" sha256 "5c0d971c5fb4c9efd62aa00bac06ef22e77d42cc406d22527c8d95ebe3c1fd06" end end devel do url "https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz" mirror "https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2.tar.gz" sha256 "689844c8f373bd7db6a0c5ce7414b825d500bf64300273656dba8b05e29f5e29" depends_on :java => "1.8+" resource "fulldocs" do url "https://www.apache.org/dyn/closer.cgi?path=/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2-fulldocs.tar.gz" mirror "https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.2/bin/apache-tomcat-9.0.2-fulldocs.tar.gz" sha256 "50062ec50751b5684513fb2d926731d4da77d98c947174780bb531949b1be48a" end end bottle :unneeded option "with-fulldocs", "Install full documentation locally" def install # Remove Windows scripts rm_rf Dir["bin/*.bat"] # Install files prefix.install %w[NOTICE LICENSE RELEASE-NOTES RUNNING.txt] libexec.install Dir["*"] bin.install_symlink "#{libexec}/bin/catalina.sh" => "catalina" (pkgshare/"fulldocs").install resource("fulldocs") if build.with? "fulldocs" end plist_options :manual => "catalina run" def plist; <<~EOS Disabled Label #{plist_name} ProgramArguments #{opt_bin}/catalina run KeepAlive EOS 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