[MNG-8693] Avoid resolving unused plugins for direct goals - #12721
[MNG-8693] Avoid resolving unused plugins for direct goals#12721goutamadwant wants to merge 2 commits into
Conversation
Skip project-wide plugin version resolution for direct-goal-only plans while preserving it for lifecycle phases. Resolve versionless project prefix candidates lazily and add regression coverage for both paths.
gnodet
left a comment
There was a problem hiding this comment.
Well-structured optimization that correctly defers plugin version resolution to the point of actual use (MNG-8693). The lazy resolution in DefaultPluginPrefixResolver is correctly placed inside existing error handling, and the conditional guard in DefaultLifecycleExecutionPlanCalculator properly limits bulk resolution to lifecycle-phase builds.
Two minor observations (non-blocking):
-
Test coverage: The new
DefaultLifecycleExecutionPlanCalculatorTestcovers the negative case (GoalTaskdoes not triggerresolveMissingPluginVersions). A complementary positive test verifying that aLifecycleTaskdoes trigger resolution would strengthen coverage. -
Subtle behavioral difference: The new version request in
DefaultPluginPrefixResolverincludes.setPom(request.getPom()), which the previous bulk resolution inLifecyclePluginResolverdid not pass. This gives the version resolver more context (pluginManagement declarations) and is arguably more correct, but it's a subtle difference worth noting.
The forked execution path correctly retains the resolveMissingPluginVersions call for forked projects, and error handling is maintained (lazy resolution falls inside the existing catch(Exception) block).
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of gnodet
Add the complementary positive regression that lifecycle tasks continue to resolve missing project plugin versions before lifecycle mapping.
|
@gnodet Thanks for the review. I added the complementary lifecycle-task test to verify that project-wide plugin version resolution is still performed for lifecycle-phase plans. I kept the POM on the lazy version request intentionally so the selected project plugin can reuse version information from the project or pluginManagement before falling back to repository resolution. |
gnodet
left a comment
There was a problem hiding this comment.
Well-structured optimization that correctly defers plugin version resolution to the point of actual use for direct CLI goals (MNG-8693). The lazy resolution in DefaultPluginPrefixResolver is properly placed inside existing error handling, the conditional guard in DefaultLifecycleExecutionPlanCalculator correctly limits bulk resolution to lifecycle-phase plans, and test coverage is solid.
Minor observations (non-blocking):
- The new lazy version request passes
setPom(request.getPom())which the previous bulk resolution inLifecyclePluginResolverdid not. This gives the version resolver more context (pluginManagement declarations) and is arguably more correct, but it is a subtle behavioral difference. The PR author acknowledged this as intentional. plugin.setVersion()directly mutates the model Plugin object. This is consistent with whatLifecyclePluginResolver.resolveMissingPluginVersionsalready does, so it is not a new concern.- The forked execution path at
DefaultLifecycleExecutionPlanCalculatorline 374 correctly retains theresolveMissingPluginVersionscall for forked projects, ensuring no regression for mojos that fork lifecycle phases. - Test coverage is comprehensive:
DefaultPluginPrefixResolverTestverifies lazy resolution only for matching plugins, andDefaultLifecycleExecutionPlanCalculatorTestcovers both the negative case (GoalTask skips resolution) and the positive case (LifecycleTask triggers resolution).
This review was generated by an AI agent (Claude Code) and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
Fixes #10128.
Summary
Direct CLI goals currently trigger missing-version resolution for every plugin in the project before Maven resolves the requested goal. Plugin version compatibility checks load plugin descriptors, which can download versionless build and managed plugins even when the goal does not use them.
This change:
Lifecycle-phase plans continue to resolve missing plugin versions before lifecycle mapping. Direct goals continue to resolve the selected plugin through the existing descriptor path.
Tests
mvn -pl impl/maven-core -am -Dtest=DefaultPluginPrefixResolverTest,DefaultLifecycleExecutionPlanCalculatorTest -Dsurefire.failIfNoSpecifiedTests=false testmvn -pl impl/maven-core -am testmvn verifyhelp:helpagainst an isolated project with versionlessmaven-release-pluginandmaven-javadoc-pluginentries inpluginManagement. The command succeeds without resolving or downloading either unused plugin.mvn -Prun-its install. Core IT reached 518 tests, with 494 passing and 23 skipped;MavenITmng4428FollowHttpRedirectTest.testitHttpsToHttpsfailed while retrieving an artifact through its local HTTPS redirect server under JDK 26. This test and failure path are unrelated to the changed plugin-resolution code.Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.