Repository navigation
Conversation
apache#14124) When a BOM that belongs to the current reactor is imported via <scope>import</scope>, the model builder 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 the BOM's own effective-model build. Root cause: ProjectModelResolver.resolveModel() returned a plain FileModelSource for reactor-pool hits. The model builder's isExternalModelBuildingRequest() check (pomFile == null && validationLevel < MAVEN_2_0) then treated it as external because the import request is built with VALIDATION_LEVEL_MINIMAL and no pomFile. Fix: introduce ReactorModelSource extends FileModelSource as a marker type. ProjectModelResolver returns it for reactor pool hits. In DefaultModelBuilder.importDependencyManagement(), set pomFile on the import request when the source is a ReactorModelSource (and the calling request is itself a project build, not an external resolution chain). This makes isExternalModelBuildingRequest() return false for reactor BOMs, restoring full profile activation. Regression introduced by: apache#12953
Contributor
Author
|
Closing in favour of #14124 (cstamas's PR, same fix). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 whatmvn help:effective-pomshows for the BOM itself.Root Cause
ProjectModelResolver.resolveModel()returned a plainFileModelSourcefor reactor-pool hits. TheisExternalModelBuildingRequest()heuristic inDefaultModelBuildercheckspomFile == null && validationLevel < MAVEN_2_0. Since the import request is always built withVALIDATION_LEVEL_MINIMALand nopomFile, the check incorrectly classified reactor BOMs as external, applying the sandbox.Regression introduced by: #12953
Fix
ReactorModelSource extends FileModelSourceas a marker type (inmaven-model-builder, public API since 3.10.3).ProjectModelResolver.resolveModel()returnsReactorModelSourcefor reactor pool hits instead ofFileModelSource.DefaultModelBuilder.importDependencyManagement()setspomFileon the import request when the source is aReactorModelSourceand the calling context is a project build (not itself an external resolution chain). This makesisExternalModelBuildingRequest()returnfalsefor reactor BOMs, restoring full profile activation.The
master/4.0.xcode is not affected:maven-impl'sisExternalOrigin()check usessource.getModelId() != nullas the discriminator, which isfalsefor 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 aReactorModelSource(user property present) and sandboxed when imported as a plainFileModelSource.Fixes #14124
Hermes Agent (Claude Sonnet 4) on behalf of Guillaume Nodet