54 lines
1.7 KiB
Ruby
54 lines
1.7 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.45.v20220203/jetty-distribution-9.4.45.v20220203.tar.gz"
|
|
version "9.4.45.v20220203"
|
|
sha256 "c26334dea02736c8840ec2e45b224a6486f748f091182c53b202815b0a29300c"
|
|
license any_of: ["Apache-2.0", "EPL-1.0"]
|
|
|
|
livecheck do
|
|
url "https://www.eclipse.org/jetty/download.php"
|
|
regex(/href=.*?jetty-distribution[._-]v?(\d+(?:\.\d+)+(?:\.v\d+)?)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, all: "822a768ebe1e8467a2fcfc3add2ab8747a0216435c9531107a820e2ac1db8b5f"
|
|
end
|
|
|
|
# Ships a pre-built x86_64-only `libsetuid-osx.so`.
|
|
depends_on arch: :x86_64
|
|
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_ARGS"] = "jetty.http.port=#{free_port} jetty.ssl.port=#{free_port}"
|
|
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
|