homebrew-core/Formula/nexus.rb

68 lines
2.4 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.35.0-02.tar.gz"
sha256 "c13d155e8d70929721f1e327d726453b4c51f582002c6ba2b9891e696d4cb81d"
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
sha256 cellar: :any_skip_relocation, big_sur: "87e0f73dea0a956d934095aa87468c3406425859ec88a8f9a9d56a4def0902e0"
sha256 cellar: :any_skip_relocation, catalina: "41cd6b79f25018620e7836dc181642d8216d62f467d305a5f25005152fe038fa"
sha256 cellar: :any_skip_relocation, mojave: "63ab4de37f889a8dd28b6e4c913b81fbbd9eda2e7506227228225785c00565f7"
sha256 cellar: :any_skip_relocation, x86_64_linux: "fe1179b198946b0b3e8bbfd67ab51bb150429ae0697d2a8f3c05b450c75cfa73"
end
depends_on "maven" => :build
depends_on arch: :x86_64 # openjdk@8 is not supported on ARM
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
service do
run [opt_bin/"nexus", "start"]
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