Skip to content

ch007m/my-lsp4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructions to play with Eclipse JDT-LS & Protocol

This project demonstrates how to launch the Eclipse Java Language Server (aka: Eclipse jdt-ls) and access it using a Java Language client able to pass commands and get JSOn responses converted to objects

The project uses a java maven example project where some class contains the annotation @MySearchableAnnotation that we would like to search about.

Setup

First, compile the project and generate the classpath file:

mvn clean compile

Download jdt-ls

Download and unzip the Eclipse JDT Language Server:

wget https://www.eclipse.org/downloads/download.php?file=/jdtls/milestones/1.50.0/jdt-language-server-1.50.0-202509041425.tar.gz > jdt-language-server-1.50.0.tar.gz
mkdir jdt-ls
tar -vxf jdt-language-server-1.50.0.tar.gz -C jdt-ls

Konveyor jdt-ls

Alternatively, you can also download and/or use your own server:

set VERSION latest

set ID $(podman create --name kantra-download quay.io/konveyor/kantra:$VERSION)
podman cp $ID:/jdtls ./konveyor-jdtls

Copy the konveyor-jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jarjava-analyzer-bundle.core-1.0.0-SNAPSHOT.jar to the ./lib/ of this project to allow maven to load it as it is not published on a maven repository server !

Here is the trick to do to add a bundle to the OSGI jdt-ls server. This step is optional as we will pass the bundle path as initialization parameter to the language server !

Edit the config.ini file corresponding to your architecture: mac, linux, mac_arm under the folder konveyor-jdtls/config_

Modify within the config.ini file the osgi.bundles property and include after the org.apache.commons.lang3... jar the BundleSymbolicName of: java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar

osgi.bundles=...org.apache.commons.lang3_3.14.0.jar@4,reference\:file\:java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar@2,...

Copy the java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar file from the path konveyor-jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/ to the plugins folder

Start the Jdt-ls and client

Before to run the server and client, configure the following properties:

  • JDT_WKS: Path if the folder containing the jdt-ls workspace, .metadata and log
  • JDT_LS_PATH: Path of the jdt-ls folder
  • LS_CMD: Language server command to be executed. Example: java.project.getAll, etc
# LS_CMD "java.project.getAll"
# LS_CMD "io.konveyor.tackle.samplecommand"
# LS_CMD "io.konveyor.tackle.ruleEntry" 

# JDT_LS_PATH "$HOME/code/application-modernisation/lsp/jdtls"
# JDT_LS_PATH "$HOME/code/application-modernisation/lsp/konveyor-jdtls"

mvn exec:java \
  -DJDT_WKS=$HOME/code/application-modernisation/lsp \
  -DJDT_LS_PATH=$HOME/code/application-modernisation/lsp/jdtls \
  -DLS_CMD=java.project.getAll

You can check the log of the server from the parent folder within: .jdt_workspace/.metadata/.log !

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages