Skip to content

[MNG-7266] Remove maven-compat module #8177

Open

Description

@jira-importer

Tracking issue for removing the maven-compat module. Opened as MNG-7266 by Guillaume Nodet, part of #7952 (remove old deprecated code); #9185 made the module optional for core itself. The original PR #1487 is closed as stale, and the work below is the input for a fresh one.

Related: #9943 (restore Maven 3 compatibility), MPLUGIN-377 (drop legacy APIs in plugin-tools), #12709 (plugin baseline), #13085 (release plan).

Measured on 2026-09-19 against the stock 3.9.16 and 3.10.0-rc-1 distributions. The source scan covers master 00a35a9377 and the default and live maintenance branches of 87 apache/maven* repositories, as of 2026-10-05.

Maven 3.9 and 3.10

The runtime doesn't need the module. With lib/maven-compat-*.jar deleted from both distributions, clean deploy site passes on a reactor that uses toolchains, compiler 3.16.0, surefire 3.5.4, jar, javadoc, source, enforcer, dependency, plugin-plugin 3.15.1, install, deploy, and site 3.21.0 with the project-info reports.

Three released plugins do need it, always for the same reason: they inject a maven-core interface whose only implementation is in maven-compat, so Guice injects null (null returned by binding at LocatorWiring … is not @Nullable). The fixes are on their master branches and verified on the same compat-less distributions:

Plugin Released version, without the jar master snapshot, without the jar Release
project-info-reports 3.9.0: every report fails (legacy RepositorySystem) 3.9.1-SNAPSHOT: six reports render 3.10.0 (MPIR-477), #13085
dependency-plugin 3.11.0: dependency:get fails (legacy RepositorySystem in GetMojo) 3.11.1-SNAPSHOT a9176af4: get, copy, tree, analyze, resolve-plugins, list-repositories pass 3.12.0 (MDEP-858), #13085
doap-plugin 3.0.0-M1: doap:generate fails (ArtifactResolver, MavenProjectBuilder, RepositoryMetadataManager) 3.0.0-M2-SNAPSHOT c34d476: generate writes the RDF files 3.0.0-M2, #13085

A scan of the latest release tag of 81 apache/maven-* repositories found no other plugin that uses a maven-compat class or one of those interfaces in src/main. plugin-tools 3.16.0 referenced PathTranslator from maven-script-ant without ever looking it up; apache/maven-plugin-tools#1200 removed the reference. Outside plugins, apache/maven-shared-io is the only library that still uses the Maven 2 API in src/main (ArtifactResolver, WagonManager).

