Skip to content

Commit 8d8b8e8

Browse files
Meher Srujana Matchadatho7561
authored andcommitted
Support Maven project name template per workspace folder
1 parent 37a9b9a commit 8d8b8e8

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ The following settings are supported:
238238
* `java.compile.nullAnalysis.nullable`: Specify the Nullable annotation types to be used for null analysis. If more than one annotation is specified, then the topmost annotation will be used first if it exists in your project dependencies. This setting will be ignored if `java.compile.nullAnalysis.mode` is set to `disabled`.
239239
* `java.compile.nullAnalysis.nonnullbydefault`: Specify the NonNullByDefault annotation types to be used for null analysis. If more than one annotation is specified, then the topmost annotation will be used first if it exists in your project dependencies. This setting will be ignored if `java.compile.nullAnalysis.mode` is set to `disabled`.
240240
* `java.import.maven.offline.enabled`: Enable/disable the Maven offline mode. Defaults to `false`.
241-
* `java.import.maven.projectNameTemplate`: Specifies the template used to name imported Maven projects, e.g. `[groupId]-[artifactId]-[version]`. This is helpful when importing projects with the same groupId and artifactId but a different version. Supported variables are `[groupId]`, `[artifactId]`, `[version]` and `[name]`. Already imported projects keep their name until the workspace is cleaned.
241+
* `java.import.maven.projectNameTemplate`: Specifies the template used to name imported Maven projects, e.g. `[groupId]-[artifactId]-[version]`. This is helpful when importing projects with the same groupId and artifactId but a different version. Supported variables are `[groupId]`, `[artifactId]`, `[version]` and `[name]`. Already imported projects keep their name until the workspace is cleaned. In a multi-root workspace, it can be set per workspace folder.
242242
* `java.codeAction.sortMembers.avoidVolatileChanges`: Reordering of fields, enum constants, and initializers can result in semantic and runtime changes due to different initialization and persistence order. This setting prevents this from occurring. Defaults to `true`.
243243
* `java.jdt.ls.protobufSupport.enabled`: Specify whether to automatically add Protobuf output source directories to the classpath. **Note:** Only works for Gradle `com.google.protobuf` plugin `0.8.4` or higher. Defaults to `true`.
244244
* `java.jdt.ls.aspectjSupport.enabled`: Specify whether to enable `io.freefair.aspectj` plugin in Gradle projects. Defaults to `false`.

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,8 @@
703703
"java.import.maven.projectNameTemplate": {
704704
"type": "string",
705705
"default": null,
706-
"markdownDescription": "Specifies the template used to name imported Maven projects, e.g. `[groupId]-[artifactId]-[version]`. This is helpful when importing projects with the same groupId and artifactId but a different version. Supported variables are `[groupId]`, `[artifactId]`, `[version]` and `[name]`. Already imported projects keep their name until the workspace is cleaned.",
707-
"scope": "window",
706+
"markdownDescription": "Specifies the template used to name imported Maven projects, e.g. `[groupId]-[artifactId]-[version]`. This is helpful when importing projects with the same groupId and artifactId but a different version. Supported variables are `[groupId]`, `[artifactId]`, `[version]` and `[name]`. Already imported projects keep their name until the workspace is cleaned. In a multi-root workspace, it can be set per workspace folder.",
707+
"scope": "resource",
708708
"order": 25
709709
},
710710
"java.import.maven.disableTestClasspathFlag": {

‎src/utils.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,15 @@ export async function getJavaConfig(javaHome: string, skipAutoDetection?: boolea
234234
javaConfig.format.tabSize = editorConfig.get('tabSize');
235235
const filesConfig = workspace.getConfiguration('files');
236236
javaConfig.associations = filesConfig.get('associations');
237+
javaConfig.import.maven.projectNameTemplateByFolder = {};
238+
if (workspace.workspaceFolders && workspace.workspaceFolders.length) {
239+
workspace.workspaceFolders.forEach((folder) => {
240+
const template = workspace.getConfiguration('java', folder.uri).get<string>('import.maven.projectNameTemplate');
241+
if (template) {
242+
javaConfig.import.maven.projectNameTemplateByFolder[folder.uri.toString()] = template;
243+
}
244+
});
245+
}
237246
const isInsider: boolean = isInsiderEditor();
238247
const androidSupport = javaConfig.jdt.ls.androidSupport.enabled;
239248
switch (androidSupport) {

0 commit comments

Comments
 (0)