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

   Resolves issue #11292 where Maven shows '[unknown project]' in error 
messages when using -e -X flags, particularly in CI environments.
   
   ## Problem
   
   The issue occurred because `DefaultProjectBuilder` was creating 
`DefaultProjectBuildingResult` with null project information when 
`ModelBuilderResult.getEffectiveModel()` returned null, resulting in empty 
projectId and causing `ProjectBuildingException.createMessage()` to display 
'[unknown project]' as a fallback.
   
   ## Solution
   
   This fix extracts project identification from available model data (rawModel 
or fileModel) when effectiveModel is null, following the same pattern used in 
`ModelBuilderException.getModelId()`.
   
   ## Changes
   
   - Added `extractProjectId()` helper method that falls back to rawModel or 
fileModel when effectiveModel is null
   - Modified project building result creation to use extracted projectId and 
POM file information instead of null values
   - Maintains backward compatibility: when all models are null, still returns 
empty string to preserve '[unknown project]' fallback for truly unknown projects
   - Added comprehensive unit tests to verify the fallback behavior
   
   ## Benefits
   
   - Provides better error messages showing meaningful project identification 
like 'com.example:my-project:jar:1.0.0' even when project building fails
   - Maintains existing error handling patterns
   - Consistent with existing patterns in the codebase 
(ModelBuilderException.getModelId())
   - Addresses the CI issue reported in #11292
   
   ## Testing
   
   The fix includes unit tests that verify:
   1. Normal case: When effectiveModel is available, use it (no change in 
behavior)
   2. Fallback to rawModel: When effectiveModel is null but rawModel is 
available, extract ID from rawModel
   3. Fallback to fileModel: When both effectiveModel and rawModel are null but 
fileModel is available, extract ID from fileModel
   4. All models null: When all models are null, return empty string (preserves 
existing fallback behavior)
   
   Fixes #11292
   
   ---
   Pull Request opened by [Augment Code](https://www.augmentcode.com/) with 
guidance from the PR author


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