homebrew-core/Formula/jdtls.rb

54 lines
1.5 KiB
Ruby

class Jdtls < Formula
include Language::Python::Shebang
desc "Java language specific implementation of the Language Server Protocol"
homepage "https://github.com/eclipse/eclipse.jdt.ls"
url "https://download.eclipse.org/jdtls/milestones/1.18.0/jdt-language-server-1.18.0-202212011657.tar.gz"
version "1.18.0"
sha256 "b9875c12442d5cb80e0f7f66a55d19fc1f7db3b3c2bbc3c793612246858eba04"
license "EPL-2.0"
version_scheme 1
livecheck do
url "https://download.eclipse.org/jdtls/milestones/"
regex(%r{href=.*?/v?(\d+(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 cellar: :any_skip_relocation, all: "47b0c67973047ae87eef2f7f45454c6a1b6a8eb5ac981ab07ddd1b631b754e5d"
end
depends_on "openjdk"
depends_on "python@3.11"
def install
libexec.install %w[bin config_mac config_linux features plugins]
rewrite_shebang detected_python_shebang, libexec/"bin/jdtls"
(bin/"jdtls").write_env_script libexec/"bin/jdtls", Language::Java.overridable_java_home_env
end
test do
require "open3"
json = <<~JSON
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"rootUri": null,
"capabilities": {}
}
}
JSON
Open3.popen3("#{bin}/jdtls", "-configuration", "#{testpath}/config", "-data",
"#{testpath}/data") do |stdin, stdout, _e, w|
stdin.write "Content-Length: #{json.size}\r\n\r\n#{json}"
sleep 3
assert_match(/^Content-Length: \d+/i, stdout.readline)
Process.kill("KILL", w.pid)
end
end
end