slachiewicz opened a new issue, #12691: URL: https://github.com/apache/maven/issues/12691
Since 4.0.0-rc-6 every model problem is printed twice: once in a new grouped per-file block, and again in the `ProjectBuildingException` summary that Maven has always emitted. ### Reproduction A single pom, no other files: ```xml <project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>99.0.0</modelVersion> <groupId>test</groupId> <artifactId>fail-build</artifactId> <version>0.1-SNAPSHOT</version> <packaging>jar</packaging> <invalidElementShouldFailBuild/> </project> ``` ``` mvn -B validate ``` 4.0.0-rc-5 reports each problem once: ``` [ERROR] Some problems were encountered while processing the POMs [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (…/pom.xml) has 3 errors [ERROR] 'modelVersion' of '99.0.0' is newer than the versions supported by this version of Maven: [4.0.0, 4.1.0]. … [ERROR] Malformed POM …: Unrecognised tag: '…invalidElementShouldFailBuild': ParseError at [row,col]:[8,3] [ERROR] Message: Unrecognised tag: '…invalidElementShouldFailBuild' [ERROR] Failed to load project … ``` 4.0.0-rc-6 reports each problem twice — the new block first, then the same three problems again in the old one: ``` [ERROR] 3 problems were encountered while processing the POMs (3 errors): [pom.xml] [FATAL] 'modelVersion' of '99.0.0' is newer than the versions supported by this Maven version (4.0.0-rc-6). … [ERROR] Malformed POM …: Unrecognised tag: '…invalidElementShouldFailBuild' @ …/pom.xml [ERROR] Failed to load project …/pom.xml [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project (…/pom.xml) has 3 errors [ERROR] 'modelVersion' of '99.0.0' is newer than the versions supported by this Maven version (4.0.0-rc-6). … [ERROR] Malformed POM …: Unrecognised tag: '…invalidElementShouldFailBuild': ParseError at [row,col]:[8,3] [ERROR] Message: Unrecognised tag: '…invalidElementShouldFailBuild' [ERROR] Failed to load project …: 2 problems were encountered while building the effective model [ERROR] - [FATAL] 'modelVersion' of '99.0.0' … [ERROR] - [ERROR] Malformed POM … ``` ### Cause cb9c4f16e2 ("Improve `ProjectBuildingException` error messages with detailed problem reporting", #10975) changed `ProjectBuildingException.createMessage(List<ProjectBuildingResult>)` from returning the one-line `"Some problems were encountered while processing the POMs"` to rendering the full per-project detail into the exception message. That message reaches the log because `DefaultGraphBuilder` wraps the exception in a `DefaultModelProblem`: ```java } catch (final ProjectBuildingException | DuplicateProjectException | MavenExecutionException e) { return Result.error(Collections.singletonList(new DefaultModelProblem(null, null, null, null, 0, 0, e))); } ``` Meanwhile `DefaultExceptionHandler.handle()` never uses that message — for a `ProjectBuildingException` it discards it and rebuilds the same information from `getResults()`: ```java if (exception instanceof ProjectBuildingException projectBuildingException) { … message = "The build could not read " + children.size() + " project" + (children.size() == 1 ? "" : "s"); } ``` So the detail added to the message is not a replacement for the existing rendering, it is a second copy of it. Still present on `master`. ### Impact Beyond the duplicated output, this breaks anything that counts occurrences of a diagnostic. maven-invoker-plugin's `fail-build-streamLogsOnFailures` IT asserts that a `[FATAL]` line appears twice across two forked runs and now sees four (apache/maven-invoker-plugin#744 makes that assertion version-independent, but the duplicated output stands on its own.) ### Suggested fix Pick one renderer. Either revert `createMessage` to the short form and keep the `ExceptionSummary` tree, or have `DefaultExceptionHandler` use the exception's message and stop rebuilding the children. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
