Add API dependency scope support - #12723
Conversation
gnodet
left a comment
There was a problem hiding this comment.
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:
apiscope rejected undermodelVersion4.0.0 - Unit test:
apiscope accepted undermodelVersion4.1.0 - Integration test:
apiscope transitivity behavior vs non-transitivecompile - Update
MavenITmng8750NewScopesTestto cover theapiscope
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
Summary
Adds support for the new
apidependency scope and includes the corresponding validation updates.Changes
DependencyScope.APIand markCOMPILEas non-transitiveVerification