vscode-javalsThis is a VS Code extension to launch the JavaLS language server. JavaLS is an experimental Java language server that is is really fast and scales really well. Prerequisites
Expected layout:
Build
Run
With default After changing the server, rebuild it with Maven and run JavaLS: Restart Language Server from the command palette. Package (VSIX)
Override the source project with:
Settings
Import processjava-ls does not read
Importer scripts (
|
| Value | Behavior |
|---|---|
Ends with .jar |
Run with the LS JVM: java -jar <path> <workspace> --output <.javals/mbt.json.<id>>. Absolute paths are used as-is; relative paths resolve against the java-ls install directory (folder containing java-ls.jar, e.g. the extension's server/). |
| Anything else | Treated as a shell command line (cmd.exe /C on Windows, /bin/sh -c elsewhere). The importer process working directory is the java-ls install directory, so relative script paths resolve there too. The server appends <workspace> --output <fragment> (and optionally --generated-source-rules for Maven). |
Examples:
{
"javals.importers": {
"maven": "mavenimporter.jar",
"gradle": "/opt/tools/gradle-mbt-import.sh"
}
}
The Maven importer scans the workspace for pom.xml files, resolves each reactor with an
embedded Maven instance, and maps projects to Metals-shaped namespaces (main and test as separate
targets, external jars as dependencyModules, workspace modules as dependsOn). It skips a full
re-import when the fragment is newer than every scanned pom unless forced.
Generated source rules
Maven does not run generate-sources during import. Instead the importer applies a registry of
rules that map known plugins to configuration paths and default directories, then adds those roots
to each namespace’s sources list (even if the directory does not exist yet).
Built-in rules cover modello, maven-compiler-plugin annotation-processor output, and
build-helper-maven-plugin add-source / add-test-source. Extend or disable them with
javals.maven.generatedSourceRules (restart required). The extension passes the array to the
server; non-empty values are written to .javals/generated-source-rules.json for the importer.
Each entry is a JSON object:
| Field | Type | Required | Meaning |
|---|---|---|---|
pluginKey |
string | yes | Maven plugin coordinates (groupId:artifactId) |
scope |
"main" | "test" |
for additions | Which namespace receives the root |
configPath |
string | for additions | Slash-separated path under the plugin’s <configuration> (e.g. outputDirectory, sources/source) |
goals |
string[] | no | When set, only executions whose goals intersect apply; empty/omitted → plugin-level config (plus executions that set the path) |
list |
boolean | no | If true, each matching child element is a path (default false) |
defaultPath |
string | no | Used when config is absent; supports ${project.build.directory} / ${project.basedir} |
required |
boolean | no | If true, skip when neither config nor default yields a path (default false) |
enabled |
boolean | no | "enabled": false disables matching built-ins instead of adding a rule (default true) |
Disable matching: pluginKey is required; optional scope, goals, and/or configPath narrow
which built-in(s) are removed. Additions need pluginKey, scope, and configPath.
Example:
"javals.maven.generatedSourceRules": [
{
"pluginKey": "org.antlr:antlr4-maven-plugin",
"scope": "main",
"configPath": "outputDirectory",
"defaultPath": "${project.build.directory}/generated-sources/antlr4"
},
{
"pluginKey": "org.codehaus.modello:modello-maven-plugin",
"enabled": false
}
]
Commands
- JavaLS: Restart Language Server (
javals.restartServer) - JavaLS: Show Output Channel (
javals.showOutputChannel)