diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenBuilderException.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenBuilderException.java index 8c157463a17..191d5758c3f 100644 --- a/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenBuilderException.java +++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/MavenBuilderException.java @@ -25,7 +25,7 @@ import org.apache.maven.api.annotations.Experimental; /** - * Base class for all maven exceptions. + * Base class for all maven exceptions carrying {@link BuilderProblem}s. * * @since 4.0.0 */ @@ -44,12 +44,17 @@ public MavenBuilderException(String message, List problems) { this.problems = problems; } + /** + * Formats message out of problems: problems are sorted (in natural order of {@link BuilderProblem.Severity}) + * and then a list is built. These exceptions are usually thrown in "fatal" cases (and usually prevent Maven + * from starting), and these exceptions may end up very early on output. + */ protected static String buildMessage(String message, List problems) { StringBuilder msg = new StringBuilder(message); ArrayList sorted = new ArrayList<>(problems); sorted.sort(Comparator.comparing(BuilderProblem::getSeverity)); for (BuilderProblem problem : sorted) { - msg.append("\n * ").append(problem.getSeverity().name()).append(" ").append(problem.getMessage()); + msg.append("\n * ").append(problem.getSeverity().name()).append(": ").append(problem.getMessage()); } return msg.toString(); } diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8379SettingsDecryptTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8379SettingsDecryptTest.java index a69490e219a..ebaa574b955 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8379SettingsDecryptTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng8379SettingsDecryptTest.java @@ -47,7 +47,8 @@ void testLegacy() throws Exception { verifier.verifyErrorFreeLog(); // there is a warning and all fields decrypted - verifier.verifyTextInLog("[INFO] Some problems were encountered while building the effective settings (use -X to see details)"); + verifier.verifyTextInLog( + "[INFO] Some problems were encountered while building the effective settings (use -X to see details)"); verifier.verifyTextInLog("testtest"); verifier.verifyTextInLog("testtest"); } @@ -70,7 +71,8 @@ void testModern() throws Exception { // there is no warning and all fields decrypted verifier.verifyTextNotInLog("[WARNING]"); - verifier.verifyTextNotInLog("[INFO] Some problems were encountered while building the effective settings (use -X to see details)"); + verifier.verifyTextNotInLog( + "[INFO] Some problems were encountered while building the effective settings (use -X to see details)"); verifier.verifyTextInLog("testtest"); verifier.verifyTextInLog("secretHeader"); }