From 8ee1ef0bbe3810e96c161d0c0e6c7e72c9c54490 Mon Sep 17 00:00:00 2001 From: Jinbo Wang Date: Wed, 31 Jan 2024 13:04:13 +0800 Subject: [PATCH] Reload pom contents as needed before finding parent POMs (#1022) --- src/archetype/createProject/SelectParentPomStep.ts | 11 ++++++++++- src/project/MavenProjectManager.ts | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/archetype/createProject/SelectParentPomStep.ts b/src/archetype/createProject/SelectParentPomStep.ts index 65325cd5..81481a84 100644 --- a/src/archetype/createProject/SelectParentPomStep.ts +++ b/src/archetype/createProject/SelectParentPomStep.ts @@ -19,7 +19,16 @@ export class SelectParentPom implements IProjectCreationStep { } ]; MavenProjectManager.projects - .filter(project => project.artifactId && project.pomPath && pathExistsSync(project.pomPath)) + .filter(project => project.pomPath && pathExistsSync(project.pomPath)) + .map(project => { + if (!project.artifactId) { + // reload pom contents + project.parsePom(); + } + + return project; + }) + .filter(project => project.artifactId && project.groupId) .sort((a, b) => a.pomPath.length - b.pomPath.length) .forEach(project => { items.push({ diff --git a/src/project/MavenProjectManager.ts b/src/project/MavenProjectManager.ts index 411d0f26..c8447f1b 100644 --- a/src/project/MavenProjectManager.ts +++ b/src/project/MavenProjectManager.ts @@ -59,7 +59,9 @@ export class MavenProjectManager { } public static add(pomPath: string): void { - MavenProjectManager.getInstance()._projectMap.set(pomPath, new MavenProject(pomPath)); + const newProject = new MavenProject(pomPath); + newProject.parsePom(); + MavenProjectManager.getInstance()._projectMap.set(pomPath, newProject); } public static remove(pomPath: string): void {