homebrew-core/Formula/carrot2.rb

65 lines
2.0 KiB
Ruby

class Carrot2 < Formula
desc "Search results clustering engine"
homepage "https://project.carrot2.org"
url "https://github.com/carrot2/carrot2.git",
tag: "release/4.2.1",
revision: "936bcf7fa48e03fafffdf4e6f15b36074d161e6e"
license "Apache-2.0"
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, big_sur: "8de11252a7b018007a2ba09d912acb2ec5c43d8f07bb9230789084d2a950cdde"
sha256 cellar: :any_skip_relocation, catalina: "a7bf7b0100998fd2e78069e7c3be0e8099d8d45192f0277094ba555fe260ed0f"
sha256 cellar: :any_skip_relocation, mojave: "ff58dbebfb493939e5d07f9984fb4a32e34e00cf8b188829703ba6fc04c47658"
end
depends_on "openjdk"
def install
# Remove `./gradlew` and use Homebrew gradle when carrot2 supports Gradle 7+
system "./gradlew", "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 5
assert_match "Lingo", shell_output("curl -s localhost:#{port}/service/list")
end
end