Skip to content

fix: resolve the conflict how models are being built - #14124

Merged
gnodet merged 1 commit into
maven-3.10.xfrom
maven-3.10.x-in-reactor-boms-are-not-external
Nov 27, 2026
Merged

gnodet merged 1 commit into
maven-3.10.xfrom
maven-3.10.x-in-reactor-boms-are-not-external

Conversation

@cstamas

@cstamas cstamas commented Nov 25, 2026

Copy link
Copy Markdown
Member

Maven distinguishes how builds a project model and how builds a dependency model.

A recent change introduced similar change, but also did introduce conflict; it was handling in-reactor models as external ones: #12953

In this case, users end up with duality, as the in-reactor BOM is fully interpolated, but then, at usage point they end up with something completely different than effective BOM would show.

Complete the "is external" check, by considering is artifact part of reactor or not as well.

Maven distinguishes how builds a project model and how builds
a dependency model.

A recent change introduced similar change, but also did introduce
conflict; it was handling in-reactor models as external ones:
#12953

In this case, users end up with duality, as the in-reactor BOM
is fully interpolated, but then, at usage point they end up with
something completely different than effective BOM would show.

Complete the "is external" check, by considering is artifact
part of reactor or not as well.
@cstamas cstamas added this to the 3.10.3 milestone Nov 25, 2026
@cstamas cstamas added the bug Something isn't working label Nov 25, 2026
@gnodet

gnodet commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Looking at the master/4.0.x code paths, I don't believe those branches are affected by the same bug, though they go through a different code path.

On master/4.0.x, the equivalent concept is isExternalOrigin() in maven-impl's DefaultModelBuilder:

static boolean isExternalOrigin(ModelBuilderRequest request) {
    return request.getRequestType() == ModelBuilderRequest.RequestType.CONSUMER_DEPENDENCY
            && request.getSource() != null
            && request.getSource().getModelId() != null;
}

The key difference is the source.getModelId() != null guard. In importDependencyManagement() on master, the code first calls resolveReactorModel() for the BOM. If the BOM is in the reactor, it returns a file-based source (a Path) — which carries no modelId. So isExternalOrigin() returns false for reactor BOMs, and they are correctly built without the external-model restrictions. There is even an explicit warning logged when a BUILD_PROJECT request imports a BOM from within the reactor.

On 3.10.x, the workspaceResolver path is supposed to handle reactor BOMs (returning the already-built effective model directly, bypassing the importRequest with VALIDATION_LEVEL_MINIMAL entirely). The bug in #12953 is that when the workspace resolver doesn't cover the BOM, the fallback modelResolver path builds the import request with VALIDATION_LEVEL_MINIMAL and no pomFile, which satisfies isExternalModelBuildingRequest() even for in-reactor artifacts. The master code avoids this by using the source type as the discriminator rather than the validation level.

So the fix is correctly scoped to 3.10.x — there's nothing to backport from master/4.0.x since the structural difference in how sources are typed prevents the problem from occurring there.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. No issues found.

The ReactorModelSource marker class is a sound design choice — a pure subtype of FileModelSource with no behavior of its own, used solely as a type tag. This is the right pattern for 3.10.x where the resolver API has no richer metadata support.

The condition importSource instanceof ReactorModelSource && !isExternalModelBuildingRequest(request) correctly gates on the outer request. If a dependency POM (external) itself imports a reactor BOM, it won't be escalated to project-mode building — only direct project builds benefit, which is the correct semantics.

The test validates both paths directly: ReactorModelSource → profiles active (count=1), FileModelSource → profiles sandboxed (count=0).

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet
gnodet merged commit d947f73 into maven-3.10.x Nov 27, 2026
17 checks passed
@gnodet
gnodet deleted the maven-3.10.x-in-reactor-boms-are-not-external branch November 27, 2026 09:03
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.

4 participants