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.4",
revision: "43924315823e3cf7324f03ad2a95f541ccf12cbf"
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: "78da6202913ceb86d7c5e4b6f7635389b9023828c7ad403aaf239ebc86057c8c"
sha256 cellar: :any_skip_relocation, catalina: "6086605181e62db297f9a4e02980b3e53ff628b88818ae11ab5ba4f715c13cbf"
sha256 cellar: :any_skip_relocation, mojave: "e6c0973d1338c4d57304c38559f08d9a3192193ceb1071f807640869f475e83b"
sha256 cellar: :any_skip_relocation, x86_64_linux: "c1581282fbc0f0f4edf15b0ab2c15005cf9b43de2cfa275105a73e1ec9aa333d"
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