Skip to content

fix: build reactor BOM imports as project models, not as external ones (#14124) - #14134

Closed
gnodet wants to merge 1 commit into
apache:maven-3.10.xfrom
gnodet:fix/reactor-bom-not-external
Closed

gnodet wants to merge 1 commit into
apache:maven-3.10.xfrom
gnodet:fix/reactor-bom-not-external

Conversation

@gnodet

@gnodet gnodet commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

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

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
@gnodet gnodet added the bug Something isn't working label Nov 26, 2026
@gnodet gnodet added this to the 3.10.3 milestone Nov 26, 2026
@gnodet

gnodet commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #14124 (cstamas's PR, same fix).

@gnodet gnodet closed this Nov 26, 2026
@cstamas cstamas removed this from the 3.10.3 milestone Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants