Skip to content

Commit ca8faa2

Browse files
committed
Bring back the module directory as the key to loadedPoms
Per comment from Alexey.
1 parent 9572200 commit ca8faa2

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private static Path locateCurrentProjectPom(Path path) throws BootstrapMavenExce
7777
}
7878

7979
private final Deque<WorkspaceModulePom> moduleQueue = new ConcurrentLinkedDeque<>();
80-
// Map key is the normalized absolute Path to the POM file
80+
// Map key is the normalized absolute Path to the module directory
8181
private final Map<Path, Model> loadedPoms = new ConcurrentHashMap<>();
8282
private final Map<GAV, Model> loadedModules = new ConcurrentHashMap<>();
8383
private final Consumer<WorkspaceModulePom> modelProcessor;
@@ -206,12 +206,13 @@ private Consumer<WorkspaceModulePom> getModelProcessor(BootstrapMavenContext ctx
206206
}
207207

208208
private void loadModule(WorkspaceModulePom rawModule, Collection<WorkspaceModulePom> newModules) {
209-
if (loadedPoms.containsKey(rawModule.getPom())) {
209+
final Path moduleDir = rawModule.getModuleDir();
210+
if (loadedPoms.containsKey(moduleDir)) {
210211
return;
211212
}
212213

213214
final Model model = rawModule.getModel();
214-
loadedPoms.put(rawModule.getPom(), model);
215+
loadedPoms.put(moduleDir, model);
215216
if (model == MISSING_MODEL) {
216217
return;
217218
}
@@ -243,7 +244,11 @@ private void loadModule(WorkspaceModulePom rawModule, Collection<WorkspaceModule
243244
if (rawModule.parent == null) {
244245
final Path parentPom = rawModule.getParentPom();
245246
if (parentPom != null) {
246-
if (!loadedPoms.containsKey(parentPom)) {
247+
var parentDir = parentPom.getParent();
248+
if (parentDir == null) {
249+
parentDir = getFsRootDir();
250+
}
251+
if (!loadedPoms.containsKey(parentDir)) {
247252
rawModule.parent = new WorkspaceModulePom(parentPom);
248253
moduleQueue.push(rawModule.parent);
249254
}
@@ -252,12 +257,17 @@ private void loadModule(WorkspaceModulePom rawModule, Collection<WorkspaceModule
252257
}
253258

254259
private void queueModule(Path module) {
255-
Path pom = module.normalize().toAbsolutePath();
256-
if (Files.isDirectory(pom)) {
257-
pom = pom.resolve(POM_XML);
260+
Path normalizedModuleDir = module.normalize().toAbsolutePath();
261+
final Path pom;
262+
if (Files.isDirectory(normalizedModuleDir)) {
263+
pom = normalizedModuleDir.resolve(POM_XML);
264+
} else {
265+
// it is valid in Maven to point directly to the POM file in the <module> so we need to take that case into account
266+
pom = normalizedModuleDir;
267+
normalizedModuleDir = normalizedModuleDir.getParent() != null ? normalizedModuleDir.getParent() : getFsRootDir();
258268
}
259269

260-
if (!loadedPoms.containsKey(pom)) {
270+
if (!loadedPoms.containsKey(normalizedModuleDir)) {
261271
moduleQueue.push(new WorkspaceModulePom(pom));
262272
}
263273
}

independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceModulePom.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public WorkspaceModulePom(Path pom, Model model, Model effectiveModel) {
2424
this.effectiveModel = effectiveModel;
2525
}
2626

27-
Path getPom() {
28-
return pom;
29-
}
30-
3127
Path getModuleDir() {
3228
var moduleDir = pom.getParent();
3329
return moduleDir == null ? WorkspaceLoader.getFsRootDir() : moduleDir;

0 commit comments

Comments
 (0)