diff --git a/config/components.yml b/config/components.yml index fd892edf..dd662b0b 100644 --- a/config/components.yml +++ b/config/components.yml @@ -59,5 +59,7 @@ frameworks: - "JavaBuildpack::Framework::JavaOpts" - "JavaBuildpack::Framework::LanguageServerBinExecJDT" - "JavaBuildpack::Framework::LanguageServerNodeESLINT" + - "JavaBuildpack::Framework::LanguageServerNodeJSON" + - "JavaBuildpack::Framework::LanguageServerNodeXML" # - "JavaBuildpack::Framework::LanguageServerNodeCDX" diff --git a/config/language_server_node_json.yml b/config/language_server_node_json.yml new file mode 100644 index 00000000..c75cf893 --- /dev/null +++ b/config/language_server_node_json.yml @@ -0,0 +1,11 @@ +# TODO License. + +# Configuration for the JSON LSP server component +--- +version: 0.0.+ +repository_root: "https://lsp-component-json.cfapps.eu10.hana.ondemand.com/" +env: + workdir: language_server_node_json/server + exec: language_server_node_json/launcher.sh + ipc: + protocol: "stream" diff --git a/config/language_server_node_xml.yml b/config/language_server_node_xml.yml new file mode 100644 index 00000000..00e6584a --- /dev/null +++ b/config/language_server_node_xml.yml @@ -0,0 +1,11 @@ +# TODO License. + +# Configuration for the JAVA LSP server component +--- +version: 0.0.+ +repository_root: "https://lsp-component-xml.cfapps.sap.hana.ondemand.com/" +env: + workdir: language_server_node_xml/server/ + exec: language_server_node_xml/launcher.sh + ipc: + protocol: "stream" diff --git a/lib/java_buildpack/framework/language_server_node_json.rb b/lib/java_buildpack/framework/language_server_node_json.rb new file mode 100644 index 00000000..aaeb0661 --- /dev/null +++ b/lib/java_buildpack/framework/language_server_node_json.rb @@ -0,0 +1,86 @@ +# Encoding: utf-8 +# TODO License. + +require 'java_buildpack/component/versioned_dependency_component' +require 'java_buildpack/framework' +require 'fileutils' +require 'java_buildpack/util/qualify_path' +require 'java_buildpack/logging/logger_factory' + +module JavaBuildpack + module Framework + + # Installs JSON based LSP server component. + class LanguageServerNodeJSON < JavaBuildpack::Component::VersionedDependencyComponent + + # Creates an instance + # + # @param [Hash] context a collection of utilities used the component + def initialize(context) + super(context) + @logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger LanguageServerNodeJSON + end + + + # (see JavaBuildpack::Component::BaseComponent#compile) + def compile + @logger.debug { "Compile JSON" } + # Install node js + FileUtils.mkdir_p @droplet.root + "nodejs" + nodedir = @droplet.sandbox + "nodejs" + comp_version = @version + comp_uri = @uri + @version="8.0.0" + @uri="https://buildpacks.cloudfoundry.org/dependencies/node/node-8.0.0-linux-x64-ade5a8e5.tgz" + download_tar( target_directory=nodedir ) + @version = comp_version + @uri = comp_uri + download_zip strip_top_level = false + @droplet.copy_resources + + end + + # (see JavaBuildpack::Component::BaseComponent#release) + def release + + @logger.debug { "Release JSON" } + environment_variables = @droplet.environment_variables + myWorkdir = @configuration["env"]["workdir"] + environment_variables.add_environment_variable(ENV_PREFIX + "workdir", myWorkdir) + myExec = @configuration["env"]["exec"] + environment_variables.add_environment_variable(ENV_PREFIX + "exec", myExec) + + myIpc = @configuration["env"]["ipc"] + @logger.debug { "JSON Env vars IPC:#{myIpc}" } + myIpc.each do |key, value| + environment_variables.add_environment_variable(ENV_PREFIX + key, value) + end + + environment_variables.add_environment_variable 'PATH', "/home/vcap/app/.java-buildpack/#{@droplet.component_id}/nodejs/bin:$PATH" + end + + protected + + # (see JavaBuildpack::Component::VersionedDependencyComponent#supports?) + def supports? + @application.environment.key?(LSPSERVERS) && @application.environment[LSPSERVERS].split(',').include?("json") + end + + private + + LSPSERVERS = 'lspservers'.freeze + + private_constant :LSPSERVERS + + BINEXEC = 'exec'.freeze + + private_constant :BINEXEC + + ENV_PREFIX = 'LSPJSON_'.freeze + + private_constant :ENV_PREFIX + + end + + end +end diff --git a/lib/java_buildpack/framework/language_server_node_xml.rb b/lib/java_buildpack/framework/language_server_node_xml.rb new file mode 100644 index 00000000..44315cb7 --- /dev/null +++ b/lib/java_buildpack/framework/language_server_node_xml.rb @@ -0,0 +1,86 @@ +# Encoding: utf-8 +# TODO License. + +require 'java_buildpack/component/versioned_dependency_component' +require 'java_buildpack/framework' +require 'fileutils' +require 'java_buildpack/util/qualify_path' +require 'java_buildpack/logging/logger_factory' + +module JavaBuildpack + module Framework + + # Installs XML based LSP server component. + class LanguageServerNodeXML < JavaBuildpack::Component::VersionedDependencyComponent + + # Creates an instance + # + # @param [Hash] context a collection of utilities used the component + def initialize(context) + super(context) + @logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger LanguageServerNodeXML + end + + + # (see JavaBuildpack::Component::BaseComponent#compile) + def compile + @logger.debug { "Compile XML" } + # Install node js + FileUtils.mkdir_p @droplet.root + "nodejs" + nodedir = @droplet.sandbox + "nodejs" + comp_version = @version + comp_uri = @uri + @version="8.0.0" + @uri="https://buildpacks.cloudfoundry.org/dependencies/node/node-8.0.0-linux-x64-ade5a8e5.tgz" + download_tar( target_directory=nodedir ) + @version = comp_version + @uri = comp_uri + download_zip strip_top_level = false + @droplet.copy_resources + + end + + # (see JavaBuildpack::Component::BaseComponent#release) + def release + + @logger.debug { "Release XML" } + environment_variables = @droplet.environment_variables + myWorkdir = @configuration["env"]["workdir"] + environment_variables.add_environment_variable(ENV_PREFIX + "workdir", myWorkdir) + myExec = @configuration["env"]["exec"] + environment_variables.add_environment_variable(ENV_PREFIX + "exec", myExec) + + myIpc = @configuration["env"]["ipc"] + @logger.debug { "XML Env vars IPC:#{myIpc}" } + myIpc.each do |key, value| + environment_variables.add_environment_variable(ENV_PREFIX + key, value) + end + + environment_variables.add_environment_variable 'PATH', "/home/vcap/app/.java-buildpack/#{@droplet.component_id}/nodejs/bin:$PATH" + end + + protected + + # (see JavaBuildpack::Component::VersionedDependencyComponent#supports?) + def supports? + @application.environment.key?(LSPSERVERS) && @application.environment[LSPSERVERS].split(',').include?("xml") + end + + private + + LSPSERVERS = 'lspservers'.freeze + + private_constant :LSPSERVERS + + BINEXEC = 'exec'.freeze + + private_constant :BINEXEC + + ENV_PREFIX = 'LSPXML_'.freeze + + private_constant :ENV_PREFIX + + end + + end +end diff --git a/resources/language_server_node_json/launcher.sh b/resources/language_server_node_json/launcher.sh new file mode 100644 index 00000000..ef15d7f2 --- /dev/null +++ b/resources/language_server_node_json/launcher.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exec ../nodejs/bin/node ./out/jsonServerMain.js --stdio diff --git a/resources/language_server_node_xml/launcher.sh b/resources/language_server_node_xml/launcher.sh new file mode 100644 index 00000000..44bfb727 --- /dev/null +++ b/resources/language_server_node_xml/launcher.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +exec ../nodejs/bin/node ./out/xmlServerMain.js --stdio