Avoid resolving unused plugins for direct goals
Changed Maven execution planning so direct CLI goals resolve only the selected plugin instead of eagerly loading descriptors for unused build and managed plugins.
apache/maven · #12721
Build efficiency fix
Direct Maven CLI goals no longer resolve or download every unrelated versionless plugin declared by the project before executing the requested goal.
Problem
Calculating a direct-goal task segment triggered project-wide missing-version resolution. Compatibility checks loaded plugin descriptors, causing Maven to resolve and download unrelated versionless plugins even when they were unbound, in inactive profiles, or absent from the requested goal.
Approach
Skipped project-wide plugin version resolution while calculating direct-goal segments, limited eager resolution during execution planning to plans containing lifecycle phases, and resolved a missing version lazily only when a project-declared plugin is actually considered during prefix resolution.
Impact and scope
- Reduces unnecessary repository traffic, descriptor loading, and startup work for focused Maven CLI commands.
- Prevents unrelated plugin availability or network state from blocking a direct goal that does not use those plugins.
- Preserves eager version resolution for lifecycle mappings and the existing descriptor path for the plugin Maven actually selects.
Validation
- Added focused lifecycle-planning and plugin-prefix regression coverage, then passed the complete Maven Core module tests and `mvn verify`.
- Built the Maven distribution and proved `help:help` does not resolve or download versionless release and Javadoc plugins from an isolated project.
- Both authored commits and the merge commit are GitHub-verified; the fix received three maintainer approvals and closed MNG-8693 as completed.