homebrew-core/Formula/nexus.rb

85 lines
2.8 KiB
Ruby

class Nexus < Formula
desc "Repository manager for binary software components"
homepage "https://www.sonatype.org/"
url "https://github.com/sonatype/nexus-public/archive/release-3.29.2-02.tar.gz"
sha256 "de26ef922ebd24d234d25e8c36e0726f9a9a7fd9e73b22534bcda8b980eddcb4"
license "EPL-1.0"
# As of writing, upstream is publishing both v2 and v3 releases. The "latest"
# release on GitHub isn't reliable, as it can point to a release from either
# one of these major versions depending on which was published most recently.
livecheck do
url :stable
regex(/^(?:release[._-])?v?(\d+(?:[.-]\d+)+)$/i)
end
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, big_sur: "cb94d397eb3c3bc5b2650563a6444baa6dce9e725be454e338070c55da356b62"
sha256 cellar: :any_skip_relocation, catalina: "c03727b3a210cf5ca7221d84744082d935fa7ea64ba7248847bf829e00e04d18"
sha256 cellar: :any_skip_relocation, mojave: "c2d13f6a1e1725df48dcd06251bf9fe34f025e77514f36244e45763301d2f3e0"
end
depends_on "maven" => :build
depends_on "openjdk@8"
uses_from_macos "unzip" => :build
def install
ENV["JAVA_HOME"] = Formula["openjdk@8"].opt_prefix
system "mvn", "install", "-DskipTests"
system "unzip", "-o", "-d", "target", "assemblies/nexus-base-template/target/nexus-base-template-#{version}.zip"
rm_f Dir["target/nexus-base-template-#{version}/bin/*.bat"]
rm_f "target/nexus-base-template-#{version}/bin/contrib"
libexec.install Dir["target/nexus-base-template-#{version}/*"]
env = {
JAVA_HOME: Formula["openjdk@8"].opt_prefix,
KARAF_DATA: "${NEXUS_KARAF_DATA:-#{var}/nexus}",
KARAF_LOG: "#{var}/log/nexus",
KARAF_ETC: "#{etc}/nexus",
}
(bin/"nexus").write_env_script libexec/"bin/nexus", env
end
def post_install
mkdir_p "#{var}/log/nexus" unless (var/"log/nexus").exist?
mkdir_p "#{var}/nexus" unless (var/"nexus").exist?
mkdir "#{etc}/nexus" unless (etc/"nexus").exist?
end
plist_options manual: "nexus start"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sonatype.nexus</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/nexus</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
mkdir "data"
fork do
ENV["NEXUS_KARAF_DATA"] = testpath/"data"
exec "#{bin}/nexus", "server"
end
sleep 100
assert_match "<title>Nexus Repository Manager</title>", shell_output("curl --silent --fail http://localhost:8081")
end
end