Two things stay as they are on 3.x. The distribution keeps bundling the jar, because third-party plugins written against the Maven 2 API still need it and Maven3CompatDependenciesValidator warns their users. The test-scoped maven-compat in plugin POMs (checkstyle, javadoc, project-info-reports, release, reporting-exec, war) is a harness question: maven-core older than 3.9.12 needs the compat RepositorySystem to boot the test container (#12709). It doesn't affect users; all six removals are merged (see the tasks).

Maven 4

Maven core itself doesn't use compat: impl/**/src/main has no reference to its classes. Three things do.

The distribution carries 64 classes that were in maven-core on 3.9.x. Plugins written for Maven 3 never declared maven-compat for them, so removing the module breaks them at runtime:

Classes Moved by Plugins that use them in src/main
org.apache.maven.toolchain.* (16 classes, bridged onto the v4 ToolchainManager by compat's ToolchainManagerFactory) #9888, 4.0.0-rc-3 surefire, javadoc, pmd, jdeps, jdeprscan, jarsigner, jlink, jmod, invoker, artifact-plugin, toolchains-plugin, compiler-plugin 3.x, jar-plugin 3.x
ArtifactRepositoryMetadata, AbstractRepositoryMetadata, AbstractArtifactMetadata, RepositoryMetadata, ProjectArtifactMetadata, RepositoryMetadataManager, PluginManager #9185 maven-plugin-plugin LegacySupport, maven-site-plugin SiteDescriptorArtifactMetadata, maven-dependency-plugin ResolverUtil, enforcer RequirePluginVersions

The compiler 3.x line is why impl/maven-cli needs compat at test scope: its invoker tests run verify on a sample project, and the compiler plugin fails with ClassNotFoundException: org.apache.maven.toolchain.ToolchainManager without it.

The core ITs. 21 IT-plugin sources under its/core-it-support use compat classes (ArtifactResolver, WagonManager, ArtifactRepositoryFactory, the v3 toolchain API, ArtifactInstaller, ArtifactDeployer, MavenProjectBuilder, RuntimeInformation), in core-it-plugins/* and core-it-toolchain, and so do the fixtures mng-3652, 4207, 5445, 6759, and gh-11314. 29 POMs declare maven-compat; 18 of them belong to modules that use no compat class and only reach MavenProject through it: the 14 maven-it-plugin-core-stubs/*, maven-it-plugin-touch, -fork, -configuration, and -project-interpolation.

Core wiring. apache-maven/pom.xml bundles the module, extension.xml exports it, Maven3CompatDependenciesValidator only warns, and DefaultLifecycles keeps a shim for compat's EmptyLifecycleExecutor.

Tasks

The 3.x releases come first because they unblock users today; the Maven 4 groups follow the dependencies between them.

Maven 3.x plugin releases

Maven 4: decide

Maven 4: move what Maven 3 plugins still need into maven-core

  • The v3 toolchain bridge (org.apache.maven.toolchain.*, ToolchainManagerFactory). Every dependency it uses is already a maven-core dependency and the package is already exported, so the move is mechanical; the @Priority(10) override of the v4 ToolchainManager has to move with it.
  • The seven metadata and manager classes, or fix the four plugins instead: site descriptor metadata as an attached artifact, drop LegacySupport in maven-plugin-plugin (unneeded since Resolver 1.9), filter in dependency ResolverUtil without ProjectArtifactMetadata, enforcer on BuildPluginManager.

Maven 4: core ITs

Maven 4: core cleanup

  • apache-maven/pom.xml: stop bundling.
  • impl/maven-cli/pom.xml: drop the test-scope dependency (after the toolchain move).
  • extension.xml: drop the org.apache.maven:maven-compat export.
  • Maven3CompatDependenciesValidator: warning to error.
  • DefaultLifecycles: remove the EmptyLifecycleExecutor shim.
  • Root POM, BOM, compat/pom.xml: drop the module.

Not verified: whether a plugin-declared maven-compat loads in a plugin realm once core stops exporting it, and the roughly 60 other Apache projects that declare it in a plugin POM.

Activity

  1. jira-importer commented on Apr 15, 2024

    @jira-importer
    Author

    Tamas Cservenak commented

    Maven-core module never depended on maven-compat so am a bit confused

  2. jira-importer commented on Apr 15, 2024

    @jira-importer
    Author

    Tamas Cservenak commented

    But if the idea is to drop maven2 support, I am for it, although unsure we have no plugin depending on maven-compat. Plus, I kinda remember that some plugin testing does depend on it...

  3. jira-importer commented on Apr 15, 2024

    @jira-importer
    Author

    Romain Manni-Bucau commented

    Let's drop it, worse case we compensate it later if really bothering for some plugin but shouldnt now.

  4. jira-importer commented on Apr 15, 2024

    @jira-importer
    Author

    Tamas Cservenak commented

    Drop it, maven-compat provides "compat components" for maven2 plugins, and Maven3 was there to provide "transitioning". Maven4 should NOT care about maven2 plugins.

  5. jira-importer commented on Apr 15, 2024

    @jira-importer
    Author

    Slawomir Jaranowski commented

    In more of cases it is needed by tests in runtime, when used interfaces like:

    • org.apache.maven.project.ProjectBuilder

    also maven-plugin-testing-harness bellow version 4.0.0-alpha-2 require it in classpath.

  6. added
    priority:major
    on Jul 6, 2025
  7. modified the milestones: , 4.x on Jul 7, 2025
  8. deleted a comment from jira-importer on Sep 19, 2026
  9. added
    dependencies
    and removed
    priority:major
    on Sep 19, 2026
  10. self-assigned this
    on Sep 19, 2026
  11. removed this from the 4.x milestone on Sep 19, 2026
  12. removed their assignment
    on Oct 7, 2026
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

    dependenciesmaintenance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions