Skip to content

[MNG-6135] Maven plugins and core extensions are not dependencies, they should be resolved the same way as projects. #7306

Open

Description

@jira-importer

Christian Schulte opened MNG-6135 and commented

Due to a bug in the Maven resolver, plugin and core extensions were resolved incorrectly: the direct test and provided dependencies were ignored.

Ironically, this fix breaks some plugins because direct test dependencies now take precedence over transitive compile one: see MNG-5739
(we know only one case where provided case has an impact: MPLUGIN-296, and in this only case, the new behaviour is more consistent than the previous)


Issue Links:

  • MRESOLVER-8 ScopeDependencySelector incorrectly de-selects direct dependencies
    ("is blocked by")

  • MRESOLVER-9 DefaultDependencyCollector does not correctly handle dependency management
    ("is blocked by")

  • MRESOLVER-10 New 'TransitiveDependencyManager' supporting transitive dependency management
    ("is blocked by")

  • MNG-8559 Rewrite DefaultPluginManager with Maven 4 API
    ("Is contained by")

  • MNG-5739 Adding a test dependency can move dependencies from the compile scope to the test scope

  • MPLUGIN-321 improve documentation on maven-plugin-annotations telling that optional=true is sufficient

  • MEAR-246 Upgrade the EAR lifecycle to use the maven-resources-plugin 3.0.2.
    ("breaks")

  • MPLUGIN-296 java.lang.ClassNotFoundException: org.apache.maven.plugins.annotations.Execute
    ("breaks")

  • MWAR-400 Upgrade the WAR lifecycle to use the maven-resources-plugin 3.0.2
    ("breaks")

  • MRESOURCES-234 Upgrade of commons-io to 2.5 and correction of invalid scope.
    ("breaks")

  • MPMD-230 Required class missing: org/apache/commons/io/IOUtils
    ("breaks")

Remote Links:

1 votes, 9 watchers

Activity

  1. jira-importer commented on Dec 21, 2016

    @jira-importer
    Author

    Christian Schulte commented

    Re-opening to edit links.

  2. jira-importer commented on Jan 9, 2017

    @jira-importer
    Author

    Stephen Connolly commented

    Maven 3.4.0 has been dropped. See this thread for more details.

    This issue will need to be re-scheduled for a Maven release in the (hopefully near) future.

  3. jira-importer commented on Feb 1, 2017

    @jira-importer
    Author

    Michael Osipov commented

    Why is this fixed, where is the commit link?

  4. jira-importer commented on Feb 2, 2017

    @jira-importer
    Author

    Christian Schulte commented

    See this thread on dev@. Issue is resolved, not closed.

  5. jira-importer commented on Mar 25, 2017

    @jira-importer
    Author

    Christian Schulte commented

    Issue is fixed in the master branch of my private maven repository on github. When interested, you can cherry pick the commit to your own repository and create a pull request for the apache master branch with just this commit yourself from there.

  6. jira-importer commented on Oct 13, 2020

    @jira-importer
    Author

    mike duigou commented

    Why was this never cherry picked back in to maven master from the abandoned 3.4.0 branch?

  7. jira-importer commented on Oct 16, 2020

    @jira-importer
    Author

    Michael Osipov commented

    mike duigou, because this is a lot of work? Do you want to give it a try?

  8. added
    bug
    priority:critical
    on Jul 6, 2025
  9. goutamadwant commented on Aug 30, 2026

    @goutamadwant
    Contributor

    @gnodet I reviewed the current plugin/core-extension resolution paths and the related issues. My understanding is that the core inconsistency still exists:

    • Project resolution uses a root artifact and adds direct dependencies explicitly.
    • Plugin and core-extension resolution use the plugin artifact as a root dependency.
    • The legacy scope selector therefore handles direct test and provided dependencies differently for projects versus plugins/extensions.

    A direct selector change would address that inconsistency, but it may expose the mediation problem described in MNG-5739: a direct test dependency can win over a transitive compile dependency and then be removed from the runtime classpath.

    MRESOLVER-8 and MRESOLVER-9 also appear relevant. MRESOLVER-10 is complete, and Maven 4 already supports transitive dependency management. PR #2000 seems complementary because it handles Maven core exports through plugin dependency management, but it does not address the root request and scope-selection difference by itself.

    I can work on this with the following plan:

    1. Establish the behavior with regression tests

    Add focused integration tests covering:

    • A plugin with a direct test dependency.
    • A plugin with a direct provided dependency.
    • A core extension with the same cases.
    • A direct test dependency conflicting with a transitive compile dependency on the same artifact.
    • The equivalent provided versus transitive compile case.
    • Consumer-specified <plugin><dependencies> overrides.
    • Maven 3 and Maven 4 personality behavior.

    The tests would assert both the collected graph and the actual plugin/extension class realm.

    2. Verify the Resolver boundary

    Confirm whether the current ScopeDependencySelector.fromDirect(...) behavior is sufficient for both request forms.

    If dependency selection still occurs before managed scope or optionality is applied, the corresponding Resolver behavior should be fixed and tested separately rather than worked around inside Maven core.

    3. Unify Maven 4 plugin and extension resolution

    Prefer using the Maven 4 dependency resolver API and an explicit plugin resolution scope for both plugins and core extensions.

    The implementation must preserve:

    • Plugin dependency overrides.
    • Optional dependencies and exclusions.
    • Repository and mirror handling.
    • Existing dependency graph transformers and filters.
    • Plugin and extension realm cache behavior.
    • Maven core artifact filtering covered by MNG-5783.

    I would avoid changing the global repository-session selector because that could affect ordinary project dependency resolution.

    4. Define compatibility explicitly

    The historical implementation selected behavior according to the plugin's Maven prerequisites. I would not reuse its old version threshold without agreement because it no longer represents the current Maven 4 compatibility boundary.

    Possible boundaries include:

    • Corrected behavior only with Maven 4 personality.
    • A plugin requiredMavenVersion boundary.
    • Another explicit compatibility switch.

    5. Validate existing behavior

    In addition to the new regression tests, run the existing plugin and extension ITs, particularly:

    • mng-5783-plugin-dependency-filtering
    • mng-5771-core-extensions
    • mng-4091
    • mng-4331

    Then run the full Maven build and core integration-test suite.

    Proposed delivery

    I suggest splitting this into:

    1. A regression-test PR defining the expected behavior.
    2. A Resolver PR only if the tests prove a Resolver change is still required.
    3. A Maven core PR unifying plugin and core-extension resolution.

    Before I start, should MNG-6135 be handled as part of MNG-8559/#10668, and which compatibility boundary would you prefer? I can begin with the test-only PR once that direction is confirmed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:critical

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions