diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ModelResolutionTaskRunner.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ModelResolutionTaskRunner.java index e5ec42ce668ab..44a4aaf6f9e5d 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ModelResolutionTaskRunner.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ModelResolutionTaskRunner.java @@ -58,8 +58,17 @@ private void assertNoErrors() { log.error(prefix, error); sb.append(System.lineSeparator()).append(prefix).append(" ").append(error.getLocalizedMessage()); for (var e : error.getStackTrace()) { - sb.append(System.lineSeparator()).append(e); + sb.append(System.lineSeparator()); + for (int j = 0; j < prefix.length(); ++j) { + sb.append(" "); + } + sb.append("at ").append(e); if (e.getClassName().contains("io.quarkus")) { + sb.append(System.lineSeparator()); + for (int j = 0; j < prefix.length(); ++j) { + sb.append(" "); + } + sb.append("..."); break; } } diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java index db915361cde8a..8e6cf95ca6c77 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/workspace/WorkspaceLoader.java @@ -159,6 +159,7 @@ LocalProject load() throws BootstrapMavenException { }; } + final ConcurrentLinkedDeque errors = new ConcurrentLinkedDeque<>(); while (!moduleQueue.isEmpty()) { ConcurrentLinkedDeque newModules = new ConcurrentLinkedDeque<>(); while (!moduleQueue.isEmpty()) { @@ -169,12 +170,15 @@ LocalProject load() throws BootstrapMavenException { CompletableFuture.runAsync(() -> { try { loadModule(module, newModules); + } catch (Exception e) { + errors.add(e); } finally { phaser.arriveAndDeregister(); } }); } phaser.arriveAndAwaitAdvance(); + assertNoErrors(errors); } for (var newModule : newModules) { newModule.process(processor); @@ -280,6 +284,35 @@ public List findVersions(Artifact artifact) { return model == null ? List.of() : List.of(ModelUtils.getVersion(model)); } + private void assertNoErrors(Collection errors) throws BootstrapMavenException { + if (!errors.isEmpty()) { + var sb = new StringBuilder("The following errors were encountered while loading the workspace:"); + log.error(sb); + var i = 1; + for (var error : errors) { + var prefix = i++ + ")"; + log.error(prefix, error); + sb.append(System.lineSeparator()).append(prefix).append(" ").append(error.getLocalizedMessage()); + for (var e : error.getStackTrace()) { + sb.append(System.lineSeparator()); + for (int j = 0; j < prefix.length(); ++j) { + sb.append(" "); + } + sb.append("at ").append(e); + if (e.getClassName().contains("io.quarkus")) { + sb.append(System.lineSeparator()); + for (int j = 0; j < prefix.length(); ++j) { + sb.append(" "); + } + sb.append("..."); + break; + } + } + } + throw new BootstrapMavenException(sb.toString()); + } + } + private static Model readModel(Path pom) { try { final Model model = ModelUtils.readModel(pom); diff --git a/independent-projects/bootstrap/maven-resolver/src/test/resources/workspace-multiple/root/module1/pom.xml b/independent-projects/bootstrap/maven-resolver/src/test/resources/workspace-multiple/root/module1/pom.xml index b86b54de20965..5e6b8d0cf7575 100644 --- a/independent-projects/bootstrap/maven-resolver/src/test/resources/workspace-multiple/root/module1/pom.xml +++ b/independent-projects/bootstrap/maven-resolver/src/test/resources/workspace-multiple/root/module1/pom.xml @@ -9,7 +9,7 @@ root-module1 - +