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

   ## Summary
   
   When a BOM that belongs to the current reactor is imported via 
`<scope>import</scope>`, Maven was incorrectly treating it as a 
repository-resolved (external) model. This caused profile activation to be 
sandboxed — user properties suppressed, file activation disabled — producing 
results inconsistent with what `mvn help:effective-pom` shows for the BOM 
itself.
   
   ## Root Cause
   
   `ProjectModelResolver.resolveModel()` returned a plain `FileModelSource` for 
reactor-pool hits. The `isExternalModelBuildingRequest()` heuristic in 
`DefaultModelBuilder` checks `pomFile == null && validationLevel < MAVEN_2_0`. 
Since the import request is always built with `VALIDATION_LEVEL_MINIMAL` and no 
`pomFile`, the check incorrectly classified reactor BOMs as external, applying 
the sandbox.
   
   Regression introduced by: #12953
   
   ## Fix
   
   - Introduce `ReactorModelSource extends FileModelSource` as a marker type 
(in `maven-model-builder`, public API since 3.10.3).
   - `ProjectModelResolver.resolveModel()` returns `ReactorModelSource` for 
reactor pool hits instead of `FileModelSource`.
   - `DefaultModelBuilder.importDependencyManagement()` sets `pomFile` on the 
import request when the source is a `ReactorModelSource` and the calling 
context is a project build (not itself an external resolution chain). This 
makes `isExternalModelBuildingRequest()` return `false` for reactor BOMs, 
restoring full profile activation.
   
   The `master`/`4.0.x` code is not affected: `maven-impl`'s 
`isExternalOrigin()` check uses `source.getModelId() != null` as the 
discriminator, which is `false` for file-based sources — an equivalent guard is 
already there by design.
   
   ## Tests
   
   `DefaultModelBuilderTest.testReactorImportIsBuiltAsProject`: verifies that a 
BOM with a property-activated profile is activated when imported as a 
`ReactorModelSource` (user property present) and sandboxed when imported as a 
plain `FileModelSource`.
   
   Fixes #14124
   
   ---
   _Hermes Agent (Claude Sonnet 4) on behalf of Guillaume Nodet_
   


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