Skip to content

Commit b7aae9b

Browse files
authored
Add Java runtime configuration guidance (#250)
- Document Gradle behavior with JDKs lower than 17 - Add instructions for configuring Maven settings.xml to resolve dependencies from custom or internal repositories - Expand example settings with kotlinSupport and other language support options (Scala, AspectJ, Android, javac)
1 parent 0753bb0 commit b7aae9b

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,30 @@ JDTLS will automatically pick the appropriate runtime based on your project's so
222222
>
223223
> **Windows paths** typically look like `C:\Program Files\Java\jdk-17`
224224
225+
> **Important:** If your default runtime is below Java 17 and you're working with Gradle projects, the Gradle daemon will fail to start because modern Gradle requires JVM 17+. In this case, set `java.import.gradle.java.home` to a JDK 17+ path so that the Gradle daemon uses a compatible JVM independently of your project's compilation runtime. See the [Advanced Configuration](#advanced-configurationjdtls-initialization-options) section below for details.
226+
227+
## Maven Configuration
228+
229+
If your project uses custom or internal Maven repositories, you should point JDTLS at your Maven `settings.xml` so it can resolve dependencies:
230+
231+
```jsonc
232+
"initialization_options": {
233+
"settings": {
234+
"java": {
235+
"configuration": {
236+
"maven": {
237+
"userSettings": "~/.m2/settings.xml",
238+
// Optional: global settings for system-wide configuration
239+
"globalSettings": "/path/to/global/settings.xml"
240+
}
241+
}
242+
}
243+
}
244+
}
245+
```
246+
247+
Without this, JDTLS's embedded Maven will only resolve artifacts from Maven Central, which will cause unresolved dependency errors for projects using internal or private repositories.
248+
225249
## Advanced Configuration/JDTLS initialization Options
226250

227251
JDTLS provides many configuration options that can be passed via the `initialize` LSP-request. The extension will pass the JSON-object from `lsp.jdtls.initialization_options` in your settings on to JDTLS. Please refer to the [JDTLS Configuration Wiki Page](https://github.com/eclipse-jdtls/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request) for the available options and values.
@@ -245,7 +269,11 @@ Below is an opinionated example configuration for JDTLS with most options enable
245269
"java": {
246270
"configuration": {
247271
"updateBuildConfiguration": "automatic",
248-
"runtimes": []
272+
"runtimes": [],
273+
// Path to your Maven settings.xml (for custom/internal repositories)
274+
"maven": {
275+
"userSettings": "~/.m2/settings.xml"
276+
}
249277
},
250278
"saveActions": {
251279
"organizeImports": true
@@ -261,11 +289,34 @@ Below is an opinionated example configuration for JDTLS with most options enable
261289
},
262290
"jdt": {
263291
"ls": {
292+
// Enables Protocol Buffer support for .proto files in the project
264293
"protobufSupport": {
265294
"enabled": true
266295
},
296+
// Enables Groovy support for mixed Java/Groovy projects
267297
"groovySupport": {
268298
"enabled": true
299+
},
300+
// Enables Kotlin support so JDTLS can resolve Kotlin classes from Java code
301+
// in mixed Kotlin/Java projects
302+
"kotlinSupport": {
303+
"enabled": true
304+
},
305+
// Enables Scala support for mixed Java/Scala projects
306+
"scalaSupport": {
307+
"enabled": true
308+
},
309+
// Enables AspectJ support for projects using aspect-oriented programming
310+
"aspectjSupport": {
311+
"enabled": true
312+
},
313+
// Enables Android project support
314+
"androidSupport": {
315+
"enabled": true
316+
},
317+
// Enables the javac-based compilation engine instead of the ECJ compiler
318+
"javac": {
319+
"enabled": true
269320
}
270321
}
271322
},
@@ -309,6 +360,14 @@ Below is an opinionated example configuration for JDTLS with most options enable
309360
"enabled": true,
310361
"wrapper": {
311362
"enabled": true
363+
},
364+
// JVM used by the Gradle daemon (must be JVM 17+ for modern Gradle).
365+
// Set this if your default runtime is a lower version.
366+
"java": {
367+
"home": "/path/to/your/JDK17+"
368+
},
369+
"annotationProcessing": {
370+
"enabled": true
312371
}
313372
},
314373
"maven": {

0 commit comments

Comments
 (0)