Skip to content

Commit 9a0b66c

Browse files
mickaelistriargrunber
authored andcommitted
JDT_LS_PATH env var to reference local JDT-LS build
1 parent 3a03f03 commit 9a0b66c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ While developing the language server and the extension, you don't need to deploy
176176
- You can modify `launch.json` to use a different port:
177177
- Modify `JDTLS_CLIENT_PORT` to specify the port VS Code should connect to.
178178

179+
## C-3) Set location to a local copy of JDT-LS
180+
181+
This approach is mainly targeting developers of JDT-LS who want to test their changes in VSCode without having to rebuild vscode-java and to deal with the npm and vsix toolchains.
182+
183+
- Make sure a recent snapshot of vscode-java is installed in your VSCode instance (as of vscode-java 1.20.0)
184+
- (Optionally) clear the workspace state: `$ rm -r $HOME/.config/Code/User/workspaceStorage/0123456789abcdef01234567890abcdef/redhat.java/jdt_ws`
185+
- Start VSCode with the `JDT_LS_PATH` environment variable set to the local copy of JDT-LS you want to try: `$ JDT_LS_PATH=$HOME/git/eclipse.jdt.ls/org.eclipse.jdt.ls.product/target/repository code`
186+
187+
Most other options such as `DEBUG_VSCODE_JAVA` are still usable with this approach.
188+
179189
## Sideloading
180190

181191
You can create a binary that you can sideload to your VS Code installation.

src/javaServerStarter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function prepareParams(requirements: RequirementsData, javaConfiguration, worksp
155155
params.push('-noverify');
156156
}
157157

158-
const serverHome: string = path.resolve(__dirname, '../server');
158+
const serverHome: string = process.env.JDT_LS_PATH || path.resolve(__dirname, '../server');
159159
const launchersFound: Array<string> = glob.sync('**/plugins/org.eclipse.equinox.launcher_*.jar', { cwd: serverHome });
160160
if (launchersFound.length) {
161161
params.push('-jar'); params.push(path.resolve(serverHome, launchersFound[0]));
@@ -171,12 +171,12 @@ function prepareParams(requirements: RequirementsData, javaConfiguration, worksp
171171
configDir = isSyntaxServer ? 'config_ss_linux' : 'config_linux';
172172
}
173173
params.push('-configuration');
174+
params.push(startedFromSources() || process.env.JDT_LS_PATH !== undefined ?
175+
path.resolve(serverHome, configDir) : resolveConfiguration(context, configDir));
174176
if (startedFromSources()) { // Dev Mode: keep the config.ini in the installation location
175177
console.log(`Starting jdt.ls ${isSyntaxServer?'(syntax)' : '(standard)'} from vscode-java sources`);
176-
params.push(path.resolve(__dirname, '../server', configDir));
177-
} else {
178-
params.push(resolveConfiguration(context, configDir));
179178
}
179+
180180
params.push('-data'); params.push(workspacePath);
181181
return params;
182182
}

0 commit comments

Comments
 (0)