48 lines
1.4 KiB
Ruby
48 lines
1.4 KiB
Ruby
class Jetty < Formula
|
|
desc "Java servlet engine and webserver"
|
|
homepage "https://www.eclipse.org/jetty/"
|
|
url "https://search.maven.org/remotecontent?filepath=org/eclipse/jetty/jetty-distribution/9.4.31.v20200723/jetty-distribution-9.4.31.v20200723.tar.gz"
|
|
version "9.4.31.v20200723"
|
|
sha256 "ddf4f4454df83c971c726acabbcfc0cbd443726a30b052ae8cb61f4933852dc8"
|
|
|
|
livecheck do
|
|
url "https://www.eclipse.org/jetty/download.html"
|
|
regex(/href=.*?jetty-distribution[._-]v?(\d+(?:\.\d+)+(?:\.v\d+)?)\.t/i)
|
|
end
|
|
|
|
bottle :unneeded
|
|
|
|
depends_on "openjdk"
|
|
|
|
def install
|
|
libexec.install Dir["*"]
|
|
(libexec/"logs").mkpath
|
|
|
|
bin.mkpath
|
|
Dir.glob("#{libexec}/bin/*.sh") do |f|
|
|
scriptname = File.basename(f, ".sh")
|
|
(bin/scriptname).write <<~EOS
|
|
#!/bin/bash
|
|
export JETTY_HOME='#{libexec}'
|
|
export JAVA_HOME="${JAVA_HOME:-#{Formula["openjdk"].opt_prefix}}"
|
|
exec #{f} "$@"
|
|
EOS
|
|
chmod 0755, bin/scriptname
|
|
end
|
|
end
|
|
|
|
test do
|
|
ENV["JETTY_BASE"] = testpath
|
|
cp_r Dir[libexec/"*"], testpath
|
|
pid = fork { exec bin/"jetty", "start" }
|
|
sleep 5 # grace time for server start
|
|
begin
|
|
assert_match /Jetty running pid=\d+/, shell_output("#{bin}/jetty check")
|
|
assert_equal "Stopping Jetty: OK\n", shell_output("#{bin}/jetty stop")
|
|
ensure
|
|
Process.kill 9, pid
|
|
Process.wait pid
|
|
end
|
|
end
|
|
end
|