Mazen050 opened a new pull request, #12707:
URL: https://github.com/apache/maven/pull/12707

   <!--
   Please open pull requests against one of the following branches:
   
   - master — default target for all changes (new features + bug fixes).  
     If the change should also go to maven-4.0.x, request a backport in the PR.
   
   - maven-3.10.x — target for 3.x changes (new features + bug fixes).  
     If the change should also go to maven-3.9.x, request a backport in the PR.
     maven-3.9.x should receive only serious bug fixes, as it is approaching 
EOL.
   
   Backports are typically handled by maintainers; 
   however, after agreement you may open a separate backport PR to the target 
maintenance branch.
   -->
   
   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
   - [x] Your pull request should address just one issue, without pulling in 
other changes.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line 
and body.
     Note that commits might be squashed by a maintainer on merge.
   - [x] Write unit tests that match behavioral changes, where the tests fail 
if the changes to the runtime are not applied.
     This may not always be possible but is a best-practice.
   - [x] Run `mvn verify` to make sure basic checks pass.
     A more thorough check will be performed on your pull request automatically.
   - [ ] You have run the [Core IT][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License 
Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
   - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   - [ ] In any other case, please file an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   
   
   ## Summary
   
   Fixes #12691 by removing the duplicate rendering of model problems 
introduced in `ProjectBuildingException#createMessage(...)`.
   
   The detailed per-project diagnostics were added to the exception message in 
#10975. However, `DefaultExceptionHandler` already reconstructs and renders the 
same information from `ProjectBuildingException#getResults()`, so the new 
exception message caused the same diagnostics to be printed twice.
   
   This change restores the previous behavior by reverting 
`ProjectBuildingException#createMessage(List<ProjectBuildingResult>)` to return 
the short summary message, leaving the existing rendering in 
`DefaultExceptionHandler` as the single source of detailed diagnostics.
   
   `ProjectBuildingExceptionTest` is removed because it was introduced to 
validate the detailed formatting added in #10975. Reverting that behavior makes 
the test obsolete; the remaining behavior is simply returning the generic 
exception message.
   
   ## Before
   
   ```
   [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 …
   ```
   
   ## After
   
   ```
   [ERROR] Some problems were encountered while processing the POMs
   [ERROR] The build could not read 1 project -> [Help 1]
   [ERROR]   
   [ERROR]   The project (/workspaces/maven/maven-repro/pom.xml) has 3 errors
   [ERROR]     'modelVersion' 99.0.0' is not supported by this Maven version 
(4.1.0-SNAPSHOT). Supported modelVersions are: [4.0.0, 4.1.0, 4.2.0]. Building 
this project requires a newer version of Maven. @ test:fail-build:0.1-SNAPSHOT, 
file:///workspaces/maven/maven-repro/pom.xml, line 2, column 3
   [ERROR]     Malformed POM /workspaces/maven/maven-repro/pom.xml: Unable to 
read model: Unrecognised tag: 
'{http://maven.apache.org/POM/4.0.0}invalidElementShouldFailBuild': ParseError 
at [row,col]:[7,3]
   [ERROR]     Message: Unrecognised tag: 
'{http://maven.apache.org/POM/4.0.0}invalidElementShouldFailBuild'
   [ERROR]     Failed to load project /workspaces/maven/maven-repro/pom.xml @ 
org.apache.maven:maven-toolchain-builder:4.1.0-SNAPSHOT, 
/workspaces/maven/compat/maven-toolchain-builder/pom.xml: 2 problems were 
encountered while building the effective model
   [ERROR]         - [FATAL] 'modelVersion' 99.0.0' is not supported by this 
Maven version (4.1.0-SNAPSHOT). Supported modelVersions are: [4.0.0, 4.1.0, 
4.2.0]. Building this project requires a newer version of Maven. @ line 2, 
column 3
   [ERROR]         - [ERROR] Malformed POM 
/workspaces/maven/maven-repro/pom.xml: Unable to read model: Unrecognised tag: 
'{http://maven.apache.org/POM/4.0.0}invalidElementShouldFailBuild'
   [ERROR] 
   [ERROR] To see the full stack trace of the errors, re-run Maven with the 
'-e' switch
   [ERROR] Re-run Maven using the '-X' switch to enable verbose output
   [ERROR] 
   [ERROR] For more information about the errors and possible solutions, please 
read the following articles:
   [ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
   ```
   
   Each model problem is now reported once again, matching the pre-4.0.0-rc-6 
behavior.
   
   Note: Please consider backporting this change to maven-4.0.x, as it fixes a 
regression affecting the 4.0.x release line.


-- 
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]

Reply via email to