homebrew-core/Formula/jdtls.rb

55 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.16.0/jdt-language-server-1.16.0-202209291445.tar.gz"
version "1.16.0"
sha256 "bf16a0c3a7034260f646206c51fba14b3c10ef68cece23b7a3c681248f5c1f3a"
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: "91d977b09985360ed2844336dc566236f3ca51c2e0f8e0ceab63f787ed9dcfc8"
end
depends_on "openjdk"
depends_on "python@3.10"
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