Skip to content

Commit

Permalink
Add root project folder to each key in projectTreeItemMap
Browse files Browse the repository at this point in the history
In #1612, the keys of this map were changed to the Gradle project path.
This path is unique for each project within one Gradle build, but not
if there are multiple Gradle builds loaded in one workspace by using:
'gradle.nestedProjects': true

This change combined the old and new behavior by creating the Map key
from two parts:
(1) The root project folder which uniquely identifies the build
    (accessible via definition.projectFolder)
(2) The Gradle project path that uniquely identifies a project inside
    the build

Signed-off-by: Jendrik Johannes <jendrik.johannes@gmail.com>
  • Loading branch information
jjohannes committed Oct 14, 2024
1 parent 9ac3ffe commit ab10245
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,14 @@ export class GradleTasksTreeDataProvider implements vscode.TreeDataProvider<vsco
}

const projectPath = definition.script.split(":").slice(0, -1);
let projectTreeItem = projectTreeItemMap.get(projectPath.join(":"));
const projectMapKey = definition.projectFolder + "_" + projectPath.join(":");
let projectTreeItem = projectTreeItemMap.get(projectMapKey);
if (!projectTreeItem) {
const parentProjectPath = projectPath.length == 0 ? null : projectPath.slice(0, -1);
const parentProject =
parentProjectPath === null
? gradleProjectTreeItem
: projectTreeItemMap.get(parentProjectPath.join(":"));
: projectTreeItemMap.get(definition.projectFolder + "_" + parentProjectPath.join(":"));
projectTreeItem = new ProjectTreeItem(
definition.project,
parentProject,
Expand All @@ -271,7 +272,7 @@ export class GradleTasksTreeDataProvider implements vscode.TreeDataProvider<vsco
} else {
gradleProjectTreeItem.addProject(projectTreeItem);
}
projectTreeItemMap.set(projectPath.join(":"), projectTreeItem);
projectTreeItemMap.set(projectMapKey, projectTreeItem);
}

const taskName = definition.script.slice(definition.script.lastIndexOf(":") + 1);
Expand Down

0 comments on commit ab10245

Please sign in to comment.