homebrew-core/Formula/carrot2.rb

81 lines
2.9 KiB
Ruby

class Carrot2 < Formula
desc "Search results clustering engine"
homepage "https://search.carrot2.org/"
url "https://github.com/carrot2/carrot2.git",
tag: "release/4.4.0",
revision: "ed3048193f9b5ad75a5d886b28716a06d3253082"
license "Apache-2.0"
bottle do
sha256 cellar: :any_skip_relocation, arm64_monterey: "8eb4ee1ba4f46c28106ee881f36be985ae7bb6ecdb4b1a5d21a3053fb4debbb5"
sha256 cellar: :any_skip_relocation, arm64_big_sur: "a753c87b1309d5f5a03ecece09a24e0ed4b12ac3730fc99c0703a71f21fec477"
sha256 cellar: :any_skip_relocation, monterey: "62972606f6f239d40bdc50328e0d6ae132ec61de859b7981c9294ddb68294919"
sha256 cellar: :any_skip_relocation, big_sur: "9e143aad0e6003e00d63395e118ba5e7764a1ee60e68e4de87b4eee3bb743309"
sha256 cellar: :any_skip_relocation, catalina: "02d2504101fa927e231b67337e8a6eaefe423a2c9ef3cfdad83bcccb786b0215"
sha256 cellar: :any_skip_relocation, x86_64_linux: "31c25f3b208e2b63ebf44cfbab55e01901a73646bfc707c7dedbb8020133b749"
end
depends_on "gradle" => :build
depends_on "node@16" => :build
depends_on "yarn" => :build
depends_on "openjdk"
def install
# Make possible to build the formula with the latest available in Homebrew gradle
inreplace "gradle/validation/check-environment.gradle",
/expectedGradleVersion = '[^']+'/,
"expectedGradleVersion = '#{Formula["gradle"].version}'"
# Use yarn and node from Homebrew
inreplace "gradle/node/yarn-projects.gradle", "download = true", "download = false"
inreplace "build.gradle" do |s|
s.gsub! "node: '16.13.0'", "node: '#{Formula["node@16"].version}'"
s.gsub! "yarn: '1.22.15'", "yarn: '#{Formula["yarn"].version}'"
end
system "gradle", "assemble", "--no-daemon"
cd "distribution/build/dist" do
inreplace "dcs/conf/logging/appender-file.xml", "${dcs:home}/logs", var/"log/carrot2"
libexec.install Dir["*"]
end
(bin/"carrot2").write_env_script "#{libexec}/dcs/dcs",
JAVA_CMD: "exec '#{Formula["openjdk"].opt_bin}/java'",
SCRIPT_HOME: libexec/"dcs"
end
plist_options manual: "carrot2"
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>#{plist_name}</string>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
<key>WorkingDirectory</key>
<string>#{opt_libexec}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/carrot2</string>
</array>
</dict>
</plist>
EOS
end
test do
port = free_port
fork { exec bin/"carrot2", "--port", port.to_s }
sleep 20
assert_match "Lingo", shell_output("curl -s localhost:#{port}/service/list")
end
end