homebrew-core/Formula/languagetool.rb

54 lines
2.1 KiB
Ruby

class Languagetool < Formula
desc "Style and grammar checker"
homepage "https://www.languagetool.org/"
url "https://github.com/languagetool-org/languagetool.git",
tag: "v5.5",
revision: "5e782cc63ab86c9e6c353157dc22f6ea2477c0d7"
license "LGPL-2.1-or-later"
head "https://github.com/languagetool-org/languagetool.git"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any_skip_relocation, big_sur: "b4ce087e229010a40944175a2a26fc6411f48adba76ea6fbba779270dee065f4"
sha256 cellar: :any_skip_relocation, catalina: "ac41ce087286dd11421a77324bbf80a43b3ada72f2e1469087982f3dc3310a75"
sha256 cellar: :any_skip_relocation, mojave: "88fcbe3f245913ab116db15b38409d7c309f1a5f3f49344ae774d441f87e991f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "3cb6cc220af4bb9f7d363e3c1c2de30b7e4d3316124f383c94cfc33dac5e4319"
end
depends_on "maven" => :build
depends_on "openjdk@11"
def install
java_version = "11"
ENV["JAVA_HOME"] = Language::Java.java_home(java_version)
system "mvn", "clean", "package", "-DskipTests"
# We need to strip one path level from the distribution zipball,
# so extract it into a temporary directory then install it.
mktemp "zip" do
system "unzip", Dir["#{buildpath}/languagetool-standalone/target/*.zip"].first, "-d", "."
libexec.install Dir["*/*"]
end
bin.write_jar_script libexec/"languagetool-commandline.jar", "languagetool", java_version: java_version
bin.write_jar_script libexec/"languagetool.jar", "languagetool-gui", java_version: java_version
(bin/"languagetool-server").write <<~EOS
#!/bin/bash
export JAVA_HOME="#{Language::Java.overridable_java_home_env(java_version)[:JAVA_HOME]}"
exec "${JAVA_HOME}/bin/java" -cp "#{libexec}/languagetool-server.jar" org.languagetool.server.HTTPServer "$@"
EOS
end
test do
(testpath/"test.txt").write <<~EOS
Homebrew, this is an test
EOS
output = shell_output("#{bin}/languagetool -l en-US test.txt 2>&1")
assert_match(/Message: Use \Wa\W instead of \Wan\W/, output)
end
end