Skip to content

Add API dependency scope support - #12723

Open
charangowdamd-cmd wants to merge 1 commit into
apache:masterfrom
charangowdamd-cmd:fix/api-scope-validation
Open

Add API dependency scope support#12723
charangowdamd-cmd wants to merge 1 commit into
apache:masterfrom
charangowdamd-cmd:fix/api-scope-validation

Conversation

@charangowdamd-cmd

Copy link
Copy Markdown

Summary

Adds support for the new api dependency scope and includes the corresponding validation updates.

Changes

  • Add DependencyScope.API and mark COMPILE as non-transitive
  • Include the new scope in the resolver scope manager configuration
  • Include it in the supported path scopes
  • Update model validation for 4.0.0 compatibility checks
  • Extend the validator test coverage for the new scope

Verification

  • Relevant Maven validation test was run for the modified area
  • The branch was pushed to the fork and is ready for review

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

The design intent — splitting compile into transitive api and non-transitive compile (similar to Gradle's api/implementation) — is a good direction for Maven 4.1. However, the implementation has significant gaps that would cause regressions:

Critical: Consumer POM builder regression

DefaultConsumerPomBuilder.hasDependencyScope() (line 292–301) returns true (remove dependency) when !scope.isTransitive(). With this PR changing COMPILE to non-transitive, all compile-scoped dependencies (and dependencies with no explicit scope, which default to COMPILE) would be stripped from consumer POMs.

The existing integration test MavenITgh11162ConsumerPomScopesTest explicitly asserts that compile-scoped dependencies are kept in the consumer POM (assertEquals(2, numDeps, "Consumer POM should keep only compile and runtime dependencies")) — this test would fail with the current change.

The consumer POM builder needs to be updated to handle the new api scope and adjust its filtering logic accordingly.

Missing test coverage

The PR description says it extends validator test coverage, but the only test change adds scopes.add(new DepScope("api")) to the mock scope list — no actual test methods are added. Needed:

  • Unit test: api scope rejected under modelVersion 4.0.0
  • Unit test: api scope accepted under modelVersion 4.1.0
  • Integration test: api scope transitivity behavior vs non-transitive compile
  • Update MavenITmng8750NewScopesTest to cover the api scope

Stale javadoc

The COMPILE javadoc still says "Compile, runtime and test." but doesn't mention it is no longer transitive. Since the new API javadoc explicitly says "exported transitively," the COMPILE javadoc should clarify the distinction — e.g., "Compile, runtime and test. Non-transitive; use API to export transitively."

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of gnodet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants