From dc2971a514d74b153684def9c0965919ff4fe84a Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 31 Aug 2026 14:45:24 -0400 Subject: [PATCH] Add a setting to specify the Maven project cache size Signed-off-by: David Thompson --- README.md | 1 + package.json | 10 ++++++++++ src/javaServerStarter.ts | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 488ac8885..ad1b12b7e 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,7 @@ The following settings are supported: * `java.home` : **Deprecated, please use 'java.jdt.ls.java.home' instead.** Absolute path to JDK home folder used to launch the Java Language Server. Requires VS Code restart. * `java.jdt.ls.lombokSupport.enabled`: Whether to enable lombok support. Defaults to `true`. * `java.jdt.ls.vmargs` : Extra VM arguments used to launch the Java Language Server. Requires VS Code restart. +* `java.jdt.ls.mavenProjectCacheSize`: Specifies the size of the in-memory Maven project cache to use. Increasing the project cache size will help load multi-module projects and monorepos faster, but will result in a significant increase in memory usage. * `java.errors.incompleteClasspath.severity` : Specifies the severity of the message when the classpath is incomplete for a Java file. Supported values are `ignore`, `info`, `warning`, `error`. * `java.trace.server` : Traces the communication between VS Code and the Java language server. * `java.configuration.updateBuildConfiguration` : Specifies how modifications on build files update the Java classpath/configuration. Supported values are `disabled` (nothing happens), `interactive` (asks about updating on every modification), `automatic` (updating is automatically triggered). diff --git a/package.json b/package.json index de46d1c7c..9869d8808 100644 --- a/package.json +++ b/package.json @@ -341,6 +341,16 @@ "scope": "machine-overridable", "order": 20 }, + "java.jdt.ls.mavenProjectCacheSize": { + "type": [ + "integer" + ], + "minimum": 1, + "default": 50, + "description": "Specifies the size of the in-memory Maven project cache to use. Increasing the project cache size will help load multi-module projects and monorepos faster, but will result in a significant increase in memory usage.", + "scope": "machine-overridable", + "order": 20 + }, "java.server.launchMode": { "type": "string", "enum": [ diff --git a/src/javaServerStarter.ts b/src/javaServerStarter.ts index 00da6400b..b92d4b3dd 100644 --- a/src/javaServerStarter.ts +++ b/src/javaServerStarter.ts @@ -257,6 +257,12 @@ function prepareParams(requirements: RequirementsData, workspacePath, context: E } else { vmargs = ''; } + if (vmargs.indexOf('-Dm2e.project.cache.size') < 0) { + const mavenProjectCacheSize = workspace.getConfiguration().get('java.jdt.ls.mavenProjectCacheSize'); + if (mavenProjectCacheSize !== undefined && Number(mavenProjectCacheSize) > 0) { + params.push(`-Dm2e.project.cache.size=${mavenProjectCacheSize}`); + } + } if (vmargs.indexOf('-DDetectVMInstallationsJob.disabled=') < 0) { params.push('-DDetectVMInstallationsJob.disabled=true'); }