homebrew-core/Formula/tomcat.rb

58 lines
1.5 KiB
Ruby

class Tomcat < 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-10/v10.1.1/bin/apache-tomcat-10.1.1.tar.gz"
mirror "https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.1/bin/apache-tomcat-10.1.1.tar.gz"
sha256 "db82e7308a1f16ecdd23a3a2949b0f052c46beb0e6f869386affb3d4e840fc7d"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, all: "1a0dedbc3ebff66c225e8850a524e3c5598b5e7c9281ff4c3ed67800707f6bbe"
end
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