Skip to content

Add LOAD_PROJECT request type for projects loaded from a POM file - #13669

Merged
gnodet merged 4 commits into
apache:masterfrom
Shreekar-cloud:fix-13395-load-project-pr
Nov 3, 2026
Merged

gnodet merged 4 commits into
apache:masterfrom
Shreekar-cloud:fix-13395-load-project-pr

Conversation

@Shreekar-cloud

Copy link
Copy Markdown
Contributor

Fixes #13395.

Implements the design suggested in the review of #13601: a new RequestType.LOAD_PROJECT instead of exposing a validation level on ModelBuilderRequest.

  • LOAD_PROJECT gets the project treatment (local parent lookup, profile activation) but is parsed and validated leniently, like the consumer request types.
  • Reactor and standalone builds stay BUILD_EFFECTIVE.
  • A POM file with processPlugins on becomes BUILD_EFFECTIVE if the validation level is STRICT, and LOAD_PROJECT otherwise. Every non-STRICT compat level gets MINIMAL validation, as before.
  • The regression test and the original analysis come from Fix project validation level handling during parent resolution #13601 by @abdulhannansyed548-cmd, who is credited as co-author.

Testing (Windows, JDK 25): ProjectBuilderTest#testLocalParentResolutionWithValidationLevels passes on current master. On the previous base I also ran the maven-core org.apache.maven.project tests and the maven-impl model and cache tests (259 run in maven-core, 0 failures). I haven't run mvn -Prun-its verify, so CI is the real check.

Fixes apache#13395.

Co-authored-by: Abdul Hannan <abdulhannansyed548@gmail.com>

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

Thanks for the clean refactoring — the introduction of LOAD_PROJECT request type and isStrictRequest() is a nice improvement to the model-building semantics.

One test-code observation:

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

@Shreekar-cloud

Copy link
Copy Markdown
Contributor Author

Thanks. processPlugins=false is a consumer request that never looks up a local parent, so it isn’t meaningful for this test. I’ve replaced the single-value loop with a plain setProcessPlugins(true) and a comment.

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

Previous findings are all addressed. The List.of(true) dead-loop concern is resolved — the test now iterates over validation levels (MINIMAL, STRICT) correctly.

LGTM. The LOAD_PROJECT semantics are correct: isBuildRequest() includes it for project-level operations (local parent lookup, profile activation, pomFile assignment), while isStrictRequest() excludes it from strict parsing and validation. All four validation call sites in DefaultModelBuilder were updated consistently. isBuildRequestWithActivation() already returns true for LOAD_PROJECT (it excludes only BUILD_CONSUMER) without any code change — profile activation works correctly.

The test covers the two distinct code paths introduced by the PR (MINIMAL → LOAD_PROJECT → lenient, STRICT → BUILD_EFFECTIVE → strict) and correctly asserts both local parent resolution (works for both levels) and the relativePath warning (only for STRICT).

Note: PRs #13394 and #13601 are still open and target the same issue — they should be closed when this merges.

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

@slachiewicz slachiewicz added the enhancement New feature or request label Oct 29, 2026
@Shreekar-cloud

Copy link
Copy Markdown
Contributor Author

Hi @gnodet,

Just following up on this PR. The requested review changes have been addressed, the branch is up to date with master, and all 21 checks are passing.

Since the PR has been approved, could you please let me know if anything else is needed before merging?

Thanks again for your time and review!

@gnodet
gnodet requested a balanced review from Copilot October 30, 2026 19:24

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds a new ModelBuilderRequest.RequestType.LOAD_PROJECT to allow “project semantics” (local parent lookup, profile activation) while keeping lenient parsing/minimal validation for non-build usage (e.g., IDEs), and wires it through model building and project building.

Changes:

  • Introduces RequestType.LOAD_PROJECT in the public API with semantics/validation expectations.
  • Updates DefaultProjectBuilder to select LOAD_PROJECT vs BUILD_EFFECTIVE based on processPlugins + validation level.
  • Updates DefaultModelBuilder to distinguish “project semantics” from “strict parsing/validation”, plus adds a regression test.
File Description
impl/​maven-impl/​src/​main/​java/​org/​apache/​maven/​impl/​model/​DefaultModelBuilder.java Separates “strict parsing/validation” from “project request semantics” with isStrictRequest() and extends “project” behavior to LOAD_PROJECT.
impl/​maven-core/​src/​main/​java/​org/​apache/​maven/​project/​DefaultProjectBuilder.java Chooses LOAD_PROJECT for filesystem POM loads with plugins processing unless validation is STRICT (then BUILD_EFFECTIVE).
api/​maven-api-core/​src/​main/​java/​org/​apache/​maven/​api/​services/​ModelBuilderRequest.java Adds the new public RequestType.LOAD_PROJECT enum constant + Javadoc.
impl/​maven-core/​src/​test/​java/​org/​apache/​maven/​project/​ProjectBuilderTest.java Adds regression coverage for local parent resolution and warning behavior across validation levels.

Review effort: Lite

…uest/isStrictRequest Javadoc

- Add comment explaining why the child POM uses modelVersion 4.1.0 (the
  validation warning for redundant relativePath only fires for non-4.0.0
  model versions, so 4.0.0 would make the test a no-op)
- Make the problem assertion more robust: match on Severity.WARNING and
  the stable field name 'parent.relativePath' in the message, rather than
  a substring of the mutable message body
- Make isStrictRequest() an explicit positive check instead of negating
  isBuildRequest(), and add a Javadoc to isBuildRequest() clarifying that
  LOAD_PROJECT is included for project-level semantics (local parents,
  profile activation) but not strict validation
@gnodet
gnodet merged commit 3036958 into apache:master Nov 3, 2026
22 checks passed
@github-actions github-actions Bot added this to the 4.2.0 milestone Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v3 ProjectBuilder classifies a project built from its POM file as a dependency unless validation is STRICT

5 participants