You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "slachiewicz (via GitHub)" <gi...@apache.org> on 2026/09/30 14:41:17 UTC
[I] Port the shared components to the Maven 4 API [maven]
slachiewicz opened a new issue, #13302:
URL: https://github.com/apache/maven/issues/13302
### Description
Tracks porting the Maven shared components from the Maven 3 API (`MavenProject`, `org.apache.maven.artifact`, `maven-compat`) to the Maven 4 API at 4.0.0-rc-7. The aim is to measure impact before any release: what ports cleanly, where the v4 API has no equivalent, and which components are better retired than ported.
Each component gets a draft PR from an `agent/mvn4-api` branch that builds with Maven 4 only (`maven4-build: true`, version taken from the `maven-gh-actions-shared@v5` default). Findings for each component are kept in one comment below, updated as the work moves; this table is the summary.
maven-archiver and maven-filtering master are already on the Maven 4 API and serve as the reference.
| Component | Maven 3 imports | PR | Status |
|---|---|---|---|
| maven-reporting-exec | 21 | | not started |
| maven-common-artifact-filters | 16 | | not started |
| maven-dependency-analyzer | 14 | | not started |
| maven-dependency-tree | 12 | | not started |
| maven-reporting-impl | 8 | | not started |
| maven-shared-jar | 4 | | not started |
| maven-mapping | 1 | | not started |
| maven-reporting-api | `MavenReport` interfaces | | not started |
| maven-shared-utils | 0 | | CI only |
| maven-file-management | 0 | | CI only |
| maven-invoker | 0 | | CI only |
| maven-jarsigner | 0 | | CI only |
| maven-script-interpreter | 0 | | CI only |
| maven-shared-resources | 0 | | CI only |
| maven-archiver | done | | CI still pins rc-6 |
| maven-filtering | done | | CI still pins rc-6 |
Out of scope: maven-verifier (superseded by maven-executor), maven-shared-incremental (retirement vote open), maven-shared-io (retired).
The CI change supersedes apache/maven-dependency-tree#145 and apache/maven-shared-resources#87, which add Maven 4 to the matrix without making it the only build.
Related: #12709 (minimum Maven baseline).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919808571
> Maven 4.0.0 is not out: cannot we wait a little bit before creating double maintenance? I know it is funny to use AI and burn tokens, but it's not funny to augment the maintenance
@hboutemy its to validate where we are with Maven 4 API, if we have some blockers, missing features. Looking at results - I don't have apetite to release any new Maven 4 only component/plugin but few design things we need to take.
Next step after collecting results, in pararel to design decisions is to simplify/move away from deprecated or soon to be deprecated iun V3 api to simplify future Maven 4 migration.
For Doxia i've identifued also few points that needs more effort.
I also remember about Your's proposal to move V4 from master to the dedicated branches to focus on V3 improvements instead (to run on Maven 3.10 and Maven 4)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5914123773
### maven-doxia-sitetools
PR: apache/maven-doxia-sitetools#701. Status: **ported**, 3.0.0-SNAPSHOT, Java 17; usable only at Maven 4 runtime.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 68 tests before and after, 0 failures: site-model 32, integration-tools 16, site-renderer 16, scm-context 4. Spotless clean.
**Where the Maven API lives:** doxia-integration-tools uses it throughout. doxia-site-renderer uses it in one place, the skin artifact and its prerequisite version check. site-model, skin-model and scm-context are Maven-free.
**Public API changes**
- `SiteTool.getSiteModel(File, Locale, MavenExecutionRequest, MavenProject, List<MavenProject>, RepositorySystemSession, List<RemoteRepository>)` → `(File, Locale, Project, List<Project>, Session, List<org.apache.maven.api.RemoteRepository>)`.
- `SiteTool.getSkinArtifactFromRepository` takes a `Session` and returns `DownloadedArtifact`.
- `SiteRenderer.createContextForSkin(Artifact, …)` → `(Session, DownloadedArtifact, …)`; `SiteRenderingContext.get/setSkin` → `DownloadedArtifact`.
- Removed the already-deprecated 6-argument `getSiteModel` and `getInterpolatedSiteDescriptorContent(Map, MavenProject, String)`.
- Behaviour: `${project.*}` in `site.xml` now interpolates against the v4 `Model`, so `MavenProject`-only getters (`getBasedir`, …) stop resolving; `${project.basedir}` is added explicitly. The modules menu also reads `<subprojects>` (POM 4.1.0).
**Gaps**
- DI stays on `javax.inject`/Sisu: the components depend on Doxia and Plexus beans (`Doxia`, `ParserModuleManager`, `VelocityComponent`, `I18N`, …) that only exist as Sisu components. **Not run inside a real Maven 4 build.**
- No static version parser: the skin prerequisite check needs `Session.parseVersionConstraint`, which is why `Session` leaks into the renderer API.
- No v4 equivalent of `LocalRepositoryManager.find(...).isAvailable()` or `ArtifactNotFoundException`; the port approximates with `getPathForLocalArtifact` and `ResultItem.isMissing()`.
- Test support: `ApiRunner.createSession()` (maven-impl rc-7) registers no transporter, so tests can't download anything and now use a seeded local repo. The real download path and the missing-artifact locale fallback have no automated coverage. There is no public `Project` implementation for tests, so a hand-written stub replaces `MavenProjectStub`.
**Consumers that break:** maven-site-plugin (`AbstractSiteRenderingMojo`, `AbstractSiteDescriptorMojo`, `SiteMojo`), maven-reporting-impl (`AbstractMavenReport`), mojohaus clirr-maven-plugin (`ClirrReport`), and mojohaus versions-test (`MockUtils`, hence versions-maven-plugin tests). All of them run on the Maven 3 API and have no v4 `Session` to pass.
**Recommendation:** split. Keep site-model, skin-model and a `Path`-based renderer on the 2.x line for Maven 3 consumers. Ship integration-tools as a separate Maven 4 release, first in the order sitetools → maven-site-plugin → reporting-impl → reporting-exec.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913668334
### maven-filtering
PR: apache/maven-filtering#411 (CI pin only)
Already on the Maven 4 API on master. CI pinned `maven4-version: 4.0.0-rc-6` while the project compiles against rc-7 since apache/maven-filtering#402; the PR drops the pin.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 137 tests, 0 failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913667919
### maven-archiver
PR: apache/maven-archiver#416 (CI pin only)
Already on the Maven 4 API on master. CI pinned `maven4-version: 4.0.0-rc-6` while the project compiles against rc-7 since apache/maven-archiver#408; the PR drops the pin.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 97 tests, 0 failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913665193
### maven-shared-utils
PR: apache/maven-shared-utils#442 (CI only)
No Maven API in `src/main`; nothing to port. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 803 tests, 0 failures, 19 skipped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913952029
### maven-common-artifact-filters
PR: apache/maven-common-artifact-filters#130. Status: **ported, one feature removed**, 4.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 231 tests before, 226 after, 0 failures. Six tests covered the removed `actTransitively`; one is new. Spotless clean.
**Public API changes**
- `ArtifactFilter` → `Predicate<org.apache.maven.api.Dependency>` in `Pattern{In,Ex}cludesArtifactFilter`, `Strict*`, `ScopeArtifactFilter` and `ArtifactIncludeFilterTransformer`.
- `collection.*` filters work on `Set<Dependency>` instead of `Set<Artifact>`.
- `Pattern{In,Ex}cludesArtifactFilter(Collection, boolean actTransitively)` removed.
- `ArtifactTransitivityFilter(Artifact, ProjectBuildingRequest, ProjectBuilder)` → `(Session, Artifact)`, collecting via `TEST_RUNTIME`; this approximates the old project-build resolution.
- `resolve.Node.getDependency()` returns the immutable `org.apache.maven.api.model.Dependency`.
- The `EclipseAether*` transformers stay on the resolver API; nothing in `org.apache.maven.api` models exclusions on a `DependencyFilter`.
**Gaps**
- No dependency trail or parent link on `Artifact`, `Dependency` or `Node`, so `actTransitively` is removed. This is the largest loss; maven-assembly-plugin `useTransitiveFiltering` depends on it.
- Version ranges: `VersionParser` is only reachable through a `Session`, and filters are built without one; the port uses resolver-util `GenericVersionScheme`.
- `type`, `scope` and `optional` live only on `Dependency`, so every filter moves from `Artifact` to `Dependency`.
- No public factory for `Dependency`, `Type` or `Version` without a `Session`; tests and consumers need stubs or Mockito.
- The new scopes (`COMPILE_ONLY`, `TEST_ONLY`, `TEST_RUNTIME`) have no defined behaviour in `ScopeArtifactFilter`; they are included, like unknown scopes before.
**Consumers that break (compile):** maven-dependency-plugin, maven-assembly-plugin, maven-javadoc-plugin (`ResourceResolver`), maven-project-info-reports-plugin, maven-remote-resources-plugin, maven-surefire-common.
**Recommendation:** port for 4.0.0 alongside a 3.x line, once a parent-aware replacement for `actTransitively` is agreed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5914183655
Build tooling: the spotless-maven-plugin warning is reported upstream as diffplug/spotless#3121.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913975633
### maven-dependency-tree
PR: apache/maven-dependency-tree#149. Status: **ported, verbose detail reduced**, 4.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → unit tests 2 before, 10 after, 0 failures; spotless clean. ITs (`-P run-its`): 6 passed, 4 failed **both before and after the port**. `verbose`, `verbose-war`, `maven-version` and `display-optional-information` fail on unported master too, because Maven 4 resolves `classworlds:1.1` where the expected output says `1.1-alpha-2`. That is a Maven 4 resolution change; the expected files were not rewritten.
**Largely redundant with the v4 API.** `src/main` shrinks by 968 lines and grows by 276.
- Both builders become thin wrappers over `DependencyResolver.collect(...)`, verbose via `verbose(true)`.
- The verbose format already exists in core: `DefaultNode.asString()` in maven-impl is a near copy of `VerboseDependencyNode.toNodeString()`, without "scope not updated to", "(optional)" and "omitted for cycle/exclusion".
- `Node.accept`, `Node.filter` and `Node.stream` cover plain visiting and filtering.
**Still unique to this library:** `getParent()` (`api.Node` has no parent link; needed by `AncestorOrSelfDependencyNodeFilter` and the filtering and building visitors), the tree-drawing `SerializingDependencyNodeVisitor`, and the composable filters.
**Public API changes**
- `buildDependencyGraph(ProjectBuildingRequest, ArtifactFilter)` and `collectDependencyGraph(...)` → `(Session, Project, Predicate<Dependency>)`; the deprecated `reactorProjects` overload is removed.
- `DependencyNode.getArtifact()` → `org.apache.maven.api.Artifact`; `getExclusions()` → `List<org.apache.maven.api.Exclusion>`; new `getDependency()`.
- Removed: `getPremanagedVersion()`, `getPremanagedScope()`, `getVersionConstraint()`, the `DependencyCollectorRequest` selector, transformer and config properties, `VerboseDependencyNode`, `ConflictData`, `VerboseJavaScopeSelector`, `DirectScopeDependencySelector`.
**Gaps**
- Premanaged version and scope, version constraint, conflict winner and ignored scope have no structured accessor on `api.Node`; they exist only inside the `asString()` text.
- A custom `DependencySelector` or `DependencyGraphTransformer` can't be set; `DependencyResolverRequest` has only `verbose`.
- No route from `api.Session` to a `RepositorySystemSession` for plugins: `InternalSession` is in maven-impl, which maven-core does not export to plugin realms. So falling back to the Resolver API is not possible.
**Consumers that break (compile):** maven-dependency-plugin (`TreeMojo`, its own `BuildingDependencyNodeVisitor`, and the DOT, TGF, GraphML and JSON serializers) and maven-project-info-reports-plugin (`DependenciesReport`, `DependencyConvergenceReport` and renderers). Both rely on premanaged and conflict data.
**Recommendation:** port as a thin layer (parent links, serializer, filters) and keep 3.x for Maven 3 plugins. Don't promise premanaged or conflict data until `api.Node` exposes it; that is the API request to raise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913796855
### maven-shared-jar
PR: apache/maven-shared-jar#182. Status: **ported**, 4.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 91 tests before and after, 0 failures; spotless clean.
**Public API changes**
- `RepositoryHashSearch.searchFileHash`/`searchBytecodeHash` (and `EmptyRepositoryHashSearch`): `List<org.apache.maven.artifact.Artifact>` → `List<org.apache.maven.api.Artifact>`.
- `EmbeddedMavenModelExposer` gains an injected `ModelXmlFactory` and reads the POM into the immutable v4 `Model`.
- `@Named`/`@Singleton`/`@Inject` move from `javax.inject` to `org.apache.maven.api.di`, so Sisu no longer discovers these components; they cannot be injected under Maven 3.
- `JarAnalyzer`, `JarData`, `JarClasses*`, `JarIdentification*` unchanged.
**Gaps**
- `maven-shared-components` parent sets `<proc>none</proc>`, so the `maven-api-di` index processor never runs; `META-INF/maven/org.apache.maven.api.di.Inject` is maintained by hand (as maven-filtering does). A new `@Named` class missing from it fails with "No binding".
- `ModelXmlFactory` is implemented only in `maven-impl`, so the model exposer needs a Maven 4 container; the v4 `MavenStaxReader` lives in `maven-support`, which is not API.
**Consumers that break:** maven-project-info-reports-plugin (`DependenciesReport` injects `JarClassesAnalysis`; `Dependencies`, `DependenciesRenderer` use unchanged types). It compiles, but under Maven 3 the component is no longer found.
**Improvements:** drops `javax.inject`, `sisu-maven-plugin`, `plexus-xml`, `maven-model`, `maven-artifact`.
**Recommendation:** port for Maven 4 plugins; keep a 3.x line while project-info-reports runs on Maven 3.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5914096491
### maven-reporting-impl
PR: apache/maven-reporting-impl#254. Status: **blocked**, compiles but cannot render. 5.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 3 unit tests pass (3 before); ITs 1 of 6 pass (6 before). Spotless clean. Only `setup-reporting-plugin`, which builds a v4 report mojo, passes.
- `use-as-direct-mojo*` (4 ITs): `A required class was missing … org/apache/maven/execution/MavenSession`. A v4 plugin realm does not see maven-core, and Doxia's `SiteTool`/`SiteRenderer` signatures need `MavenProject`, `RepositorySystemSession` and a Maven 3 `Artifact`.
- `use-as-site-report`: maven-site-plugin 3.22.0 fails with `Cannot cast CustomReportFactory to org.apache.maven.plugin.Mojo`, because the site plugin only accepts v3 mojos as reports.
**Public API changes**
- `AbstractMavenReport`: `extends AbstractMojo` → `implements org.apache.maven.api.plugin.Mojo`; `MavenProject` → `Project`; `MavenSession`/`MojoExecution` → injected v4 `Session`/`MojoExecution`; v4 `Log`.
- Removed the protected fields `reactorProjects`, `repoSession`, `remoteProjectRepositories`, `siteTool` and `siteRenderer`, in favour of `getReactorProjects()`, `getSiteTool()` and `getSiteRenderer()`.
- Subclasses must use `org.apache.maven.api.plugin.annotations` and maven-plugin-plugin 4.x.
- `AbstractMavenReportRenderer` unchanged.
**Gaps**
- Doxia site tools expose Maven 3 types, so they can't be called from a v4 mojo. See maven-doxia-sitetools (wave 2).
- Doxia components are Sisu components. v4 DI `@Inject` gives "No binding … SiteTool", and `Lookup.lookup(SiteTool.class)` does not see plugin-realm Sisu components.
- No v4 site or report lifecycle: maven-site-plugin looks reports up as v3 mojos.
- `org.apache.maven.api.Plugin` has no `getId()` (minor).
**Consumers that break:** every report plugin that extends `AbstractMavenReport`: site, surefire-report, jxr, changelog, changes, checkstyle, javadoc, pmd, project-info-reports, artifact, dependency, invoker, plugin-report.
**Recommendation:** keep reporting-impl on the Maven 3 API until doxia-sitetools and maven-site-plugin move. Porting in the order sitetools → site plugin → reporting-impl → reporting-exec is the only order that works.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913952913
### maven-doxia-converter
PR: apache/maven-doxia-converter#165 (CI only)
:white_check_mark: **Migration not needed:** no Maven API used.
**Blocked by the build, not the code.** Verified locally with Maven 4.0.0-rc-7, JDK 21: 23 tests pass, then BUILD FAILURE in `maven-shade-plugin:3.6.2:shade`. The dependency-reduced POM keeps `parent.relativePath` pointing at `pom.xml`, which Maven 4 rejects as FATAL because that resolves to the converter itself. 3.6.2 is the latest release; the fix is tracked in apache/maven-shade-plugin#813 and apache/maven-shade-plugin#843. The same break hits any shaded project whose parent is not in the reactor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913744834
### maven-reporting-api
PR: apache/maven-reporting-api#88 (CI only)
:white_check_mark: **Migration not needed:** no Maven API used. `src/main` imports only the Doxia sink API (`Sink`, `SinkFactory`), and the only dependency is `doxia-sink-api`.
Optional cleanup, not required for Maven 4: the Plexus lookup constant `MavenReport.ROLE` has no users in the plugins, shared components or Doxia; removing it would be a breaking change for a major release only.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → BUILD SUCCESS (no tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919281733
### Wave 3 findings
maven-build-cache-extension has its own comment above. Each port is a local branch `agent/mvn4-api`; the PRs are not opened yet.
#### Migration not needed
No Maven API in the library modules, so only CI changes (branch `agent/mvn4-api`, one commit "Build with Maven 4 only"; PRs not opened yet). Verified locally with `mvn verify`, Maven 4.0.0-rc-7, JDK 21:
- maven-jxr: 34 tests, 0 failures (only maven-jxr-plugin uses the Maven API).
- maven-wrapper: 34 tests, 0 failures (only maven-wrapper-plugin uses the Maven API).
- maven-archetypes: 18 archetype builds, 0 failures (only the archetype templates use the Maven API).
- maven-wagon: 1035 tests, 0 failures, 10 skipped.
- maven-executor: 62 tests, 0 failures, 4 skipped.
- maven-scm: 340 tests, 0 failures, 3 skipped (only maven-scm-plugin uses the Maven API).
#### Ported libraries
<details><summary><b>maven-surefire</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-SNAPSHOT, Java 17 (maven-surefire-common only).
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → before: 1487 tests in 12 modules, 0 failures (maven-surefire-common 867); after: maven-surefire-common 868 (865 with `E2ETest` excluded, 0 failures), other library modules unchanged. `E2ETest.endToEndTest` times out under machine load on the unmodified tree too (36 s against 30 s). maven-surefire-plugin, maven-failsafe-plugin and surefire-its are out of the reactor, so their 35 unit tests and all ITs did not run after. Spotless and RAT clean.
**Only maven-surefire-common uses the Maven API.** surefire-booter, -api, -extensions-api, -logger-api, -report-parser and the providers import none; they run in the forked test JVM, stay on `release 8`, and need no port.
**Public API changes** (maven-surefire-common)
- `AbstractSurefireMojo` implements `org.apache.maven.api.plugin.Mojo`; `getSession()`, `getProject()`, `getToolchainManager()` return v4 types; `MojoFailureException`/`MojoExecutionException` both become the unchecked `MojoException`.
- `getPluginDescriptor()` removed; `getPluginArtifactMap()`/`getProjectArtifactMap()` return v4 artifacts, computed lazily.
- `SurefireDependencyResolver` takes a `Session`; `isWithinVersionSpec` is no longer static.
- Parameter `additionalClasspathDependencies` becomes `List<AdditionalClasspathDependency>`, a new bean with the same XML, because the immutable v4 model cannot be populated from configuration.
- DI moves to `org.apache.maven.api.di`; Sisu no longer discovers `ProviderDetector` or `SurefireDependencyResolver`.
**Gaps**
- The library holds the mojo base class, so `SurefireMojo` and `IntegrationTestMojo` cannot stay on Maven 3 while it moves: library and plugins must be ported together.
- No `MavenExecutionRequest` in the API: `-e` and `-ff`/`-fae`/`-fn` no longer reach the forked JVM.
- No v4 counterpart for `${plugin.artifactMap}`, `${project.artifactMap}`, `${plugin}`, `${basedir}`, `${session.parallel}`.
- No static version parser: `Session.parseVersionRange` needs a session.
- No `ArtifactHandler`: `isAddedToClasspath()` becomes `!Type.getPathTypes().isEmpty()`.
- `ScopeArtifactFilter` differs: with `classpathDependencyScopeExclude` = `provided` or `system`, the v3 filter excludes nothing and the v4 one excludes that scope.
- `LocationManager` (plexus-java) is a Sisu component; created with `new`.
- Depends on the unreleased maven-common-artifact-filters 4.0.0-SNAPSHOT (apache/maven-common-artifact-filters#130).
**Consumers that break:** maven-surefire-plugin, maven-failsafe-plugin, surefire-its in this repository. Outside it, only the maven-plugin-plugin `mplugin-305_*` ITs extend `AbstractSurefireMojo`, and they pin 3.1.0.
**Improvements:** maven-surefire-common drops maven-core, maven-plugin-api, maven-artifact, maven-model, maven-resolver-api/-util, `javax.inject`, `org.eclipse.sisu.plexus`.
**Recommendation:** port the library only together with maven-surefire-plugin and maven-failsafe-plugin, and keep a 3.x line. The API first needs the request flags on `Session`, a session-free version parser, and test fixtures for `Dependency` and `Project`.
</details>
<details><summary><b>maven-release</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-SNAPSHOT, Java 17. The library modules (`maven-release-api`, `maven-release-manager`, both policies) compile against `org.apache.maven.api` only and pass; the plugin is a consumer and is excluded. The immutable model forced a redesign of the POM-rewriting layer, and plugin/extension/report artifact resolution is reduced.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → before 876 tests (api 0, manager 769, odd-even 11, semver 78, plugin 18), 0 failures, 18 skipped (manager); after 791 (api 0, manager 700, odd-even 12, semver 79), 0 failures, same 18 skipped. Spotless and checkstyle clean. The manager lost 88 tests and gained 19 (net -69). The 88 are the tests of the removed Maven 3 model subclasses, almost all asserting `UnsupportedOperationException` for methods that no longer exist: `DomTripDependencyTest` 24, `DomTripParentTest` 11, `DomTripExtensionTest` 10, `DomTripDependencyManagementTest` 6, and 37 of the 45 in `DomTripBuildTest`. The behaviour that was real (get/set version, group and artifact id, element name) is covered by the 10 tests of `DomTripMavenCoordinateTest`; the parent test that added or removed a missing `<version>` element is not carried over. The other 9 new tests are 3 in `DomTripBuildTest`, 5 in `DependencyInjectionTest` and 1 `DiIndexTest` (plus one `DiInd
exTest` in each policy module). The plugin's 18 unit tests and the `run-its` profile (it lives in the plugin module) were not run, before or after: the plugin does not compile against the ported libraries, so there is no "after".
**Public API changes**
- `ReleasePhase.execute/simulate`, `ResourceGenerator.clean`, `Release*Request.get/setReactorProjects`: `List<MavenProject>` → `List<org.apache.maven.api.Project>`.
- `ReleaseEnvironment.getSettings()` returns `org.apache.maven.api.settings.Settings`; new `Session getSession()` (phases need it for `collectDependencies` and the XML factories), `DefaultReleaseEnvironment.setSession`.
- `ReleaseDescriptor.getOriginalScmInfo`, `ReleaseDescriptorBuilder.addOriginalScmInfo` and the modello-generated descriptor: `org.apache.maven.model.Scm` → `org.apache.maven.api.model.Scm`. `IdentifiedScm` is immutable: `new IdentifiedScm(Scm, id)`, no setters (the v4 `Scm` has a protected builder constructor, so it can still be subclassed).
- `VersionPolicyRequest.get/setMetaData`: `artifact.repository.metadata.Metadata` → `org.apache.maven.api.metadata.Metadata`.
- `Version.compareTo` no longer throws `VersionComparisonConflictException` (one ordering instead of two; the class stays, never thrown). New `versions.ArtifactKeys` (`versionlessKey`, `isSnapshot`, `SNAPSHOT_VERSION`, `VERSION_FILE_PATTERN`) replaces `ArtifactUtils`.
- `DefaultReleaseManagerListener(Log)` → `(org.slf4j.Logger)`; the API has no `Log`.
- `ModelETL.getModel()` returns the new `PomModel`; `ModelETLRequest.setProject(Project)`; `AbstractRewritePomsPhase.transformScm` takes `(Project, PomModel, Model originalModel, ...)`. `DomTripDependency/Extension/Parent/DependencyManagement/PluginManagement/Reporting/ReportPlugin` are gone; the other DomTrip classes implement the new `PomModel`, `PomBuild`, `PomPlugin`, `PomProfile`, `PomScm` views instead of subclassing Maven 3 model classes.
- `ScmRepositoryConfigurator.getConfiguredRepository(..., Settings)` takes the v4 `Settings`. `AbstractMavenExecutor`, `ForkedMavenExecutor`, `InvokerMavenExecutor` take a `SettingsXmlFactory`; `getSettingsWriter()` → `getSettingsXmlFactory()`. `PomFinder(Logger, ModelXmlFactory)`. `GenerateReleasePomsPhase` takes a `ModelXmlFactory` instead of `ModelInterpolator`. `MavenCrypto(SecDispatcher)` on plexus-sec-dispatcher 4.2.0.
- `@Named`/`@Singleton`/`@Inject` move to `org.apache.maven.api.di`, `@Description` is dropped; Sisu no longer discovers any component. `DefaultStrategy`, `DefaultVersionPolicy`, `DefaultNamingPolicy` become `@Named("default")` (see traps below).
**Design changes forced by the immutable model**
- The DomTrip layer was `DomTripModel extends Model` plus a dozen subclasses of Maven 3 model classes, overriding the setters they needed and throwing `UnsupportedOperationException` for the rest. The v4 `Model` cannot be edited in place, so the rewrite phases now edit the DOM through five small `Pom*` views (`setVersion`, `setScm`, coordinate `setVersion`, `Properties`). This is a redesign, not a port: the `transform` package goes from 2151 to 1598 lines, including the new interfaces.
- `GenerateReleasePomsPhase` built the release POM by cloning the `MavenProject` and calling setters; it now derives the release model with `Model.newBuilder(effective, true)`.
**Gaps**
- `MavenProject.getOriginalModel()` (9 uses) has no equivalent. The original model is read again from the POM file with `ModelXmlFactory`. Consequence: `generate-release-poms` runs after `rewrite-poms-for-release`, so it now reads plugin, extension and plugin-dependency declarations that are already rewritten; Maven 3 kept the load-time snapshot.
- No plugin, extension or report artifact API and no `RELEASE`/`LATEST` resolution (`MavenProject.getPluginArtifacts/getReportArtifacts/getExtensionArtifacts` and their maps). Versions come from the effective model. A plugin, report plugin or extension without a version stays without one in the release POM (Maven 3 wrote the resolved version; one expected file had `<version>RELEASE</version>` and was changed), and `CheckDependencySnapshotsPhase` cannot see a snapshot behind it.
- `Session.collectDependencies(project, TEST_COMPILE ∪ TEST_RUNTIME)` replaces `getArtifacts/getDependencyArtifacts`. It throws when any dependency POM cannot be read, where Maven 3 still listed the declared artifact; the code falls back to the declared coordinates and an empty transitive set.
- `MavenProject.getParentArtifact()`: only `Project.getParent()`, present when the parent project was built.
- No `ModelInterpolator`. The super POM path unaligning in `GenerateReleasePomsPhase` uses plexus-interpolation over the v4 model (kept as a dependency).
- `api.Version` needs a `VersionParser` service, but `Version` and `DefaultVersionInfo` are plain value classes. They use the resolver's `GenericVersionScheme` (new direct dependency `maven-resolver-util`); the `ComparableVersion` cross-check is dropped.
- No crypto API. `MavenCrypto` uses plexus-sec-dispatcher 4.2.0, whose legacy dispatcher can only decrypt. `encryptSettings` needs a v4 `master` dispatcher configuration; without one the passwords go unencrypted into the temporary `settings.xml` for the forked build (the failure was already swallowed in Maven 3).
- `maven-scm-manager-plexus` gets its providers through Sisu map injection, which the v4 container does not do. `ReleaseScmManager` reads `META-INF/sisu/javax.inject.Named` itself and instantiates the providers that have a public no-argument constructor.
- The parent sets `<proc>none</proc>`, so `META-INF/maven/org.apache.maven.api.di.Inject` is maintained by hand in all three modules; `DiIndexTest` fails when a `@Named` class is missing (checked by removing `DefaultStrategy`).
- Not verified: injection of `Prompter` and `SecDispatcher` in a real Maven 4 plugin container. `ApiRunner.createSession` binds neither, so the tests bind them. No release was run end to end.
- Traps: a bare `@Named` is the empty key in `Map<String, T>` injection, not `default` as in Sisu (`Policy 'default' is unknown, available: []`); `model.with().parent(null).build()` does not clear the parent (null is ignored on a builder from `with()`; use `withParent(null)` or `Model.newBuilder(model, true)`); `DependencyResolver.collect` needs a `ProjectManager` service that only maven-core provides.
- Release POM content changes with the v4 effective model: no `repositories`/`pluginRepositories` (the central declarations are no longer in the model) and three extra properties (`project.build.outputTimestamp`, `project.build.sourceEncoding`, `project.reporting.outputEncoding`). 58 expected files under `src/test/resources/projects/generate-release-poms` were adjusted for this.
- Tests: there is no project builder outside maven-core. The harness builds `TestProject` from the `ModelBuilder` of maven-impl and resolves against a local repository seeded from `src/test/remote-repository` (marked `>central=`), with a stub `ProjectManager`. It uses `DefaultDependencyCoordinates` and `InternalSession` from maven-impl, which are internal classes.
**Consumers that break:** maven-release-plugin (same repository): 15 compile errors in 8 classes, measured by compiling its sources against the ported jars. `AbstractReleaseMojo:131` (`setSettings` takes the Maven 3 `Settings`); `CleanReleaseMojo`, `RollbackReleaseMojo`, `PrepareReleaseMojo`, `BranchReleaseMojo`, `PerformReleaseMojo`, `UpdateVersionsMojo` (`setReactorProjects(getReactorProjects())` with `List<MavenProject>`, and `new DefaultReleaseManagerListener(getLog())` with `Log`); `AbstractScmReadReleaseMojo:145` and `UpdateVersionsMojo:124` (`addOriginalScmInfo` with the Maven 3 `Scm`). At runtime its `@Inject ReleaseManager` and `ScmManager` would also find no Sisu components. maven-scm-publish-plugin, by reading: `AbstractScmPublishMojo:352` passes a Maven 3 `Settings` to `getConfiguredRepository`, and it injects `ScmRepositoryConfigurator` with `javax.inject`. No other repository under the Apache Maven plugin repositories imports `org.apache.maven.shared.release`.
**Improvements:** drops `maven-core`, `maven-model`, `maven-model-builder`, `maven-artifact`, `maven-settings`, `maven-plugin-api`, `maven-repository-metadata`, `plexus-interactivity-api`, `plexus-cipher`, `plexus-sec-dispatcher` 2.0 (it clashed by coordinates with the 4.2.0 that maven-impl brings), `maven-scm-manager-plexus`, `javax.inject`, `org.eclipse.sisu.inject`, `sisu-maven-plugin`, and the test-only `plexus-testing`, `org.eclipse.sisu.plexus` and four resolver modules.
**Recommendation:** port the libraries for a Maven 4 release plugin, but only together with a Maven 4 port of the plugin. The API first needs a way to resolve plugin and extension versions and an original (file) model on `Project`; without them the release POM and the snapshot check are weaker than on 3.x. Keep the 3.x line for Maven 3 builds.
</details>
<details><summary><b>maven-enforcer</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-SNAPSHOT, Java 17. `enforcer-api` and `enforcer-rules` ported; 3 of 38 rules removed for lack of API; `maven-enforcer-plugin` and `maven-enforcer-extension` excluded from the reactor.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → before 300 tests (rules 276, plugin 24), 0 failures; after, library modules only: rules 347 (272 ported, 75 new), 0 failures. Spotless, checkstyle and RAT clean. ITs (154 invoker projects in the plugin module) cannot run after, because the plugin no longer builds. Removed tests: the 3 of the removed rules and 1 of a test-only `PluginParameterExpressionEvaluator` subclass.
**Public API changes**
- `enforcer-api`, the SPI third-party rules implement: `AbstractEnforcerRuleConfigProvider.getRulesConfig()` returns `org.apache.maven.api.xml.XmlNode` instead of `Xpp3Dom`. The deprecated `EnforcerRule`, `EnforcerRule2` and `EnforcerRuleHelper` are removed; they expose `PlexusContainer` and the Maven 3 `Log`. `AbstractEnforcerRule`, `EnforcerRuleBase`, `EnforcerLogger`, `EnforcerLevel`, `EnforcerRuleException`, `EnforcerRuleError` are unchanged.
- `enforcer-rules`: DI moves to `org.apache.maven.api.di`, so Sisu finds no rule. Rules take `Project`, `Session`, `ProjectManager`, `VersionParser` instead of `MavenProject`, `MavenSession`, `RuntimeInformation`, `PluginManager`, `RepositorySystem`.
- `utils.ExpressionEvaluator` no longer extends `PluginParameterExpressionEvaluator`; `${mojo.*}`, `${plugin.*}`, `${localRepository}` are not supported.
- Removed rules: `requireUpperBoundDeps`, `banDynamicVersions`, `requireProfileIdsExist`.
**Gaps**
- `Node` has no pre-managed version and no declared version constraint. `requireUpperBoundDeps` compares the pre-managed version and `banDynamicVersions` checks ranges and `LATEST`/`RELEASE` of transitive dependencies; a port would silently narrow both, so they are removed.
- `Session` has no requested (`-P`) profile ids: `requireProfileIdsExist` is removed.
- No original model on `Project`: five rules re-parse `pom.xml` through `ModelXmlFactory`.
- No resolved-artifact view of a project: `requireSameVersions`, `bannedDependencies`/`requireReleaseDeps` (`searchTransitive=false`) and `enforceBytecodeVersion` now run a resolution request.
- No public `ProfileActivationContext` or no-op `ModelProblemCollector`: `requireOS` carries hand-written implementations.
- `requirePluginVersions` is tested against mocks only; its check for versions from the default lifecycle bindings is not verified on Maven 4.
- Rule configuration from `<rules>` (Plexus `ComponentConfigurator` from `Xpp3Dom`) has no API equivalent; it belongs to the plugin port. Nothing ran end to end in a real Maven 4 build.
**Consumers that break**
- maven-enforcer-plugin (`EnforceMojo`, `DisplayInfoMojo`, `DefaultEnforcementRuleHelper`, `EnforcerRuleCache`) and maven-enforcer-extension (`AbstractMavenLifecycleParticipant`), both in this repository.
- mojohaus/extra-enforcer-rules: its 9 rules still compile against the unchanged SPI types, but inject `MavenProject`/`MavenSession` through `javax.inject`, so Maven 4 DI does not find them; it has to move with the plugin.
- Any third-party rule implementing `EnforcerRule`/`EnforcerRule2` or calling `EnforcerRuleHelper.getComponent`.
**Improvements:** `enforcer-api` drops everything but `maven-api-xml`; `enforcer-rules` drops maven-core, maven-artifact, maven-plugin-api, maven-model(-builder), maven-settings, maven-resolver-api/-util, `javax.inject`, `org.eclipse.sisu.plexus`, plexus-utils, plexus-xml.
**Recommendation:** do not release. The rules are usable only once maven-enforcer-plugin can configure and look up v4 rules, which is the larger half. Ask apache/maven for a pre-managed version and declared constraint on `Node` and requested profile ids on `Session` before dropping the 3 rules for good. Keep a 3.x line for Maven 3 and for extra-enforcer-rules.
</details>
<details><summary><b>maven-plugin-tools</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 5.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify -P run-its` with Maven 4.0.0-rc-7, JDK 21, library modules → api 61 unit + 15 IT before and after; generators 17 (1 skipped) before and after; annotations 37 before, 42 after (new: DI wiring, sources-jar resolution); 0 failures. Spotless clean. maven-plugin-plugin (12 unit, 32 ITs) and maven-plugin-report-plugin (3 unit, 12 ITs) were green before and are excluded from the reactor after.
Everything except the descriptor model moves to the Maven 4 API. `PluginDescriptor`, `MojoDescriptor` and `Parameter` stay on `org.apache.maven.plugin.descriptor` because the tools still write the Maven 3 `plugin.xml`.
**Public API changes**
- `PluginToolsRequest`: constructor `(Session, Project, PluginDescriptor)`; `getProject()` returns `Project`; `getDependencies()` is `Set<org.apache.maven.api.Artifact>`; `getSettings()` is the v4 `Settings`; `getRepoSession()`/`setRepoSession()` removed.
- `PluginUtils.isMavenReport(String, Session, Project)` replaces `(String, MavenProject)`; deprecated `GeneratorUtils.isMavenReport` removed; `toComponentDependencies` takes v4 `Dependency`.
- `PluginHelpGenerator`: `setMavenProject(Project)`; `setVelocityComponent` → `setVelocityEngine`.
- `MojoAnnotationsScannerRequest` takes `Session`, `Project` and v4 artifacts; `JavadocLinkGenerator`/`JavadocSite` take v4 `Settings`.
- `@Named`/`@Singleton`/`@Inject` move to `org.apache.maven.api.di`: Sisu no longer finds the extractors, scanners or converters, so they cannot be injected under Maven 3.
**Gaps** (rc-7)
- The descriptor model exists (`org.apache.maven.api.plugin.descriptor`, `PluginXmlFactory`), but `MojoDescriptor` has no `threadSafe`, `instantiationStrategy`, `executionStrategy` or `requiresReports`, `Parameter` has no `implementation` or `requirement`, and `PluginDescriptor` has no `dependencies`. It cannot carry a Maven 3 `plugin.xml`, so it cannot be the tools' internal model. There is also no plugin manager or descriptor lookup service.
- `MavenProject#getArtifacts()` has no `Project` equivalent; `Session#resolveDependencies(project, PathScope.MAIN_COMPILE)` returns paths only and covers compile and provided scope, not runtime.
- `MavenProject#getProjectReferences()` has no equivalent; projects are matched from `Session#getProjects()` by GAV.
- No `Dependency` factory outside a resolved graph; no `Version` factory outside a `Session`; `Settings` has no `getActiveProxy()`.
- Plexus components (`ArchiverManager`, `VelocityComponent`) cannot be injected through `api.di`; sources jars are unpacked with `java.util.zip` (with a zip-slip check), so only `*-sources.jar` is supported.
- `<proc>none</proc>` in the parent: the DI index files are maintained by hand; a new test fails when an entry is missing.
- `ProjectManager#getEnabledSourceRoots` is stubbed in tests; nothing ran the extractors end to end on a real Maven 4 project.
**Consumers that break**
- maven-plugin-plugin `DescriptorGeneratorMojo`, `HelpGeneratorMojo`; maven-plugin-report-plugin `PluginOverviewRenderer`, `GoalRenderer`. Both are excluded from the reactor.
- A Maven 3 plugin build cannot use these libraries at all: Maven 3.9 has no `Session`/`Project` API.
**Improvements:** drops maven-core, maven-settings, maven-resolver-api, `javax.inject`, `plexus-archiver`, `plexus-velocity`, `sisu-maven-plugin`. Still needs maven-plugin-api, maven-model, maven-artifact for the descriptor model.
**Recommendation:** do not release a "Maven 4 API" 5.0.0 while the public descriptor types are Maven 3. Decide first between a tools-owned descriptor model and dropping Maven 3 `plugin.xml` output; keep `maven-plugin-tools-3.x` as the line maven-plugin-plugin builds on.
</details>
<details><summary><b>maven-archetype</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 57 tests before (archetype-common 29, maven-archetype-plugin 28), 0 failures; after 30 in archetype-common (29 ported, 1 new), 0 failures, spotless clean. The plugin (28 tests, 33 integration test projects) is a consumer that does not compile against the ported library, so it is excluded from the reactor and its tests and ITs were not run after. `-Prun-its` before: 20 of 33 IT projects finished (all passed) when the 30-minute time box ended. For the code with no unit test (`FilesetArchetypeCreator`, POM rewriting) I generated an archetype from a 3-module fixture with both builds and diffed the output trees: identical apart from the version string and a timestamp, with `keepParent` true and false.
**Public API changes** (archetype-common)
- `ArchetypeGenerationRequest`: `MavenSession`, `RepositorySystemSession`, `RepositorySystem`, `ProjectBuildingRequest`, `ArtifactRepository` (local and remote) getters and setters are replaced by one `getSession()`/`setSession(org.apache.maven.api.Session)`; `getRemoteRepositories()` is now `List<org.apache.maven.api.RemoteRepository>`.
- `ArchetypeCreationRequest.project`: `MavenProject` → `org.apache.maven.api.Project`.
- `ArchetypeManager`, `ArchetypeDataSource`, `Downloader`, `ArchetypeArtifactManager`: `RepositorySystemSession` → `Session`, aether `RemoteRepository` → API `RemoteRepository`. `ArchetypeManager.archiveArchetype` no longer declares `DependencyResolutionRequiredException`.
- `PomManager` reads and writes the immutable `org.apache.maven.api.model.Model`. Constructors change: `DefaultPomManager(ModelXmlFactory)`, `DefaultOldArchetype(ArchetypeVelocity, ArchetypeArtifactManager, ModelXmlFactory)`, `DefaultFilesetArchetypeGenerator` takes `ArchetypeVelocity` instead of `VelocityComponent`, `DefaultArchetypeGenerator` drops `RepositorySystem`.
- `plexus-velocity` is gone; the new `ArchetypeVelocity` builds the engine with the settings `DefaultVelocityComponent` 2.4.0 applies (read from its bytecode) plus the former `VelocityConfigurator` settings. The `VelocityComponentConfigurator` extension point is lost.
- `@Named`/`@Singleton`/`@Inject` move to `org.apache.maven.api.di`; Sisu no longer discovers these components, so they cannot be injected under Maven 3.
**Gaps**
- No metadata resolution in the API. `RemoteCatalogArchetypeDataSource` now fetches `archetype-catalog.xml` through `TransportProvider`: no local repository cache, update policy or checksum check. The old lookup also matched a repository by the id of a repository it mirrors (`getMirroredRepositories()`); the API `RemoteRepository` has none, so only ids `archetype` and `central` match. Not exercised by a test (none existed).
- `RepositoryPolicy` cannot be set on a repository created with `Session.createRemoteRepository(id, url)`; the `archetypeRepository` URL used to get always-update and warn-on-checksum, it now gets the defaults. Mirror, proxy and authentication handling for it relies on the API resolving through `toResolvingRepositories`; not exercised.
- The v4 model reader rejects `<reports>` (project and profile) and plugin `<goals>` in strict mode; the Maven 3 reader accepted them. `DefaultPomManager` and `DefaultOldArchetype` read non-strict, so any unknown element is now accepted too. `MavenJDOMWriter` cannot read those elements from the v4 model and leaves them untouched in the file (new test `testAddParentKeepsLegacyElements`).
- `Model.Builder.parent(null)`/`modules(null)` on a builder made with `Model.newBuilder(model)` does not clear the value (null means inherit from base); `newBuilder(model, true)` is required. The first version of the port kept `<modules>` in the root archetype POM for this reason; the tests did not catch it, the fixture diff did.
- `maven-parent` sets `<proc>none</proc>`, so `META-INF/maven/org.apache.maven.api.di.Inject` is maintained by hand (14 classes).
- `ApiRunner.createSession` has no transporter. The tests register `file` and Apache HTTP factories with `@Provides @Named` on a class passed to `injector.bindImplicit`; that pulls `maven-resolver-transport-file` and `-apache` 2.0.23 into test scope.
**Consumers that break:** maven-archetype-plugin, in this repo (excluded from the reactor, not ported): `CreateProjectFromArchetypeMojo` (`setMavenSession`, `setRepositorySession`, `setRepositorySystem`, `setProjectBuildingRequest`, `setLocalRepository`, `setRemoteArtifactRepositories`), `IntegrationTestMojo` (`setMavenSession`, `Downloader.download`), `CreateArchetypeFromProjectMojo` (`setProject(MavenProject)`), `UpdateLocalCatalogMojo` and `DefaultArchetypeSelector` (`RepositorySystemSession`), `DefaultArchetypeGenerationConfigurator` (`VelocityComponent`, `RepositorySystemSession`). The plugin is a Maven 3 mojo and also relies on Sisu discovery. No other repository under the Apache Maven plugin repositories, shared, shared-4 or skins imports archetype-common.
**Improvements:** drops `maven-core`, `maven-model`, `maven-artifact`, `maven-resolver-api`, `javax.inject`, `plexus-velocity`, and test-side `plexus-testing`, `maven-resolver-connector-basic`, `maven-resolver-transport-http`. `plexus-utils` and `plexus-xml` stay (generated archetype descriptor and catalog readers).
**Recommendation:** the library ports without dropping behaviour except the remote-catalog and repository-policy gaps above. Do not release it before the plugin is ported to the Maven 4 mojo API and its 33 ITs run against it; keep the 3.x line for Maven 3 users.
</details>
<details><summary><b>maven-resolver-ant-tasks</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 3.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify -P run-its` with Maven 4.0.0-rc-7, JDK 21 → 59 tests before, 60 after (new `AntModelResolverTest`), 0 failures; the POM-reading parity golden file and all 11 `ResolveTest` cases pass unchanged; spotless clean. Cost: `run-its` build 2:46 → 9:17, not profiled.
Only the model and settings layer moves to the v4 API. Collection, resolution, install and deploy stay on the resolver's `RepositorySystem`.
**Central finding: no public `Session` outside Maven.** Ant has no Maven runtime. The only route is `org.apache.maven.impl.standalone.ApiRunner` in `maven-impl`, which is internal. Its session has no transporter, cannot take the Ant project's `RepositorySystem` (local repository, mirrors, proxies, credentials), and a custom `ModelResolver` replaces the default only as a `@Named @Priority` class, not through `bindInstance`.
**Public API changes** (internal packages, but the uber jar is what Ant users load)
- `AntRepoSys.loadModel` and `Pom.getModel` return the immutable `org.apache.maven.api.model.Model`; `CreatePom` builds through new `addRepository`, `addDeveloper`, `setScm`.
- `AntSecDispatcher`, `AntSettingsDecryptorFactory`, `SettingsUtils` removed: the v4 `SettingsBuilder` decrypts and converts profiles. A Maven 3 `settings-security.xml` master password still decrypts.
- The tasks need Java 17 (was 8).
**Gaps**
- Dependency POMs still go through the Maven 3 model builder via `maven-resolver-supplier-mvn4`; only the root POM uses the v4 `ModelBuilder`, so both builders are on the classpath.
- A repository declared in a POM loses its policies: the v4 `RemoteRepository` has only id, URL and protocol. Read from the API; no test covers it.
- `BUILD_PROJECT` needs `.mvn` or `root="true"`, so the root POM is built with `BUILD_EFFECTIVE`/`CONSUMER_DEPENDENCY`; `setProcessPlugins(false)` has no equivalent.
- The mvn4 supplier defaults to the transitive dependency manager; the classic one is now set explicitly. Other supplier defaults not diffed.
- The shaded jar must merge `META-INF/maven/org.apache.maven.api.di.Inject` and leave `org.apache.maven.impl` and `api.spi` unrelocated; the uber jar grows 4.95 MB → 8.22 MB.
**Consumers that break:** none in the estate; user Ant builds need Java 17 and see the v4 model from `Pom.getModel`.
**Improvements:** drops `maven-settings-builder`, `plexus-cipher`, `plexus-sec-dispatcher`, `maven-resolver-supplier-mvn3`; fixes an NPE on an unreadable `settings.xml`.
**Recommendation:** do not merge. The port rests on internal `ApiRunner`; ask apache/maven for a supported standalone `Session` factory that accepts a `RepositorySystem` and a `ModelResolver`. Keep 2.x on Maven 3 for Java 8 Ant users.
</details>
<details><summary><b>maven-indexer</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 8.0.0-SNAPSHOT, Java 17. `indexer-core` ported; `indexer-cli` and `search-backend-indexer` compile but fail at runtime (Sisu wiring), left unported.
Verified locally: `mvn -B verify` with Maven 4.0.0-rc-7, JDK 21. `indexer-core`: 245 tests, 0 failures, 1 skipped, plus 5 ITs, before and after. `indexer-reader` 23 (1 skipped), `search-api` 4, `search-backend-smo` 15 (14 skipped), `search-backend-remoterepository` 39: unchanged. `indexer-cli`: 7 tests, 0 errors before, 5 errors after (its 6 ITs no longer reached). `search-backend-indexer`: 9 tests (7 skipped), 0 errors before, 2 errors after. The `examples` profile (`indexer-examples-*` tests, off by default) was not run. Spotless clean.
**Public API changes**
- `ArtifactContext.getPomModel()`: `org.apache.maven.model.Model` (maven-model) → `org.apache.maven.api.model.Model`. This is the only Maven type in the public API; `MinimalArtifactInfoIndexCreator` reads name, description and packaging from it.
- POMs are read with `org.apache.maven.model.v4.MavenStaxReader` (`maven-support`), and `ArtifactLocator` no longer handles `XmlPullParserException`.
- `@Named`/`@Singleton`/`@Inject` on all 19 components move from `javax.inject` to `org.apache.maven.api.di`. Sisu and Guice no longer discover them, so `WireModule`/`SpaceModule`, `InjectedTest` and Plexus lookups return nothing. Bare `@Named` is dropped because the v4 annotation requires a value.
- Named creators (`min`, `jarContent`, `maven-plugin`, ...) and `List<IndexCreator>`/`Map<String, IndexCreator>` injection work in maven-di as-is.
**Gaps**
- `maven-compiler-plugin` has `<proc>none</proc>`, so `META-INF/maven/org.apache.maven.api.di.Inject` is maintained by hand (19 classes); a new component missing from it fails with "No binding".
- maven-di has no empty-collection injection: `DefaultIndexUpdater(…, List<IndexUpdateSideEffect>)` failed with a DI error because no side effect is bound. Fixed with `@Nullable` on the parameter (`maven-api-annotations`); the existing null check covers it. Behavioural difference: the list is `null`, not empty, when nothing is bound.
- No API-level POM reader outside a container: `ModelXmlFactory` needs a Maven 4 injector, and `MavenStaxReader` sits in `maven-support`, which is not `maven-api-*`.
- Tests: Sisu's `InjectedTest` replaced by a local `AbstractTestSupport` that builds `Injector.create().discover(...)`; no test removed.
- Not ported: `archetype-catalog` (`ArchetypeDataSource`, optional, Maven 3 artifact) and plexus-utils `StringUtils`/`FileUtils`/`Xpp3Dom`/DAG, which are not Maven APIs; `plexus-utils` is now declared explicitly because it used to arrive through `maven-model`.
- Build: `javaVersion` 11 → 17 makes modernizer flag six `String.format` sites; modernizer pinned at 11 to keep them out of this change. `indexer-examples-spring` test-only `maven-model-builder` pinned to a new `maven3.version` (3.9.16) because it uses the v3 `ModelWriter`.
**maven-api-core: not appropriate here.** Nothing in `indexer-core` uses `Session`, `Artifact`, `Project` or any service; the three files with Maven 3 API use only the model. The port depends on `maven-api-model`, `maven-api-di`, `maven-api-annotations` and `maven-support` (which pulls `maven-xml`, `maven-api-settings`/`-toolchain`/`-metadata`/`-plugin`, all Java 17). For an artifact consumed by IDEs, repository managers and search tooling outside Maven, dropping the Maven dependency is the better port: only name, description and packaging are read, which a JDK StAX parse covers, and DI could be JSR 330 only (`javax.inject`/`jakarta.inject`), which Sisu, Guice and Spring all honour. Forcing `org.apache.maven.api.di` on those consumers replaces a de-facto standard with a Maven-internal one. Not implemented; measured only the api.di port.
**Consumers that break**
- In this repo (compile, fail at runtime with Guice `NullInjectedIntoNonNullable` because Sisu finds no components): `indexer-cli` (`Components`, `NexusIndexerCli`, `NexusIndexerCliTest`), `search-backend-indexer` (`IndexerCoreSearchBackendPagingTest`, `IndexerCoreSearchBackendImplTest`); `indexer-examples-basic` (`BasicUsageExample`) and `indexer-examples-spring` use the same Guice/Sisu wiring, tests not run.
- the Apache Maven repositories plugins, shared, shared-4 and misc: no Java import of `org.apache.maven.index` and no `org.apache.maven.indexer` dependency outside the repo itself. External consumers (IDE, repository manager, search tooling) cannot be checked from here; anyone calling `ArtifactContext.getPomModel()` or wiring through Sisu breaks.
**Improvements:** drops `javax.inject`, `org.eclipse.sisu.inject` and `guice` (provided) from `indexer-core`, and `maven-model`.
**Recommendation:** do not merge as is. Keep `indexer-core` 7.x on JSR 330 for the non-Maven consumers; if a Maven 4 line is wanted, prefer replacing `MavenXpp3Reader` with a small StAX read and keeping `javax.inject`, rather than `org.apache.maven.api.di`.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919284027
### Wave 4 findings, part 4 of 4: maven-remote-resources-plugin to maven-toolchains-plugin
Each plugin is a local branch `agent/mvn4-api` with a "Build with Maven 4 only" commit and a "Port to the Maven 4 API" commit; the PRs are not opened yet.
<details><summary><b>maven-remote-resources-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported** (reduced supplemental-model merging, see Gaps), 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify -Prun-its` with Maven 4.0.0-rc-7, JDK 21 → 11 unit tests, 9 failsafe ITs and 7 invoker ITs before (8:39 min), 11, 9 and 7 after (4:10 min), 0 failures; spotless clean. The unit test class is rewritten (see Gaps), the ITs are untouched.
Snapshots consumed from the local repository (not rebuilt here): `maven-filtering` 4.0.0-beta-2-SNAPSHOT, `maven-archiver` 4.0.0-beta-6-SNAPSHOT (`org.apache.maven.shared`), `maven-common-artifact-filters` 4.0.0-SNAPSHOT (the agent/mvn4-api port).
**v4 equivalents**
| Was | Is |
|---|---|
| `ProjectBuilder.build(Artifact, request)` → `MavenProject` | `Session.resolveArtifact` of the `pom` artifact, then `ModelBuilder.newSession().build(ModelBuilderRequest…requestType(CONSUMER_DEPENDENCY).source(Sources.resolvedSource(pom, key)))` → `getEffectiveModel()`. `api.ProjectBuilder` is unusable here: `ProjectBuilderResult.getProject()` is empty for a repository POM because `DefaultSession.getProject` returns null when the project has no base directory. `BUILD_EFFECTIVE` fails on invalid dependency POMs (`'distributionManagement.status' must not be specified` for `maven-plugin-api:2.0`); `CONSUMER_DEPENDENCY` tolerates them like `VALIDATION_LEVEL_MINIMAL` did (MRRESOURCES-121 IT). |
| `MavenProject.getArtifacts()` / `getDependencyArtifacts()` | `Session.collectDependencies(project, TEST_RUNTIME)` flattened / `root.getChildren()`, as `Dependency` sets fed to the v4 common-artifact-filters |
| `RepositorySystem.resolveArtifact` + `ArtifactHandlerManager` | `Session.requireType(type)` (extension, classifier) + `Session.resolveArtifact(artifact, ProjectManager.getRemoteProjectRepositories(project))` |
| `MavenSession.getProjects()` output dirs | `Project.getOutputDirectory(ProjectScope.MAIN / TEST)` |
| `project.getResources().add(Resource)` | `ProjectManager.addSourceRoot(project, scope, Language.RESOURCES, path)` |
| `project.getResources()` iteration | `ProjectManager.getEnabledSourceRoots(project, MAIN, Language.RESOURCES)`, `SourceRoot.stringFiltering()` |
| `MavenXpp3Reader` for supplements | `ModelXmlFactory.read(XmlReaderRequest)` |
| plexus `ResourceManager` injection | `new DefaultResourceManager(Map<id, loader>)` built by hand; still exposed as `$locator` |
**Velocity context objects**
- `project` and each element of `projects`: `MavenProject` → `RemoteResourcesProject` (new, public), a wrapper over the immutable `org.apache.maven.api.model.Model` with the descriptive getters (`groupId`, `artifactId`, `version`, `packaging`, `name`, `description`, `url`, `inceptionYear`, `organization`, `licenses`, `developers`, `contributors`, `mailingLists`, `scm`, `issueManagement`, `ciManagement`, `distributionManagement`, `build`, `dependencies`, `properties`, `id`, `basedir`, `model`). Returned values are v4 model classes (same getter names); `properties` is a `Map<String,String>`.
- `$project.artifact` keeps the textual form `groupId:artifactId:type:version` (type = the model packaging), so the bundled `DEPENDENCIES` template output is unchanged (MRRESOURCES-121 asserts `…maven-plugin-api:jar:2.0`). The object is no longer an `Artifact` (no `getFile()`).
- `projectsSortedByOrganization` keys are `org.apache.maven.api.model.Organization`; `projects` sort by groupId, artifactId, version.
- Unchanged: `presentYear`, `projectTimespan`, `locator`, user `properties`.
- Gone: every `MavenProject`-only method (`getFile`, `getParent`, `getArtifacts`, `getBuild().getResources()` as mutable, …); templates using them need `$project.model`.
**Public API changes**
- Mojos implement `org.apache.maven.api.plugin.Mojo`; `@Inject` fields (`Session`, `Project`, `Log`, `MavenFileFilter`); constructors are no-arg (a constructor with parameters fails at lookup: the generated `…MojoFactory` calls `<init>()`). Protected `mavenSession` → `session` (`api.Session`), `project` is `api.Project`; abstract `getAllDependencies()` / `getDirectDependencies()` return `Set<org.apache.maven.api.Dependency>`; `getProjects()` returns `List<RemoteResourcesProject>`; `getSupplement`, `mergeModels` use `api.model.Model`.
- `ModelInheritanceAssembler.assembleModelInheritance` returns the merged `Model` instead of mutating; `ModelUtils` is removed.
- Defaults `${basedir}/src/main/resources` and `${basedir}/src/main/appended-resources` became `${project.basedir}/…`: Maven 4 does not evaluate `${basedir}` in `@Parameter` defaults (the `bundle` goal silently skipped with "skip non existing resourceDirectory ${basedir}/src/main/resources").
**Gaps**
- `SourceRoot` is immutable, so a project resource that overrides a bundle resource is no longer excluded from the project's resources (`resource.addExclude`); both copies reach the resources plugin. ITFilterLocalOverride and ITGenerateFromOverride pass.
- Supplemental-model assembly is reduced: descriptive metadata, properties, dependencies, dependencyManagement, repositories and the build directories/filters/resources are merged; plugins, pluginManagement, extensions and reporting are not (no v4 API to merge models, `maven-impl`'s assembler is internal). They only matter if a template reads them. ITSupplementalArtifact passes.
- `requiresDependencyResolution = TEST` has no attribute in use; dependencies are collected on demand. `resolveScopes` was already unused.
- The filtering component needs a `BuildContext`: `Providers` (`@Named`, `@Provides ThreadBuildContext`) plus `plexus-build-api` and `org.eclipse.sisu.plexus` at runtime (for `AbstractLogEnabled`), as in maven-resources-plugin.
- Tests: `RemoteResourcesMojoTest` no longer uses `AbstractMojoTestCase` and is rebuilt on Mockito mocks of `Session`/`Project`/`ProjectManager` (same 11 scenarios, renamed to camelCase). Removed, with reason: `stub/ArtifactStub`, `MavenProjectBasicStub`, `MavenProjectBuildStub`, `MavenProjectResourcesStub`, `ModelStub` (v3 `MavenProject` stubs with no v4 counterpart), `src/test/resources/unit/rrmojotest/*.xml` (mojo configs for the old lookup harness). The unit tests therefore do not exercise real dependency resolution; the ITs do.
**User-visible changes:** requires Maven 4; Velocity templates that call `MavenProject` methods beyond the list above break; the `${basedir}` defaults are now `${project.basedir}`; local resources overriding a bundle are copied twice (same content). ASF parent POMs bind this plugin, so they need the 4.x plugin on Maven 4 only. No Java code under the Apache Maven repositories imports `org.apache.maven.plugin.resources.remote`.
**Improvements:** drops `maven-core`, `maven-model`, `maven-model-builder`, `maven-plugin-api`, `maven-artifact`, `maven-resolver-api/provider/util`, `maven-plugin-annotations`, `javax.inject`, and from tests junit4, the vintage engine, `maven-plugin-testing-harness` and `maven-resolver-impl`; adds `maven-api-core/annotations/model/di` (provided), `plexus-build-api`, `mockito-core` 5.24.0 (tests, replaces the harness stubs).
**Recommendation:** port for Maven 4; keep the 3.x line for Maven 3. Ask core for a `ProjectBuilder` result that works for repository POMs (or document `ModelBuilder` + `CONSUMER_DEPENDENCY`), and for a documented `${basedir}` alias in parameter defaults.
</details>
<details><summary><b>maven-scm-publish-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → no unit tests exist, before or after; `mvn verify -Prun-its` → 5 passed, 0 failed before (5m09s) and after (4m57s); spotless clean. Also run by hand with the installed plugin: credentials from a settings `<server>` (see Gaps) and a no-project publish to a local bare git repo (BUILD SUCCESS, commit and `index.html` present, seed file deleted as expected). Shared snapshots consumed: none (maven-scm 2.2.1 release; the maven-scm library modules use no Maven API and are used unchanged; maven-release-manager is dropped, not ported).
**Public API changes** (Mojo base classes, for subclasses only)
- `AbstractScmPublishMojo` implements `org.apache.maven.api.plugin.Mojo`; constructor `(ScmManager, ScmRepositoryConfigurator)` is gone; `@Inject` fields `Log`, `Session`, `Prompter`; `ScmPublishPublishScmMojo.project` is now `org.apache.maven.api.Project`; the `settings` field is gone; `execute()`/`scmPublishExecute()` throw the unchecked `MojoException`.
- `@Mojo(projectRequired = false, aggregator = true)` replaces `requiresProject = false`.
- New package-private `ScmManagerFactory` (builds the `ScmManager`).
**Gaps**
- `ScmManager` and `ScmRepositoryConfigurator` cannot be injected. Both are Sisu JSR 330 components (`META-INF/sisu/javax.inject.Named`), which the v4 plugin container does not read, and `ScmRepositoryConfigurator.getConfiguredRepository(ReleaseDescriptor, org.apache.maven.settings.Settings)` takes the v3 `Settings` type, which `Session.getSettings()` (`org.apache.maven.api.settings.Settings`) does not provide. I did not try to keep `maven-release-manager`. Replacement: `ScmManagerFactory` reads the Sisu index from the plugin class loader, instantiates each `@Named` `ScmProvider` (first hint wins, as in `DefaultScmManager`) into a `BasicScmManager`; debug log shows `git`, `jgit`, `hg`, `svn` registered. A provider needs a no-arg constructor or the Plexus `Prompter` constructor (jgit, served by an adapter over the v4 `org.apache.maven.api.services.Prompter`); any other is skipped with a warning. This is the piece maven-scm would have to fix properly (a non-Sisu way to obtain a `Scm
Manager`, such as a `ServiceLoader` registry).
- Settings/servers: `Session.getSettings().getServers()` is a plain list, so the `getServer(id)` lookup and the host fallback (`host[:port]`) are reimplemented in the mojo, along with the username/password/privateKey/passphrase precedence of `DefaultScmRepositoryConfigurator`. The v4 API has no decrypt service; Maven 4's `DefaultSettingsBuilder` decrypts settings itself (read in the maven-4.0.x checkout at e8fd05aeee), so the mojo uses the values as given. Not run against an encrypted password. Observed: `svn --username alice --password ... ` taken from `<server id="myserver">` via `${project.model.distributionManagement.site.id}`.
- Plugin expressions: `${project.distributionManagement.site.url}` and `${project.name}` do not evaluate in v4 (the evaluator reflects on `api.Project`, which has no such getters). The first ITs failed with "The scm url cannot be null". Defaults are now `${project.model.distributionManagement.site.url|id}` and `${project.model.name}`; `${project.reporting.outputEncoding}` still resolves as a property.
- `${settings}` and `${project}` parameters have no v4 form; replaced by `Session.getSettings()` and an injected `Project`. With `projectRequired = false` and no pom, the injected `Project` is null and the mojo handles it (publish without a project verified).
- Left as is, warnings only: `maven-shared-utils` `MessageUtils` (deprecated; the v4 `MessageBuilderFactory` exists), `Model.getModules()` and `ScmProviderRepository.setPersistCheckout` (deprecated).
**User-visible changes**
- Maven 4 only; Java 17 to run.
- Parameters `settings` and `project` removed; all other parameter names, properties and the `maven.site.deploy.skip` alias are unchanged (alias present in the generated `plugin.xml`).
- Default expressions changed as above; users overriding `pubScmUrl`, `serverId` or `checkinComment` are unaffected. Without a project the default checkin comment still contains the literal `${project.model.name}` (Maven 3 behaviour not compared).
- Third-party SCM providers added as plugin dependencies are found only if they publish the Sisu index and have a supported constructor.
**Improvements:** drops `maven-release-api`, `maven-release-manager`, `maven-core`, `maven-model`, `maven-settings`, `maven-plugin-api`, `maven-plugin-annotations`; adds the `maven-api-*` jars (provided). `javax.inject` moves from provided to runtime (needed to read `@Named` hints; providers already depend on it) and `plexus-interactivity-api` 1.4 becomes explicit (already transitive via the jgit provider; the adapter implements its interface).
**Recommendation:** port for the Maven 4 line, keep 3.x for Maven 3. The port works, but the in-plugin provider bootstrap is a workaround; ask maven-scm for a non-Sisu `ScmManager` factory before releasing.
</details>
<details><summary><b>maven-scripting-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 1 test before and after, 0 failures; `-Prun-its` 5/5 ITs pass before and after (whole suite, no time-box hit); spotless clean. Not measured: running the ported plugin under Maven 3.
Uses `maven-api-core`/`maven-api-di`/`maven-api-annotations` 4.0.0-rc-7 (provided) and plugin-tools 4.0.0-beta-1. No shared component needed.
**User-visible changes**
- Goal `scripting:eval` and its parameters (`engineName`, `script`, `scriptFile`, `scriptResource`) are unchanged.
- The plugin no longer runs on Maven 3 (v4 `Mojo`, `@Inject`).
- Script-visible bindings (the `GLOBAL_SCOPE` `Bindings` passed to every engine): the names stay `project` and `log`, the types change.
- `project`: `org.apache.maven.project.MavenProject` → `org.apache.maven.api.Project`. Still there: `groupId`, `artifactId`, `version`, `basedir` (now `java.nio.file.Path`, was `File`), `model`, `build` (now `org.apache.maven.api.model.Build`), `parent` (now `Optional<Project>`), `artifacts` (now `List<ProducedArtifact>`). Gone: `getFile()` (use `pomPath`), `getProperties()` (use `model.properties`), `getName()`/`getDescription()` (use `model.name`/`model.description`), `getCollectedProjects()`, `getArtifact()`, `getRemote*Repositories()`, `getPluginArtifacts()`, `getCompileSourceRoots()`.
- `log`: `org.apache.maven.plugin.logging.Log` → `org.apache.maven.api.plugin.Log`. `debug/info/warn/error` with `CharSequence` and/or `Throwable`, and `isXxxEnabled()`, are present; the `(CharSequence, Throwable)` overloads exist too.
- No `session` binding before or after; not added.
- Java engine (`Maven-Scripting-Java-Engine`): the generated class now imports `org.apache.maven.api.Project` and `org.apache.maven.api.plugin.Log`, so `$project` and `$log` change type the same way. The engine's compile classpath is `${maven.home}/lib/maven-*` plus the test/plugin classpath; on Maven 4 that includes `maven-api-core`, so it compiles.
- Groovy scripts using `project.artifactId` (the 4 Groovy ITs) work unchanged; Groovy property access maps onto the `Project` getters.
- Error reporting: `MojoExecutionException` (script error) and `MojoFailureException` (no engine for name/extension) both become `MojoException`, so the "BUILD FAILURE" vs "error" distinction is gone.
- `ContextAwareEngine.setLog(Log)` is public API for custom engines: parameter type is now the v4 `Log`.
**Gaps:** none. Everything used has a v4 equivalent.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-plugin-annotations`. `<prerequisites><maven>` follows `${mavenVersion}`.
**Recommendation:** port; publish as a 4.x line and keep 3.x for Maven 3 users. Release notes must list the binding type change, since user scripts are the only "consumers" and they are not visible to us.
</details>
<details><summary><b>maven-shade-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn -B -ntp verify` with Maven 4.0.0-rc-7, JDK 21 → 72 unit tests before and after, 0 failures, 0 skipped; `mvn verify -Prun-its` → Passed 85, Failed 0, Skipped 1 before (19m39s, contended by other builds) and after (13m59s); the skipped IT is `MSHADE-185` ("SKIPPED due to JRE version") both times, so the system-scoped-dependency path of the reduced POM is unexercised. `spotless:check` clean. Shared snapshots consumed: none. Not measured: parallel (`-T`) builds beyond the existing `MSHADE-413-parallel` IT, JDK 17.
**Public API changes**
- `Shader.shade` throws the unchecked `org.apache.maven.api.plugin.MojoException` instead of checked `MojoExecutionException`. Third-party `Shader` implementations break at compile time and need `@Named("<hint>")` from `org.apache.maven.api.di` plus an entry in `META-INF/maven/org.apache.maven.api.di.Inject` (`<proc>none</proc>` in the parent, so nothing generates it for test classes). `DefaultShader` is `@Named("default")` with `@Inject` on the no-arg constructor.
- `MinijarFilter` public constructors: `(MavenProject, Log, ...)` becomes `(String projectId, Path projectArtifact, Path outputDirectory, Map<String,Path> dependencies, Log, ...)`; `Log` is `org.apache.maven.api.plugin.Log`.
- `UseDependencyReducedPom.createPomReplaceTransformers(MavenProject, File)` takes `org.apache.maven.api.Project`; `ShadeMojo.updateExcludesInDeps(MavenProject, List, List)` becomes `(List, List)` over `org.apache.maven.api.model.Dependency`.
- Removed `org.apache.maven.plugins.shade.pom.PomWriter`, `MavenJDOMWriter` (1941 lines) and `Counter`; the reduced POM is written with `ModelXmlFactory`.
- Unchanged: `ResourceTransformer`, `ReproducibleResourceTransformer`, `Relocator`, `Filter` and every built-in transformer. None references a Maven type, so third-party transformers recompile as they are (`MSHADE-363_old-Transformer` passes with a Spring Boot transformer on the plugin classpath). `jdom2` and `plexus-utils` stay because built-in transformers use them.
- `ShadeMojo` implements `org.apache.maven.api.plugin.Mojo` with `@Inject` `Log`/`Session`/`Project`/`Map<String,Shader>`; new package-private `ResolvedArtifact` replaces `org.apache.maven.artifact.Artifact` inside the mojo.
**Gaps**
- The project's POM file cannot be replaced. v3 called `MavenProject.setFile(dependencyReducedPom)`; `Project` has no setter, and `ArtifactManager.setPath(project.getPomArtifact(), drp)` has no effect on install (tried: installed `-build.pom` still lists the shaded dependency). The call is dropped. Measured on Maven 4 with the 3.6.3 plugin: `setFile` only changed the installed `*-build.pom`; the consumer POM (`*.pom`) is generated from the model and still lists the shaded dependency. So Maven 4 core, not the plugin API, decides what consumers see; a model-level hook would be needed.
- Main artifact replacement needs no v4 call: the mojo renames the shaded file over the path from `ArtifactManager.getPath(project.getMainArtifact())`. Attached artifacts use `ProjectManager.attachArtifact(project, session.createProducedArtifact(g, a, v, classifier, ext, null), path)`; classified sources/tests resolve through `session.resolveArtifact(coordinates, projectManager.getRemoteProjectRepositories(project))`. `getMainArtifact()` is empty for `pom` packaging.
- `ProjectBuilder` cannot re-read the reduced POM: `DefaultProjectBuilder.doBuild` builds a bare `ProjectBuildingRequest` (no root directory, properties or profiles), so a parent reachable only through `relativePath` fails with "Non-resolvable parent POM" (`dep-reduced-pom-with-local-parent`). The port collects the dependencies it just wrote (`DependencyResolverRequest` with `rootArtifact`, `dependencies`, `managedDependencies`, `verbose(true)`, `TEST_RUNTIME`) instead. Consequences: the written POM is no longer parsed back, so a malformed reduced POM is no longer caught in the plugin, and the MSHADE-467 lock around the build is gone.
- `DependencyCoordinatesFactory.create(Session, org.apache.maven.api.model.Dependency)` drops scope, optional and exclusions (it passes only g:a:v:classifier:type). With it the graph lost `provided` and the exclusions and `dep-reduced-pom-artifactset-provided-excludes` (MSHADE-311) failed. The mojo fills `DependencyCoordinatesFactoryRequest` itself and implements `api.Exclusion`.
- No `threadSafe` and no `requiresDependencyResolution` on `@Mojo`: dependencies are resolved in `execute()` with `DependencyResolver.resolve(session, project, PathScope.MAIN_RUNTIME)`; `getDependencies()` is a `LinkedHashMap`, so jar order (first wins on duplicate resources) is kept. No IT isolates the ordering.
- `MavenProject.getOriginalModel()` has no equivalent; the raw model is read from `project.getPomPath()` with `ModelXmlFactory` (`strict(false)`).
- DI: injecting `Shader` picks an arbitrary implementation once a build adds another (`shading-with-java-8-sources` has the test jar with `MockShader` on the plugin classpath and sets no `shaderHint`, and it ran `MockShader`); the mojo injects `Map<String,Shader>` and looks up `shaderHint` or `default`. A class with two constructors needs `@Inject` on one.
- Parameter default `${basedir}/dependency-reduced-pom.xml` does not evaluate in v4 (created a literal `${basedir}` path); now `${project.basedir}/...`, same value.
- Reduced-POM `parent.relativePath` (apache/maven-shade-plugin#813, #843, both open): master does not fix it. On rc-7 a project with `<relativePath/>` in its parent fails at `shade` with `'parent.relativePath' ... points at 'pom.xml' which resolves to org.example:app-emptyrel instead of the declared parent`; the `..` layout from #813 did not fail on rc-7 with master's code in my repro. Root cause: the 3.x code resolves an empty relativePath against the basedir and writes `pom.xml`. The port keeps an empty path empty, and leaves an unset path unset: the v4 model writer writes every non-null field, so writing the computed `../pom.xml` made Maven 4 reject the reduced POM (verified with `mvn -f dependency-reduced-pom.xml validate`). Not the approach of #843 (empty path when `..` is not the real parent); that PR's case and mine are different inputs.
- Unverified: parallel builds, `generateUniqueDependencyReducedPom` under load, `MSHADE-185` system scope (IT skipped), mojo configuration of third-party transformers that need injection.
**User-visible changes**
- Runs on Maven 4 only and needs Java 17; a 3.x line must stay for Maven 3 users. Goal, parameter names and `-D` properties are unchanged; `threadSafe` is not declared.
- Reduced POM is written by the v4 model writer: canonical element order, `https://maven.apache.org/xsd/maven-4.0.0.xsd` in `schemaLocation`, default values (`<relativePath>../pom.xml`) omitted; all reduced-POM ITs pass.
- Install/deploy publish the original `*-build.pom` (on Maven 4 the 3.6.3 plugin published the reduced one there); the consumer POM is unchanged by either.
- `<relativePath/>` in the shaded project's parent now works on Maven 4 (fails on master).
- Consumers in the Apache Maven repositories that use the plugin (indexer-cli, resolver-ant-tasks, surefire-shared-utils, surefire-shadefire, doxia converter, modello-core) reference only built-in transformers by class name; no source change, but each needs the new plugin version under Maven 4. Maven 4's `mvnup` (`PluginUpgradeStrategy`) upgrades shade to at least 3.5.0 and skips projects with custom transformers; it knows nothing of 4.x.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-model`, `maven-artifact`, `maven-resolver-provider`, `maven-plugin-annotations`, `javax.inject`, `sisu-maven-plugin`, and about 2000 lines of generated JDOM writer; adds `maven-api-core`, `maven-api-di`, `maven-api-model`, `maven-api-annotations` (provided). Test scope: `junit-vintage-engine`, `junit` (explicit) and `maven-plugin-testing-harness` go; `guice` is added for `TransformerTesterRule` (sisu.plexus needed it and `maven-core` no longer supplies it); `junit`/`hamcrest-core` stay in `dependencyManagement` because `xmlunit-legacy` pulls junit 4 in and surefire then starts the vintage engine.
**Tests rewritten, none removed:** `ShadeMojoTest` (5 tests) from JUnit 3 `AbstractMojoTestCase` to JUnit 5 with Mockito and `new DefaultShader()`; `MinijarFilterTest` (2 tests) from a `MavenProject` mock to the new constructor. 72 tests before and after. New `src/test/resources/META-INF/maven/org.apache.maven.api.di.Inject` lists `MockShader`.
**Recommendation:** port for the Maven 4 line, keep 3.x for Maven 3. Two things block a full-parity claim: the reduced POM cannot become the published POM through any v4 API (a core/consumer-POM question to raise on apache/maven), and the `ProjectBuilder` request cannot carry session context. Worth issues: `DependencyCoordinatesFactory.create(Session, model.Dependency)` dropping scope/exclusions, and `ProjectBuilderRequest` lacking root directory/properties. Consider folding the `<relativePath/>` fix into a 3.x PR against #813/#843 first, since master is broken for that input today.
</details>
<details><summary><b>maven-toolchains-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17. All four goals on `org.apache.maven.api`; no test or IT removed.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn -B -ntp verify`: 1 test (`ToolchainDiscovererTest`), 0 failures, before and after. `-Prun-its`: 8 of 8 ITs before (old plugin on Maven 4), 8 of 8 after. `display-discovered-jdk-toolchains` and `generate-jdk-toolchains-xml` have no IT; both were run by hand against the built plugin and print/write the 5 local JDKs. Spotless clean.
**Do the goals still have a job under Maven 4? Yes, both `toolchain` and `select-jdk-toolchain`.** rc-7 `DefaultToolchainManager` only stores and reads the build context (`toolchain-<type>`); nothing in core selects and stores a toolchain. Core points at this plugin: `checkJdkSourceLevelCompatibility` logs "run 'mvnup' to add the maven-toolchains-plugin" and mvnup `ToolchainPluginStrategy` adds `select-jdk-toolchain`.
**Public API changes**
- Mojos implement `org.apache.maven.api.plugin.Mojo` with `@Inject Log`/`Session` (`org.apache.maven.api.di`); `requiresProject = false` becomes `projectRequired = false`; `defaultPhase` is a string. Goal names and parameter names/properties unchanged.
- `ToolchainManagerPrivate` becomes `session.getService(ToolchainManager.class)` (`getToolchains`, `storeToolchainToBuildContext`); `ToolchainPrivate` becomes `org.apache.maven.api.Toolchain`; toolchains XML goes through `ToolchainsXmlFactory`; models are the immutable `org.apache.maven.api.toolchain` types with `XmlNode` configuration.
- `ToolchainsRequirement` (public) keeps its getters; its package-private field is replaced by `fromXmlNode(XmlNode)`. `ToolchainConverter` and `ToolchainsComponentConfigurator` (Plexus converter plus custom configurator `toolchains-requirement-configurator`) are deleted: the `toolchains` parameter is now an `XmlNode`, which rc-7's enhanced configurator populates directly (confirmed by the `toolchain` ITs).
- `ToolchainDiscoverer` is an api.di `@Named @Singleton` with a constructor taking `ToolchainsXmlFactory` (was no-arg); it is public, so callers constructing it break.
- Discovery no longer aborts on one unreadable JDK: a JDK whose `java -XshowSettings` fails is skipped (before, the NPE was caught and discovery returned an empty result).
- The cache and generated toolchains XML now use the 1.2.0 toolchains namespace (writer of rc-7).
**Gaps**
- No API turns a `ToolchainModel` into a `Toolchain` for an arbitrary model: the `jdk` `ToolchainFactory` is not bound in a plugin's injector (`No binding ... @Named("jdk") ToolchainFactory`). `select-jdk-toolchain` therefore wraps discovered and current JDK models in a private `JdkToolchain` (type, model, `findTool`); `storeToolchainToBuildContext` only uses type and model, and core re-creates the real toolchain from the stored model.
- `RequirementMatcherFactory` is compat-only. Matching is done locally on `model.getProvides()`: `version` through `session.parseVersionConstraint(..).contains(session.parseVersion(..))`, `env` by the existing regex, everything else case-insensitive equals. The jdk factory's own matcher also does not know `env`, so `toolchain.matchesRequirements` could not have been reused.
- `Xpp3Dom` replaced by `XmlNode` (`child("jdkHome").value()`); the plugin no longer needs `plexus-xml`.
- No generated-by-processor surprises: `<proc>` is on; the `META-INF/maven/org.apache.maven.api.di.Inject` index lists the four Mojo factories and `ToolchainDiscoverer`.
- Custom toolchain types: a v4 `services.ToolchainFactory` contributed by an extension is found by the core manager only when it is registered through the Sisu index (`javax.inject.@Named("custom")` plus `sisu-maven-plugin:main-index`), not through `META-INF/maven/org.apache.maven.api.di.Inject` alone (`Missing toolchain factory for type: custom` with the api.di index). The IT fixture `setup-custom-toolchain` is ported that way.
**User-visible changes**
- Requires Maven 4 (`<prerequisites>` follows `mavenVersion` 4.0.0-rc-7).
- Failure messages carry `MojoException` instead of `MojoFailureException` (IT `missing-toolchain` assertion updated).
- The `toolchains` parameter is logged at debug level as XML, not `ToolchainsRequirement{...}` (IT `select-jdk-toolchain-range` now asserts the `Required toolchain:` info line instead).
- Custom toolchain factories written against the compat `ToolchainFactory` still work through core's bridge; ones written for the v4 API need the Sisu index, see Gaps.
**Improvements:** drops `maven-core`, `maven-plugin-api`, `maven-plugin-annotations`, `javax.inject`, `org.eclipse.sisu.plexus`, `plexus-xml`, `slf4j-api` 1.7 (now provided 2.0.x) and `sisu-maven-plugin`.
**Recommendation:** merge-worthy as the 4.x line, with the jdk-factory and `env` matcher gaps filed against apache/maven: a way to create a `Toolchain` from a `ToolchainModel` would remove the private `JdkToolchain` wrapper.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919282431
### Wave 4 findings, part 1 of 4: maven-acr-plugin to maven-dependency-plugin
Each plugin is a local branch `agent/mvn4-api` with a "Build with Maven 4 only" commit and a "Port to the Maven 4 API" commit; the PRs are not opened yet.
<details><summary><b>maven-acr-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT (was 3.2.1-SNAPSHOT), Java 17.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` → BUILD SUCCESS before and after; the plugin has no unit tests (0 before, 0 after). `mvn verify -Prun-its` → 4/4 invoker ITs pass before (3m20s) and after; `spotless:check` clean. Consumed released artifacts only, no local snapshots: maven-archiver 4.0.0-beta-5, maven-filtering 4.0.0-beta-1, maven-plugin-plugin 4.0.0-beta-1.
**User-visible changes**
- `AcrMojo` implements `org.apache.maven.api.plugin.Mojo`, annotated with `org.apache.maven.api.plugin.annotations`; project, session, `Log`, `ProjectManager` and `MavenFileFilter` are `@Inject`ed. Goal `acr`, phase `package` and every parameter name/property (`maven.acr.*`, `jarName`, `excludes`, `archive`, `filters`, `outputTimestamp`) are unchanged; `basedir` and `outputDirectory` are now `Path` (same XML syntax).
- Runs only on Maven 4: it no longer loads under Maven 3 (`javax.inject`, `maven-plugin-api`, `maven-core`, `maven-artifact` dropped). A 3.x line has to stay for Maven 3 users.
- Main artifact is attached with `ProjectManager.attachArtifact(project, project.getMainArtifact(), jar)` instead of `project.getArtifact().setFile`.
- Bug fixed on the way: the old code appended `META-INF/application-client.xml` to the user's `excludes` list in place; it now copies the list.
- New `Providers` class (`@Provides`) supplies `ProjectManager` and `BuildContext`; the second is needed because `DefaultMavenFileFilter` 4.0.0-beta-1 requires a `BuildContext` binding (the same workaround maven-resources-plugin carries). Without both, every IT failed with "No binding to construct an instance for key ...".
**Gaps**
- `org.eclipse.sisu:org.eclipse.sisu.plexus` must be a compile dependency: `ThreadBuildContext` (plexus-build-api 0.0.7) needs `org.codehaus.plexus.logging.AbstractLogEnabled`, which the v4 plugin realm does not provide. The four ITs pass without it (the `<extensions>true</extensions>` realm supplies the class), but invoking the goal directly on a jar-packaged project (`mvn ...:maven-acr-plugin:4.0.0-beta-1-SNAPSHOT:acr`) failed with "Unable to lookup Mojo" until the dependency was added; afterwards it built the jar. maven-resources-plugin master carries the same dependency.
- `@Mojo(dependencyResolutionPathScopes = "runtime")` (the v4 replacement for `requiresDependencyResolution = RUNTIME`) cannot be used: maven-plugin-plugin 4.0.0-beta-1 fails with "Method: 'dependencyResolutionPathScopes' not found in class MojoAnnotationContent". The attribute is omitted; this is safe here because `MavenArchiver.getManifest` resolves `MAIN_RUNTIME` on demand through `DependencyResolver`, which is what all four ITs exercise (manifest classpath included).
- The `app-client` packaging still needs `META-INF/plexus/components.xml` (`LifecycleMapping` + `ArtifactHandler`). A pure v4 registration via `PackagingProvider` + `TypeProvider` compiled and its beans were indexed, but with the components.xml removed and a clean build, it-01 failed with `Unknown packaging: app-client`. `DefaultPackagingRegistry.lookup` in maven-4.0.x resolves only through the Sisu `LifecycleMapping` component and never consults `PackagingProvider`, so the SPI is inert. The experiment was reverted; the file is unchanged and works under rc-7.
- `maven-plugin-testing` v4 harness was not added: no unit test existed to port.
**Improvements:** drops `javax.inject`, `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-plugin-annotations`, `plexus-utils` (`FileUtils` replaced by `java.nio.file.Files`). Adds `maven-api-core/di/annotations` (provided), `plexus-build-api` and `org.eclipse.sisu.plexus`.
**Recommendation:** port for Maven 4; keep a 3.x line for Maven 3 builds. Follow up upstream on two items: `PackagingProvider` not honoured by `DefaultPackagingRegistry` (blocks removing components.xml from packaging plugins), and maven-plugin-tools not extracting `dependencyResolutionPathScopes`.
</details>
<details><summary><b>maven-antrun-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported** (two workarounds for Maven 4.0.0-rc-7 defects), 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify -Prun-its` with Maven 4.0.0-rc-7, JDK 21 → 4 unit tests and 29 invoker ITs before, 4 and 29 after, 0 failures (before 9:52 min, after 10:08 min); spotless clean. The "before" numbers are the 3.2.1 code built and run by Maven 4.
**Ant-visible references** (all registered on the Ant project by `AntRunMojo`)
| Reference | Before | After |
|---|---|---|
| `maven.compile.classpath`, `maven.dependency.classpath`, `maven.runtime.classpath`, `maven.test.classpath` | `Path` from `MavenProject.get*ClasspathElements()` | same ids and type; built from output directories plus `Session.resolveDependencies(project, MAIN_COMPILE / MAIN_RUNTIME / TEST_RUNTIME)` |
| `maven.plugin.classpath` | `Path` from `${plugin.artifacts}` | same id and type; built from the `URLClassLoader` URLs of `MojoExecution.getPlugin().getClassLoader()` (see Gaps) |
| `maven.project` | `org.apache.maven.project.MavenProject` | changed type: `org.apache.maven.api.Project` |
| `maven.project.ref` | `MavenAntRunProject` holding a `MavenProject` | same id; `getMavenProject()` now returns `org.apache.maven.api.Project` |
| `maven.project.helper` | `MavenProjectHelper` | **disappears**; `maven.session` replaces it (attach goes through `ProjectManager.attachArtifact`) |
| `maven.local.repository` | aether `LocalRepository` (`getBasedir()`) | changed type: `org.apache.maven.api.LocalRepository` (`getPath()`) |
| `maven.local.repository.manager` | aether `LocalRepositoryManager` | **disappears**; `Session.getPathForLocalArtifact` via `maven.session` |
| `maven.session` | none | new: `org.apache.maven.api.Session` |
| `maven.dependency.artifacts` | none | new: `List<MavenAntRunDependency>` (dependency + path); replaces `MavenProject.getArtifacts()` for the tasks |
Unchanged: the Ant properties (`project.*`, `localRepository`, `settings.localRepository`, one property per dependency conflict id, `maven.project.dependencies.versions`), the `maven.project.dependencies` fileset and the per-artifact filesets, and the `mvn:attachartifact` / `mvn:dependencyfilesets` task names and attributes.
**Public API changes**
- `AntRunMojo` implements `org.apache.maven.api.plugin.Mojo` (was `AbstractMojo`); `execute()` throws `MojoException`; `DEFAULT_MAVEN_PROJECT_HELPER_REFID` removed, `DEFAULT_MAVEN_SESSION_REFID` and `DEFAULT_MAVEN_DEPENDENCIES_REFID` added; `copyProperties` takes `org.apache.maven.api.Project` plus the resolved dependencies; `getLocalRepository()` returns `org.apache.maven.api.LocalRepository`.
- `MavenAntRunProject`, `MavenLogger` (now takes `api.plugin.Log`), `DependencyFilesetsTask.filterArtifacts` (`List<MavenAntRunDependency>`), `SpecificScopesArtifactFilter` and `TypesArtifactFilter` (now `Predicate<org.apache.maven.api.Dependency>`) change signature. New `MavenAntRunDependency` record.
- Parameters: `${plugin.artifacts}` and `${repositorySystemSession}` are no longer injected; `sourceRoot` / `testSourceRoot` (removed, fail-fast) are `String` instead of `File`; `@Mojo(threadSafe, requiresDependencyResolution)` has no v4 attribute in use, dependencies are resolved on demand in `execute()`.
- `AntrunXmlPlexusConfigurationWriter` (package-private) is replaced by `AntrunXmlConfigurationWriter` over `XmlNode`; output is identical for the 4 existing writer tests.
**Gaps**
- An `XmlNode`-typed `@Parameter` drops every XML attribute and namespace: `DefaultBeanConfigurator.XmlConverter.toXml` calls `XmlNode.newInstance(name, value, null, children, null)`. Ant tasks are attribute-based, so the plugin reads `<target>` from `MojoExecution.getConfiguration()` instead; the injected `target` field stays only as the declared parameter. Consequence: runtime Maven expressions inside `<target>` that are not resolved at model time (for example `${session...}`) are no longer evaluated by Maven; no IT covers them.
- `MojoExecution.getPlugin().getDependencies()` throws an NPE from the second plugin execution in a build (`DefaultMojoExecution.getDependenciesMap` uses a null `PluginDescriptor.getDependencyNode()`); reproduced by the `multiple-phase-test` IT. `maven.plugin.classpath` is taken from the plugin realm URLs instead, which includes dependencies added in the project's `<plugin><dependencies>`.
- No `PathScope` contains the `system` dependency scope (`test-runtime` = compile, provided, test, runtime, test-runtime), so system-scoped dependencies are absent from the classpaths, properties and filesets. No IT covers it.
- No `MojoFailureException`: every Ant failure is a `MojoException` (build failure vs. error is lost).
- `Build.getSourceDirectory()` and `getTestSourceDirectory()` are deprecated in the v4 model and still feed `project.build.sourceDirectory`; projects that only declare `<sources>` are not covered.
- Anything a user script does with `MavenProject` through `maven.project` (`getArtifacts()`, `addCompileSourceRoot`, `getProperties()`…) has no direct v4 equivalent on `api.Project`.
- Site pages (`usage`, `tasks/*`) still describe the old references; not updated.
**User-visible changes:** requires Maven 4; the reference and parameter changes above; Ant scripts or custom tasks that cast `maven.project` to `MavenProject`, read `maven.project.helper` or `maven.local.repository.manager` break. No Java code under the Apache Maven repositories imports the changed types (grep over `org.apache.maven.plugins.antrun` / `org.apache.maven.ant.tasks`); POM users of the plugin were not inspected.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-model`, `maven-plugin-annotations`, `javax.inject`, `org.eclipse.sisu.plexus`, `plexus-utils`, `plexus-xml`; adds `maven-api-core/annotations/model/xml/di` (provided). No MXSerializer.
**Recommendation:** port for Maven 4 plugins and keep a 3.x line for Maven 3 users. Before merging, ask Maven core for attribute-preserving `XmlNode` parameters (or document `MojoExecution.getConfiguration()`) and fix the null dependency node in `DefaultMojoExecution`.
</details>
<details><summary><b>maven-artifact-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT (was 3.7.1-SNAPSHOT), Java 17. `buildinfo`, `compare`, `describe-build-output` and `check-buildplan` are ported; `reproducible-central` compiles but cannot run, and one IT cannot pass.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` before → 2 tests, 0 failed, 0 skipped; after → 25 tests, 0 failed, 0 skipped, but only with `-Dpgpverify.skip=true` (see Gaps). `mvn verify -Prun-its` before → 13 passed, 3 failed (`git-mono`, `git-multi`, `describe-multi`), 0 skipped (12m10s); after → 12 passed, 4 failed (the same three, plus `buildinfo-dir`), 0 skipped (17m18s), both run on a copy of the tree. The three common failures are not caused by the plugin: `git-*` stop in git-commit-id-plugin with "Could not get HEAD Ref" (the copied tree has no commits), `describe-multi` stops in apache-rat on `build.log.1` and the Maven 4 consumer POM. `spotless:check` clean. Consumed: released `org.apache.maven.shared:maven-archiver:4.0.0-beta-5`, and the local snapshots `maven-reporting-impl` and `maven-reporting-api` 5.0.0-SNAPSHOT (branch `agent/mvn4-api` of maven-reporting-impl, commit 21c3da4, already in the local repository, not rebuilt).
**User-visible changes**
- Goals `buildinfo`, `compare`, `describe-build-output`, `check-buildplan`, `reproducible-central` keep their names, phases and parameters (`buildinfo.*`, `reference.repo`, `compare.*`, `check.*`, `diagnose`, `outputTimestamp`); `buildinfoFile` and `check.plugin-issues` are now `Path`. `threadSafe` is gone from `@Mojo` (the API annotation has none). Runs only on Maven 4: a 3.x line has to stay.
- `RangesUtil` is no longer a Sisu component: it is a static utility returning `RangeDependency` records (`groupId`, `artifactId`, `version`, `message`).
- `compare`: the reference is the file of the local repository when there is one (installed, or cached from the reference repository), else it is downloaded from the reference repository with the `Transport` service, without looking at the reactor. The log line "Comparing against N reference files from ..." now shows `id (url)`.
- `check-buildplan`: the plan is computed from the effective POM (see Gaps).
- Dependency range messages are unchanged on the ITs (`Dependency g:a:jar:v (scope) via ... has been resolved from a version range [a,b)`).
**Gaps**
- `check-buildplan` has no v4 route to `LifecycleExecutor.calculateExecutionPlan` / `MavenExecutionPlan`. The plugins of the plan are the plugins of the effective POM's `build/plugins` (Maven 4 injects the packaging bindings there) that have an execution with goals in a phase up to the phase of a task (Maven 3 phase names matched through `Lifecycle.aliases()`) or in no phase. Not covered: tasks that are goals (`-Dcheck.buildplan.tasks=foo:bar`), plugins forked by `@Execute`, and executions whose phase only comes from the goal's default phase in a plugin descriptor when the POM gives none (those are counted as in the plan, which can over-report). The five `check-buildplan-*` ITs pass.
- Version ranges: `Node` carries no `VersionConstraint`, so direct ranges come from `Project.getDependencies()` (overlaid with `getManagedDependencies()`), and transitive ones from building the POM of every node of the graph with `ProjectBuilder`. A dependency whose POM cannot be resolved or built hides the ranges of its own dependencies; relocated dependencies are not followed. `check-buildplan-version-range-*` and `compare-mono` (buildinfo `mvn.rebuild-args`) pass.
- `compare` has no resolver provenance: `DownloadedArtifact` gives a path, not the repository. "Installed locally" is read from `_remote.repositories` (`file>=`), which resolver documents as internal. Workspace-free download uses `TransportProvider`; `Session.createRemoteRepository` does not apply mirrors to an `id::url` or `url` reference repository (not measured).
- `reproducible-central` compiles against `maven-reporting-impl` 5.0.0-SNAPSHOT, but `mvn org.apache.maven.plugins:maven-artifact-plugin:4.0.0-beta-1-SNAPSHOT:reproducible-central` fails with `NoClassDefFoundError: org/apache/maven/execution/MavenSession`: the Doxia site tool behind `AbstractMavenReport` needs Maven 3 types that the plugin realm of a Maven 4 plugin does not see (the same blocker as the reporting-impl port). No IT covers this goal. `@Mojo(requiresDependencyResolution = RUNTIME)` cannot be written either (`dependencyResolutionPathScopes` is not extracted by maven-plugin-plugin 4.0.0-beta-1); the report collects the runtime graph itself.
- IT `buildinfo-dir` (MARTIFACT-26) fails: it expects the warning "Ignoring artifact ...:pom:4.3.10 because it points to inexistent ..." for the main artifact of a `pom`-packaged module. In the v4 API a `pom` project has no main artifact (`Project.getMainArtifact()` is empty unless there are two artifacts), so there is nothing to warn about. The buildinfo itself is written correctly. The IT is unchanged.
- `mvn verify` runs pgpverify: its keys map has no entries for the new artifacts, and the locally built rc-7 artifacts are unsigned, so the goal fails; `pgp-keys-map.list` is not updated.
- `Session` has no top-level project: `Project.isTopProject()` is used; `MavenProject.getOriginalModel()` is read back from the POM file with `ModelXmlFactory`.
Tests: the two existing tests are unchanged. New: `RangesUtilTest`, `CheckBuildPlanMojoTest`, `PluginUtilTest`, `LocalRepositoryOriginTest`, `OutputArtifactTest` (23 tests).
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-model`, `maven-artifact`, `maven-resolver-api`, `maven-resolver-util`, `plexus-utils`, `plexus-xml`, `commons-io`, `javax.inject` and `maven-plugin-annotations` (the Maven 3 `maven-archiver` 3.6.6 is replaced by 4.0.0-beta-5, used only for `parseBuildOutputTimestamp`). Adds `maven-api-core/di/annotations` and `maven-xml` (provided) and the two reporting snapshots.
**Recommendation:** port for Maven 4 and keep a 3.x line for Maven 3. Do not release before the reporting chain is ported: the report goal cannot run. Upstream follow-ups worth filing: expose the repository of a resolved artifact and a way to resolve without the workspace; put `VersionConstraint` (and the pre-managed version) on `Node`; give the API an execution-plan service for tasks.
</details>
<details><summary><b>maven-assembly-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17. Needs an unreleased plexus-archiver (see Gaps, first item).
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 273 unit tests before, 271 after, 0 failures/errors/skipped both (3 tests removed, 1 added, listed below); checkstyle, RAT, dependency:analyze and `spotless:check` pass. `mvn verify -Prun-its` (155 project ITs): the before run hit the 30 min time-box after 65 ITs (65 passed, 0 failed; `exit=143`). After: the same 65 → 65 passed in 7 min, and the other 90 → 89 passed, 1 failed (`depSet-transFromProfile`, which the POM's own `pomExcludes` excludes from `run-its`; I listed it by hand, so it is not a regression). The ITs ran as two `-Dinvoker.test=` batches (the 65 that finished before, then the remaining 90) because the full profile exceeds the time-box on this machine. Shared snapshots consumed: maven-archiver 4.0.0-beta-6-SNAPSHOT, maven-filtering 4.0.0-beta-2-SNAPSHOT, maven-common-artifact-filters 4.0.0-SNAPSHOT (all from their local `agent/mvn4-api`/master worktrees), plexus-archiver 5.0.0-SNAPSHOT (master plus
a 4-line local patch, `asm-plexus-archiver-prototype.diff`). maven-mapping is not a dependency of the plugin (no import, not in the tree), so nothing is lost there.
**Public API changes** (for people who call or extend the plugin classes; the descriptor model `Assembly`, `ModuleSet`, ... is unchanged)
- `AbstractAssemblyMojo` implements `org.apache.maven.api.plugin.Mojo`; services are `@Inject` fields (`Session`, `Project`, `Log`, `MojoExecution`, `AssemblyArchiver`, `AssemblyReader`, `MavenReaderFilter`). The four-argument constructor is gone.
- `AssemblerConfigurationSource`: `MavenProject` → `org.apache.maven.api.Project`, `MavenSession getMavenSession()` → `Session getSession()`, `MavenArchiveConfiguration` is now `org.apache.maven.shared.archiver` (its `getManifestFile()` is a `Path`).
- New `artifact.AssemblyArtifact` replaces `org.apache.maven.artifact.Artifact` throughout (resolver, tasks, filters). The v4 API splits coordinates (`Dependency`), file and dependency trail; `AssemblyArtifact` holds all three and keeps the v3 getter names that `${artifact.*}` / `${module.*}` expressions use.
- `ProjectBuilder`, `ArtifactHandlerManager`, `RepositorySystem`, `PlexusContainer`, `BasicComponentConfigurator` are no longer constructor arguments of the phases, the resolver and `DefaultAssemblyArchiver`. `AddDependencySetsTask` and `ModuleSetAssemblyPhase` lose their `ProjectBuilder` parameter; `FilterUtils.filterProjects` gains a `Session`.
- `AssemblyProxyArchiver` no longer implements the deprecated `Archiver` methods (`addDirectory(...)`, `addArchivedFileSet(File, ...)`, `getFiles`, `setUseJvmChmod`, `setLastModifiedDate`, ...): plexus-archiver 5.0 removed them.
- `ContainerDescriptorHandler` SPI is unchanged (`ArchiveFinalizer` + `FileSelector`); how handlers are found changed, see Gaps.
**Gaps** (what has no v4 equivalent or had to be worked around; each verified by a concrete failure)
- **`ArchiverManager` cannot be obtained without Sisu in a v4 mojo, and plexus-archiver's "no DI" mode is incomplete.** Probe plugin on rc-7: `Lookup.lookup(ArchiverManager.class)` → `NoSuchElementException`; `lookupMap(ArchiverManager.class)` is empty. Cause: `DefaultArchiverManager` (plexus-archiver `src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java`) is a `javax.inject` `@Named @Singleton` bean whose constructor takes `Map<String, Provider<Archiver>>` etc., a Sisu-only hint-keyed map, and Maven 4 registers `javax.inject` `@Named("hint")` beans by class name (next item). `lookupMap(Archiver.class)` does list the archivers, keyed by class name (`org.codehaus.plexus.archiver.zip.ZipArchiver`), so hint `zip` is unavailable. plexus-archiver master (5.0.0-SNAPSHOT) already has `new ServiceLoaderArchiverManager()` (no DI, `META-INF/services/org.codehaus.plexus.archivers.spi.ArchiverProvider`), and the plugin uses it. But archivers it creates still NPE in
`addArchivedFileSet` (unpacking, every `<unpack>true`): `AbstractArchiver.java:132` declares `@Inject private Provider<ArchiverManager> archiverManagerProvider` (used at `:589` in `asResourceCollection`, reached from `addArchivedFileSet` `:646`); with no container it stays null. Same NPE for archivers taken from `lookupMap` and for `new ZipArchiver()`. 4.14.0 has the same field (`AbstractArchiver.java:144`, use at `:673`) and no `ServiceLoaderArchiverManager`, so the 4.x line cannot be made Sisu-free without a backport. **Candidate fix PR for codehaus-plexus/plexus-archiver (master)**: make `asResourceCollection` fall back to `new ServiceLoaderArchiverManager()` when the provider is null (4 lines, `asm-plexus-archiver-prototype.diff`; with it `addArchivedFileSet` works and all 155 ITs' unpacking passes); better, let the ServiceLoader providers/`ArchiverFactory` hand the manager to the archivers they create, and add a test that unpacks through `new ServiceLoaderArchiverManager()`.
- **`javax.inject` `@Named("hint")` beans lose their hint in a Maven 4 plugin.** Probe: a `@javax.inject.Named("sisu-h")` `Handler` is in `lookupMap(Handler.class)` under `probe.SisuHandler`, `lookup(Handler.class, "sisu-h")` fails; `@org.apache.maven.api.di.Named("di-h")` and `META-INF/plexus/components.xml` `role-hint`s work. The same applies to core's `ComponentConfigurator`s (keyed `org.codehaus.plexus.component.configurator.BasicComponentConfigurator`). Consequence for the SPI: third-party `ContainerDescriptorHandler`s declared with `javax.inject.@Named("hint")` cannot be selected by `<handlerName>hint</handlerName>` any more; components.xml or `api.di.@Named` ones can. The built-in handlers (`file-aggregator`, `metaInf-services`, `metaInf-spring`, `plexus`) moved to `api.di.@Named`. Handlers are looked up through `Lookup.lookupMap(ContainerDescriptorHandler.class)` at use time.
- **No Plexus component configurator.** `new BasicComponentConfigurator()` in the plugin realm: `NoClassDefFoundError: com.google.inject.spi.TypeConverter`; obtaining it from `Lookup.lookupMap(ComponentConfigurator.class)` fails the same way on provisioning (IT `massembly-345`, `archiverConfig`). Replaced by `internal.BeanConfigurator` (setter or field per child element; String, numbers, boolean, enum, `File`, `Path`, collections/arrays of those, `-` to camelCase). Anything the Plexus converters did beyond that (for example nested objects) is not supported for `archiverConfig` and handler `<configuration>`; unverified for exotic archiver options.
- **Mojo parameter types**: `PlexusConfiguration archiverConfig` and `Xpp3Dom` fail in v4 ("Cannot create instance of ..."); `archiverConfig` is now `XmlNode`, its XML text is handed to the archiver configuration as before. Descriptor model `Xpp3Dom` fields (handler `<configuration>`) are unaffected (they are read by modello, not by the mojo configurator).
- **`${project.basedir}` default is wrong in a reactor**: it resolved to the directory Maven was started in, not the child's (11 dependency-set ITs failed with "Error locating assembly descriptor"). The `basedir` parameter is gone; the value comes from the injected `Project`.
- **Dependency resolution**: `DependencyResolverRequest` needs a non-null `pathScope`; `RESOLVE` only returns dependencies with a path type, so `pom`/`zip`/`sar` dependencies would be dropped. The plugin uses `COLLECT` with the project's direct dependencies (pre-filtered by scope as `classpathFilter` did), managed dependencies and project repositories, walks the `Node` tree itself, and resolves each artifact with `Session#resolveArtifact(artifact, projectRepositories)` (without the repositories IT `massembly-1306` fails: the session's repositories are not the project's). `scope=test` needs two collects (`TEST_COMPILE` and `TEST_RUNTIME`) to cover compile, provided, runtime and test; `system` scope rides on `MAIN_COMPILE`. `Node` has no parent link, so the dependency trail is rebuilt during the walk.
- **`useTransitiveFiltering` / caf `actTransitively`**: maven-common-artifact-filters 4 dropped `actTransitively` and the trail (`PatternIncludesArtifactFilter(patterns, boolean)`), so the flag would silently do nothing. `FilterUtils` re-creates it in two private subclasses: the artifact is tried, then every trail element (project, ancestors) until a pattern matches; `patternMatches` cannot tell "no match" from "negated pattern matched", so a second filter with a trailing catch-all `*` is asked as well. Works, but leans on caf's first-match-wins behaviour and on the protected `patternMatches`; a `Predicate<Dependency>` with a real trail (or the flag back) in caf would be cleaner. Tests cover include/exclude via trail.
- **Project of a dependency**: v3 built a `MavenProject` for every dependency (and a stub `MavenProject(Model)` when that failed). v4 has `ProjectBuilder.build(request)` from a POM file (the POM is resolved first) but no way to create a stub `Project`; on failure the plugin continues with no project and uses the artifact itself for `${artifact.*}` (one IT, `including-sar-dependency`, hit that path: the sar's POM does not build). `ProjectBuilderRequest` has no builder switch for `allowStubModel`/validation level (v3 used minimal validation), so POMs v3 tolerated may now fail to build and lose `${artifact.build.finalName}` / `${artifact.properties.x}`.
- **Expression surface of `${project.*}`, `${module.*}`, `${artifact.*}` (descriptors, archiverConfig, filtering)**: v3 reflected over `MavenProject`; v4 `Project` has no bean surface (`getBasedir()` is a `Path`, no `getBuild()` bean tree beyond the model). The plugin evaluates against the effective `Model` plus `basedir`, `file`, `id`. Not reproduced: `${project.artifact.*}`, `${project.attachedArtifacts}`, `${project.compileSourceRoots}`, `${project.artifacts}` style paths. Unverified how many real descriptors use them.
- Project main artifact and attachments: `Project#getMainArtifact()` is empty for pom packaging and `ArtifactManager#getPath` is the only way to a file; pom-packaged projects are treated as having no file (as v3), otherwise `useProjectArtifact` added the POM to the archive (IT `massembly-1022`). Attachment files come from `ArtifactManager`, attachments are created with `Session#createProducedArtifact(..., classifier, extension, null)` plus `ProjectManager#attachArtifact(project, artifact, path)`; the `attachArtifact(session, project, type, path)` default has no classifier parameter. Replacing the main artifact file (`appendAssemblyId=false`) uses `Session#setArtifactPath`.
- `@Mojo` has no `threadSafe` and no `requiresDependencyResolution` attribute (only `dependencyResolutionPathScopes`, unused): resolution happens inside the mojo, and the plugin is not marked thread-safe. `maven-plugin-tools` 4.0.0-beta-3 constructor injection of a mojo is not possible (field `@Inject`).
- `BuildContext` (plexus-build-api) is not bound in the CLI; it is looked up optionally and skipped when absent (it only refreshed the archive for IDEs).
- Build: plexus-archiver 5.0.0-SNAPSHOT changes the `Archiver` interface (removed deprecated methods), so `AssemblyProxyArchiver` (939 lines, implements `Archiver`) had to drop the implementations of the removed methods; it still compiles against 4.14.0 only because the `Archiver` methods it no longer implements would be abstract there, i.e. it does not.
**Removed or changed tests** (nothing else deleted)
- `FilterUtilsTest.filterProjectsShouldNotRemoveProjectTransitivelyIncluded` and `filterProjectsShouldRemoveProjectTransitivelyExcluded`: a reactor project's main artifact has no dependency trail in production (v3 or v4); the tests passed only because the mock returned one.
- `ModuleSetAssemblyPhaseTest.getModuleProjectsShouldExcludeModuleAndDescendentsTransitively`: same reason, it relied on a mocked `getDependencyTrail()`.
- `DefaultDependencyResolverTest` rewritten for the v4 resolver (mocked `DependencyResolver`/`Session`), `AddDependencySetsTaskTest` for the v4 `ProjectBuilder`; one test added (`getDependencySetResolutionRequirementsFiltersByScope`). Test projects/sessions/artifacts are Mockito stubs in the new `testutils/TestStubs`.
**User-visible changes**
- Runs on Maven 4 only and needs Java 17; no 3.x support, a 3.x line must stay for Maven 3 users.
- Parameters removed from the descriptor: `basedir`, `reactorProjects`, `mavenSession` (all readonly). `archiverConfig` is now an `XmlNode` (same XML).
- `<archive>` is the maven-archiver 4 `MavenArchiveConfiguration` (`manifestFile` is resolved as a `Path`).
- Third-party `ContainerDescriptorHandler`s registered with `javax.inject.@Named("hint")` are not found by hint (see Gaps).
- `useTransitiveFiltering` behaviour is preserved by plugin code, not by the library.
- Output of descriptors that used `${project.artifact...}`-style expressions may differ (see Gaps).
**Improvements:** drops `javax.inject`, `sisu-maven-plugin` (Sisu index), `maven-plugin-api`, `maven-core`, `maven-model`, `maven-model-builder`, `maven-artifact`, `maven-resolver-api/util`, `maven-plugin-annotations`; adds `maven-api-core`, `maven-api-di`, `maven-api-model`, `maven-api-xml`, `maven-api-annotations` (provided). `org.eclipse.sisu.plexus` stays provided only for the `ExpressionEvaluator` interface, `plexus-build-api` only for the optional `BuildContext` type. No new runtime dependency. The Plexus configurator, the PlexusContainer lookup and the reflection over `MavenProject` are gone.
**Recommendation:** port for the Maven 4 line once plexus-archiver ships the no-DI unpack fix (first Gap item); until then the plugin depends on an unreleased 5.0.0 and on a patch. Two upstream asks that would remove most hacks: (1) plexus-archiver: unpack without a JSR-330 container, and a released `ServiceLoaderArchiverManager`; (2) Maven core: honour `javax.inject.@Named` hints (or document that only `api.di.@Named` and components.xml keep them), and fix `${project.basedir}` in a reactor. Keep 3.x for Maven 3.
</details>
<details><summary><b>maven-changelog-plugin</b>: blocked</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **blocked**, 4.0.0-beta-1-SNAPSHOT, Java 17. The plugin code ports and compiles; it cannot run, because every consumer of a report mojo is a Maven 3 class.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` before → 23 tests, 0 failures. After → 23 tests, 19 errors, 0 failures (`ChangeLogReportTest` 15, `DeveloperActivityReportTest` 2, `FileActivityReportTest` 2); the 4 tests that pass do not execute a report. `-Prun-its` before → 4/4 ITs pass; after → 0/4 (whole suite, no time-box hit). Spotless clean. No test deleted.
**Concrete build errors (reporting chain)**
1. Against the released `maven-reporting-impl` 4.0.0, with only Maven 4 API dependencies: `cannot access org.apache.maven.plugin.AbstractMojo` at `ChangeLogReport extends AbstractMavenReport`. The released base class extends the Maven 3 `AbstractMojo`.
2. Against the local `maven-reporting-impl` 5.0.0-SNAPSHOT port (see below): compiles, but every unit test that executes a report fails with `IllegalStateException: Cannot get the Maven 3 object from org.apache.maven.impl.InternalSession...#getMavenSession()`. The ported `AbstractMavenReport.execute()` reaches the Plexus container through `LegacyMavenBridge` and `Session.getMavenSession()`. The impl port's own ITs fail the same way at runtime with `A required class was missing ... org/apache/maven/execution/MavenSession`: `maven-core` is not visible in a plugin class realm.
3. Real build, maven-site-plugin 3.22.0 on Maven 4.0.0-rc-7, all 4 ITs: `Failed to get report for org.apache.maven.plugins:maven-changelog-plugin: Unable to lookup Mojo: Cannot cast org.apache.maven.plugins.changelog.ChangeLogReport[Factory] to org.apache.maven.plugin.Mojo`. Site plugin 3.x only accepts Maven 3 mojos as reports.
**Snapshots consumed:** `maven-reporting-impl` 5.0.0-SNAPSHOT, built from `maven-reporting-impl` `agent/mvn4-api` (`mvn install -DskipTests -Dinvoker.skip=true`, installed into the local repository); `maven-reporting-api` 4.0.0 (release).
**User-visible changes**
- Version 3.0.0-M3-SNAPSHOT → 4.0.0-beta-1-SNAPSHOT; needs Maven 4; `<prerequisites>` follows `mavenVersion`.
- Goals and parameter names unchanged: `changelog`, `dev-activity`, `file-activity`.
- `developers`: `List<org.apache.maven.model.Developer>` → `List<org.apache.maven.api.model.Developer>`. The `project.developers` expression default is gone (the Maven 4 test container cannot evaluate an expression to a raw `List`); when unset, the mojo reads `project.getModel().getDevelopers()`. The v4 `Developer` is immutable, so a POM-level `<developers>` override in plugin configuration is no longer expressible as before. Not verified under a real build because of the block above.
- `settings` parameter (`${settings}`) removed; credentials come from `Session.getSettings().getServers()`, matched on `host[:port]`. Users who passed a `Settings` object in test configurations lose that hook.
- `ScmManager` is a Plexus component and v4 DI reports `No binding to construct an instance for key ScmManager` (seen in both unit tests and the first IT run). The mojo now obtains it with `Lookup.lookup(ScmManager.class)` on first use; that path is unexercised in a real build because of error 3.
- `MojoExecutionException` no longer thrown (`MojoException`); `ChangeLogReport.checkResult` is public and now declares `MojoException`.
- Test infrastructure moves to maven-plugin-testing-harness 4.0.0-beta-4, `maven-impl`, Guice and Mockito 5; resolver 1.9.27 → 2.0.23; transport `maven-resolver-transport-http` → `-apache`.
**Gaps**
- No Maven 4 report contract that site plugin 3.x accepts (error 3); needs a v4 maven-site-plugin, which needs the Doxia site-tools port (apache/maven-doxia-sitetools#701).
- No Maven 4 path from a plugin realm to the site renderer (error 2); the reporting-impl port works around it with `MavenSession`, which is not exported.
- No v4 DI route to Sisu/Plexus components (`ScmManager`); `Lookup` is the workaround.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-model`, `maven-settings`, `maven-plugin-annotations`, `javax.inject` and `maven-artifact` (test) from the plugin's own dependencies.
**Recommendation:** do not merge. Keep on 3.x until maven-site-plugin, maven-reporting-impl and doxia-sitetools have v4 releases in that order; then the remaining work here is the test-harness glue (`Lookup`, `Session` settings) and re-running the 4 ITs. The commit is a compile-clean starting point only.
</details>
<details><summary><b>maven-checkstyle-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17. The `check` goal is ported and runs in a real Maven 4.0.0-rc-7 build (30 ITs). The two report goals (`checkstyle`, `checkstyle-aggregate`) are **blocked** by the reporting chain and are excluded from the build; their sources stay in the tree.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn -B -ntp verify` before → 26 tests, 0 failures, 1 skipped; after → 16 tests, 0 failures, 0 skipped (`CheckstyleReportTest` 10 run / 1 skipped removed with the reports; every other test kept: `CheckstyleViolationCheckMojoTest` 6, `RuleUtilTest` 4, `CheckstyleResultsTest` 2, `CheckstyleExecutorTest` 1, both `CheckstyleReportListener*Test` 1, `ViolationTest` 1). `-Prun-its` before → 49/49 invoker ITs pass (24 min); after → 30/30 of the ITs that do not need a report goal pass (`clean verify -Prun-its`, 4:48 min); the other 19 are excluded with `pomExcludes` (list under Gaps). Run unexcluded, the suite was 27 of 49 on the first pass (fixes for the 3 inline-rules ITs applied afterwards, then 30 of 30). Spotless clean. `dependency:analyze` clean.
**Report goals: can they be ported?** No, not today. Concrete errors:
1. Real compile of the unchanged `AbstractCheckstyleReport` against Maven 4 API + released `maven-reporting-impl` 4.0.0: `AbstractCheckstyleReport.java:[64,56] cannot access org.apache.maven.plugin.AbstractMojo` (the released base class extends the Maven 3 `AbstractMojo`, which is not on a v4-only classpath).
2. Even with a v4 `reporting-impl` (the 5.0.0-SNAPSHOT port), site plugin 3.x on rc-7 only accepts Maven 3 mojos as reports: `Unable to lookup Mojo: Cannot cast org.apache.maven.plugins.changelog.ChangeLogReport[Factory] to org.apache.maven.plugin.Mojo` (proven on maven-changelog-plugin, same chain, not re-run here). The port would also need `maven-core` types from reporting-impl at runtime (`MavenSession`), which a plugin realm cannot see.
3. The report classes additionally use Doxia sink/i18n (`CheckstyleReportRenderer`, 696 lines), `MavenProject` and `MavenReportException`; all of that has to move with the chain (doxia-sitetools → site plugin → reporting-impl).
Excluded from compilation: `AbstractCheckstyleReport`, `CheckstyleReport`, `CheckstyleAggregateReport`, `CheckstyleReportRenderer` (compiler `excludes` in the pom; sources kept).
**Non-report goal**
- `check`: mojo implements `org.apache.maven.api.plugin.Mojo`; injected `Session`, `Project`, `MojoExecution`, `Log` and the executor (`@Inject @Named("default")`, field injection because mojo constructor injection fails in rc-7). `MojoExecutionException`/`MojoFailureException` become `MojoException`.
- Executor (`DefaultCheckstyleExecutor`): `@Named("default")` with `org.apache.maven.api.di`, no Sisu `@Typed`; the DI index is generated by the annotation processor (`META-INF/maven/org.apache.maven.api.di.Inject` lists the mojo factory and the executor).
- Source roots: `ProjectManager.getEnabledSourceRoots(project, scope, Language.JAVA_FAMILY)`; resources: the same call with `Language.RESOURCES`, turned into `org.apache.maven.api.model.Resource`. New helper `exec/ProjectRoots`.
- Plugin dependency artifacts for license/config lookup (`${plugin}` `PluginDescriptor.getArtifactMap()` in v3): `MojoExecution.getPlugin().getDependenciesMap()` plus `ArtifactManager.getPath(Dependency)`; proven by ITs `MCHECKSTYLE-225-customHeader`, `-225-pluginManagement`, `-225-LICENSE.txt`, `-219-*` (license read from a plugin-dependency jar).
- Classpath for Checkstyle (`project.getTestClasspathElements()` in v3): `Session.resolveDependencies(project, PathScope.TEST_COMPILE | MAIN_COMPILE)` plus the output directories. A resolution failure logs a warning and continues with the output directories only (v3 with `requiresDependencyResolution=NONE` never failed here).
**plexus-resources without Sisu (how `ResourceManager` was obtained)**
`DefaultCheckstyleExecutor` and `LicenseResourceManager` no longer get `ResourceManager`/`Map<String,ResourceLoader>` injected. plexus-resources 1.4.0 is a Sisu component library but its classes are plain: `javap` of `plexus-resources-1.4.0.jar` shows `DefaultResourceManager` has `public DefaultResourceManager(Map<String,ResourceLoader>)` and `FileResourceLoader`, `JarResourceLoader`, `URLResourceLoader`, `ThreadContextClasspathResourceLoader` all have public no-arg constructors. Their `@javax.inject.Named` values (read from the class files) are `file` (`FileResourceLoader.ID`), `jar`, `url`, `classloader`. The executor builds `new LinkedHashMap` with those four and passes it to `new DefaultResourceManager(map)` or `new LicenseResourceManager(map)`. The loaders keep search paths, so every `executeCheckstyle` call builds fresh instances (the v3 singleton managers were reconfigured on every call). No `Lookup`, no Sisu, no `@Named("license")` binding. `LicenseResourceManager` keeps i
ts `instanceof ThreadContextClasspathResourceLoader` filter (MCHECKSTYLE-219), which works because the loader class is unchanged.
**User-visible changes**
- Version 3.6.1-SNAPSHOT → 4.0.0-beta-1-SNAPSHOT; needs Maven 4.0.0-rc-7; Java 17.
- Goals: `check` and `help` only. `checkstyle:checkstyle` and `checkstyle:checkstyle-aggregate` are gone until the reporting chain is ported; `<reporting>` entries and `checkstyle:checkstyle checkstyle:check` command lines break.
- `check` parameters unchanged, except: `resources` and `testResources` (read-only, `${project.resources}`) and the injected `project`/`plugin` parameters are no longer parameters; `checkstyleRules` is `org.apache.maven.api.xml.XmlNode` instead of `PlexusConfiguration`; `threadSafe` has no v4 attribute.
- The mojo no longer fails the build with the `MojoFailureException` type: a violation failure and an execution failure are both `MojoException` (message unchanged; build result is FAILURE either way).
- `checkstyleRules` inline config: Maven 4.0.0-rc-7 drops all attributes when it injects an `XmlNode` parameter (`-X` shows the configuration with `<module name="Checker">` and `(f) checkstyleRules = <module>...` without `name`; `inlinerules`, `MCHECKSTYLE-295`, `-371` fail with `Attribute "name" is required ... for element type "module"`). The mojo reads the node from `MojoExecution.getConfiguration()` instead, and writes it with `XmlService.write` (`XmlNode.toString()` is not XML). Consequence: `${...}` expressions inside the inline rules are not evaluated (they were not with `PlexusConfiguration` either).
- Checkstyle classpath now comes from an explicit dependency resolution, so `check` on a module whose dependencies cannot be resolved warns instead of silently using only the output directories.
- Test infrastructure: maven-plugin-testing-harness 3.5.1 → 4.0.0-beta-4, plus `maven-impl`, `maven-core`, `maven-xml`, Guice 6; test configs use `${project.basedir}` (the harness does not evaluate `${basedir}`); slf4j 1.7.36 → 2.0.19; resolver test dependencies dropped.
- ITs edited: `MCHECKSTYLE-131`, `inlinerules`, `multi-modules`, `multimoduleproject` ran `clean checkstyle:checkstyle checkstyle:check`; now `clean checkstyle:check` (`check` runs the analysis itself). Their assertions are unchanged and pass.
**Gaps**
- Report goals: see above. 19 ITs excluded in the `run-its` profile because they call `checkstyle:checkstyle`, `site`, or bind the `checkstyle` goal: `MCHECKSTYLE-137`, `-172`, `-193`, `-222-no-resources`, `-222-resources`, `-222-testResources`, `-224`, `-253-jdk8`, `-332_cache-checker`, `-338`, `-357`, `-357-with-header-override`, `-365`, `-99`, `-99-custom-xref-test-location`, `checkstyle-goal`, `checkstyle-report`, `minimal-pom`, `multi-modules-aggregate`. Not deleted; they pass again when the report goals return. Their failure on the ported plugin is `Could not find goal 'checkstyle' in plugin ...:maven-checkstyle-plugin:4.0.0-beta-1-SNAPSHOT among available goals check, help`.
- `XmlNode` parameter injection loses attributes in Maven 4.0.0-rc-7 (workaround above; a core issue).
- `org.apache.maven.api.model.Resource` is deprecated in rc-7 (javac warning) in favour of `SourceRoot`; kept because the executor request and `addResourceFilesToProcess` only need directory, includes and excludes.
- No v4 equivalent of `Plugin.getArtifactMap()` for transitive plugin-realm artifacts; `getDependenciesMap()` covers the direct `<dependencies>` of the plugin, which is what v3 code looked up.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-model`, `maven-artifact`, `maven-plugin-annotations`, `javax.inject`, `org.eclipse.sisu.plexus`, `org.eclipse.sisu.inject`, `sisu-maven-plugin`, `animal-sniffer-maven-plugin` (Java 8 signature), `maven-reporting-api`/`-impl`, `doxia-core`/`-sink-api`/`-integration-tools` and `plexus-i18n` from the plugin's own dependencies; resource managers are no longer singletons with shared search paths.
**Recommendation:** do not merge. `check` is a usable starting point and keeps every `check` IT green on rc-7. Keep the plugin on 3.x until maven-site-plugin, maven-reporting-impl and doxia-sitetools have v4 releases in that order; then restore the four report classes (port `MavenProject` to `Project`, `MavenReportException` to the v4 report contract) and re-enable the 19 ITs. Separately worth filing against Maven core: the `XmlNode` attribute loss.
</details>
<details><summary><b>maven-dependency-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17. 25 of 29 goals ship and run on Maven 4.0.0-rc-7; `add`, `remove`, `list-repositories` and `analyze-report` are not shipped.
Verified locally: `mvn verify`, Maven 4.0.0-rc-7, JDK 21. Unit tests before 435 run, 0 failed, 1 skipped; after 174 run, 0 failed, 0 skipped (accounting under Gaps). spotless:check, checkstyle, RAT, enforcer and the plugin's own `analyze-only` (strict) pass. ITs (`-Prun-its -Dinvoker.test=` subset, only ported goals, 30 min time-box): before, 75 builds, 74 passed, 1 failed (`unpack-custom-ear`, fails on the unchanged tree; `purge-local-repository-bad-pom` failed once and passed on rerun) in 1534 s; plus 19 more, 18 passed, 0 failed, 1 skipped (`analyze-exclusions-gh-1598`, the IT excludes Maven 4 itself) in 236 s. After, 94 builds: 85 passed, 8 failed, 1 skipped (582 s), then `mdep-450-*` rerun after a fix, 2 of 2 passed. The 8 failures: `unpack-custom-ear` (same as before), `analyze-report`, `analyze-testDependencyWithNonTestScope`, `list-repositories` (goals not shipped), `tree-verbose`, `tree-verbose-small`, `used-dependencies`, `mdep-450-project-with-ancestor` (fixed after tha
t run). IT subset: analyze*, build-classpath*, collect, copy*, filterunpack, get-*, mdep-4xx..9xx for ported goals, purge-local-repository*, resolve*, go-offline*, tree*, unpack*, used-dependencies, dependency-properties, list-repositories, analyze-report. Not run: add-dependency, remove-dependency, setup-custom-ear-lifecycle.
Shared snapshots consumed (built from the local branch agent/mvn4-api, commit "Port to the Maven 4 API"): maven-dependency-tree 4.0.0-SNAPSHOT a610f3b1ab9e01de142ae84b4363fcaa1db4ac50; maven-dependency-analyzer 2.0.0-SNAPSHOT f10337cef52a2366f4c46a685bef853a31d5484f; maven-common-artifact-filters 4.0.0-SNAPSHOT c2fdc406acfb36807bf1dd1f31eeecee510bb40f. Experiment only, not a dependency of the result: maven-reporting-impl 5.0.0-SNAPSHOT 21c3da415d7ebcf965f2dc1e1c101164220cdb74. plexus-archiver stays the released 4.14.0; its `ArchiverManager` is a Sisu component that a v4 mojo cannot have injected and the `Lookup` service does not find in the plugin realm, so `UnpackUtil` builds `DefaultArchiverManager` by hand from the `UnArchiver` entries of plexus-archiver's `META-INF/sisu/javax.inject.Named` (new compile dependency `javax.inject:javax.inject:1` for `Provider`/`Named`).
**Per-goal table**
| Goal | Status | Missing API / difference |
|---|---|---|
| tree | ported | verbose output differs (dependency-tree 4 port has no premanaged/conflict data): "(scope not updated to compile)" lost, "scope updated from compile" added; tree-verbose ITs fail. Root node has no dependency, so include/exclude patterns are matched against the project in the mojo |
| analyze, analyze-only | ported | params `baseDir`, `outputDirectory` removed (`${basedir}` does not evaluate). `analyze` forks via `@Execute(phase="test-compile")`; the forked build does not leave reactor siblings resolvable, so `used-dependencies` (multi-module) fails |
| analyze-dep-mgt, analyze-duplicate, analyze-exclusions | ported | analyze-exclusions needs model `InputLocation` (present on `Project.getModel()`); only exercised by hand, its IT skips Maven 4 |
| analyze-report | no run route | port compiles against reporting-impl 5.0.0-SNAPSHOT (source changed, excluded from compile). Running: class `org.apache.maven.execution.MavenSession` not found in the v4 plugin realm; with maven-core added, "A type incompatibility occurred" (two copies of core classes). Reporting chain, not plugin code |
| copy, copy-dependencies, unpack, unpack-dependencies | ported | `BuildContext` (m2e) gone: `skipDuringIncrementalBuild` accepted, no effect |
| resolve, list, collect, resolve-sources, sources | ported | collect uses `DependencyResolver.flatten` (no download); "sources" classifier fixed at run time (no `@Parameter` on setters) |
| build-classpath | ported | attach via `ProjectManager` |
| get, list-classes, properties, display-ancestors | ported | relocation and POM download re-implemented (resolver no longer reads descriptors) |
| purge-local-repository | ported | "launched from CLI" approximated by execution id `default-cli`; relocation/descriptor as above |
| go-offline, resolve-plugins | ported | plugin `<dependencies>` scope and exclusions cannot reach the v4 request (resolved as compile, no exclusions) |
| render-dependencies | ported | templates see a `TemplateArtifact` bean with the Maven 3 getters |
| list-repositories | no v4 route | `RemoteRepository` has no mirrored-repositories or policy; IT expects "mirrored by" and "releases+snapshots" |
| add, remove | not ported | need raw/original model and in-memory model update (`syncInMemoryModel`); not attempted, `pom/DependencyEntry` kept |
**Public API changes**
- Every mojo implements `org.apache.maven.api.plugin.Mojo`, `@Inject` fields, unchecked `MojoException`; Maven 3 `Artifact` replaced by `ResolvedDependency` (new, path + coordinates) and `api.Dependency`; `ResolverUtil`, `CopyUtil`, `UnpackUtil` are plain classes, not components; `ArtifactItem.getArtifact()` returns `DownloadedDependency`; filters/markers/translators take `Dependency`; `DependencyUtil` gains `getId`, `toString`, `getDependencyConflictId`.
**Gaps**
- Resolver behaviours lost and rebuilt: POM download and relocation (`Session.resolveArtifact`), pre-order artifact order, `Project.getParent()` empty for repository parents, purge root-dependency scope semantics.
- plugin-tools 4.0.0-beta-3 crashes on `@Mojo(dependencyCollection = true)`, so `requiresDependencyCollection` is dropped; `requiresDependencyResolution`, `threadSafe` have no v4 attribute (resolved inside the mojo).
- Tests: 435 to 174. Kept/ported: utils, filters, markers, translators, ArtifactItem, matchers, pruning visitor, ExclusionChecker, reactor filters, TestAnalyzeDepMgt (4 of 5; `mojo()` removed), ResolverUtilTest (22 to 18, descriptor/installer/collect cases rewritten for the v4 calls), pom/* (58, domtrip test scope); new ResolvedDependencyTest (4), TreeSerializationTest (5, replaces TestTreeMojo, whose mojo-discovery case is removed). Not compiled (files remain, excluded by `testIncludes`, Maven 3 harness with `MavenProject`/`MavenSession` stubs; ITs cover the goals): AddDependencyMojoTest 36, RemoveDependencyMojoTest 12, AnalyzeExclusionsMojoTest 9, GoOfflineMojoTest 9, ResolveDependenciesMojoTest 4, TestAnalyzeDuplicateMojo 2, TestBuildClasspathMojo 2, TestCollectMojo 3, TestCopyDependenciesMojo 35 + 2: 14, TestCopyMojo 29, TestGetMojo 8, TestIncludeExcludeUnpackDependenciesMojo 7, TestIncludeExcludeUnpackMojo 11, TestListClassesMojo 4, TestPropertiesMojo 2, TestRenderDependencie
sMojo 2, TestResolveMojo 2, TestSkip 19, TestTreeMojo 6, TestUnpackDependenciesMojo 27 + 2: 5, TestUnpackMojo 17.
**User-visible changes**
- Runs on Maven 4 only, Java 17; 3.x line must stay for Maven 3. Goals `add`, `remove`, `list-repositories`, `analyze-report` absent. Parameters `baseDir`, `outputDirectory` (analyze) removed; `skipDuringIncrementalBuild` no-op; `render-dependencies` templates keep Maven 3 getters; tree verbose annotations differ; `dependency:analyze` on a multi-module reactor needs siblings already built (use `analyze-only` in the lifecycle).
**Improvements:** drops maven-core, maven-plugin-api, maven-model, maven-artifact, maven-settings, maven-repository-metadata, maven-resolver-*, plexus-build-api, sisu.plexus, plexus-i18n, maven-shared-utils, javax.inject annotations build; test side drops jetty and plugin-testing-harness. Adds maven-api-*, three shared snapshots, `javax.inject`, slf4j-api (provided).
**Recommendation:** ship the ported goals on the Maven 4 line, keep 3.x for Maven 3. Before a real PR: fix the dependency-tree verbose data, decide `@Execute` reactor behaviour upstream in Maven, file a plugin-tools issue for `dependencyCollection`, and port add/remove (route exists, unattempted).
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919283521
### Wave 4 findings, part 3 of 4: maven-javadoc-plugin to maven-rar-plugin
Each plugin is a local branch `agent/mvn4-api` with a "Build with Maven 4 only" commit and a "Port to the Maven 4 API" commit; the PRs are not opened yet.
<details><summary><b>maven-javadoc-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17. Every goal is ported and runs as a direct goal on Maven 4.0.0-rc-7; nothing runs as a site report (blocked).
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn clean verify` → 72 tests before (8 skipped, 0 failures), 75 after (8 skipped, 0 failures; 3 added); spotless, RAT and checkstyle pass. `-Prun-its` (93 ITs, run as two `-Dinvoker.test=` halves because the suite exceeds the 30 min time-box) → before 79 passed, 3 failed, 11 skipped; after 75 passed, 7 failed, 11 skipped. Pre-existing failures, before and after: MJAVADOC-181, MJAVADOC-444 (both `site`), MJAVADOC-568_jar-mixed. The 4 new failures are all `site` ITs (MJAVADOC-134_multiaggregate, -259, -369, site-failOnError), see Gaps. The other 89 outcomes are identical. Skipped: JRE-version (doclava, JDK 23 fonts) and toolchain-version ITs. No test deleted; 13 `MavenProjectStub` classes removed because the v4 harness reads the POM (see tests below). `testJavadocResourcesWithExcludes` fails on a second run without `clean`, before and after.
**Per-goal status**
| goal | status | evidence |
|---|---|---|
| `jar` | ported | ITs MJAVADOC-137_jar, -812, -568_export-to-testcase, -599, -639_requires_ignored, reproducible, -610_mrjar, toolchain probe below; `package` build with attach and install |
| `test-jar` | ported | no IT in the repo; probe project `package`+`install` attached and installed `-test-javadoc.jar` |
| `aggregate-jar`, `test-aggregate-jar` | ported | ITs MJAVADOC-599, -618_modular-war, -639_requires_ignored; probe for test-aggregate-jar (jar contains the module's test class page) |
| `resource-bundle`, `test-resource-bundle` | ported | probe: both bundles built, attached, installed; bundles consumed by dependencySource-1..4 ITs |
| `javadoc`, `test-javadoc`, `aggregate`, `test-aggregate`, `*-no-fork` | ported as direct goals (`mvn javadoc:javadoc`) | about 50 ITs use them; partial as reports: `mvn site` has no v4 route |
| `fix`, `test-fix` | not in this source version | removed before this branch (plugin.xml lists 15 goals, `help` included) |
| toolchains | ported | `jdkToolchain` with JDK 21 running Maven and a JDK 8 toolchain: log `Toolchain in maven-javadoc-plugin: JDK[...zulu-8...]`, JDK 8 output (`allclasses-frame.html`); build-context path via maven-toolchains-plugin 3.2.0 + `jar` in one `package` build also selects JDK 8 |
| module path | ported, plexus-java kept | ITs MJAVADOC-498_modulepath, -498_mm_modulepath, -449_aggr_modulepath, -639_aggr_static_modulepath, -555_link-automatic-modules, -575, -556, -568_manifest-splitpackage pass; see Gaps for why `JavaPathType` is not used |
| `detectLinks`, `detectOfflineLinks`, `detectJavaApiLink` | ported | ITs MJAVADOC-580_detectLinks, detectLinks, -592, -495, -642_cmdline, -320, -275; probe: `detectLinks` resolved the dependency POM through `ArtifactResolver` + `ProjectBuilder` and validated the URL online → `-link https://commons.apache.org/proper/commons-lang/apidocs` |
| `additionalDependencies`, `docletArtifact(s)`, `tagletArtifact(s)`, `resourcesArtifacts` | ported | doclet/taglet ITs need JDK ≤13, so probes: `-docletpath` and `-tagletpath` held the artifact plus its compile-scope transitive dependencies, `-classpath` held the additional dependency; unit tests cover taglet/stylesheet/helpfile artifacts |
| dependency sources (`includeDependencySources`) | ported | ITs dependencySource-1..4, MJAVADOC-338, -494_aggregate-repositories, -526 |
Differential check of the report goals: the released 3.11.2 and this port run on the same probe projects under Maven 4.0.0-rc-7. The `-X` parameter dump of all 7 non-site goals is identical except `detectOfflineLinks` (3.11.2 had an older default) and the injected objects. For `aggregate` on a two-module reactor with provided and runtime scopes the `javadoc` options file is byte identical after path normalisation; `javadoc` and `test-javadoc` differ only in class path order. This found three defects that the ITs had not (fixed): `${project.name}` left unevaluated, `system` scope dependencies dropped, runtime dependencies missing from the test class path.
**Concrete build error (reporting chain):** as in the changelog finding. Real build, maven-site-plugin 3.22.0 on rc-7, MJAVADOC-134_multiaggregate: `Failed to get report for org.apache.maven.plugins:maven-javadoc-plugin: Unable to lookup Mojo: Cannot cast org.apache.maven.plugins.javadoc.AggregatorJavadocReportFactory to org.apache.maven.plugin.Mojo`. `reporting-api` 4.0.0 has no Maven 3 dependency, so `MavenMultiPageReport` is still implemented and compiles; only the site plugin is missing.
**User-visible changes**
- Needs Maven 4.0.0-rc-7 and Java 17 (was 3.6.3 / 8); version 3.12.1-SNAPSHOT → 4.0.0-beta-1-SNAPSHOT.
- Goals, parameter names, properties and defaults are unchanged (defaults compared by the differential run above). Exceptions: `jarOutputDirectory` and `finalName` no longer take `-Dproject.build.directory` / `-Dproject.build.finalName` (a v4 `property` is a user property, not an expression; now `defaultValue`); `${basedir}` defaults are `${project.basedir}`.
- `additionalDependencies` element type `AdditionalDependency` is now a plain bean (groupId, artifactId, version, type, classifier, scope) instead of a subclass of the model `Dependency`; `<exclusions>`, `<optional>`, `<systemPath>` inside it are no longer accepted.
- Class hierarchy: the `*NoFork*` mojos are now the base classes and the forking ones subclass them (an inherited `@Execute` cannot be cancelled). `TestJavadocReport` no longer extends `JavadocReport`. The plugin descriptor shows the same goals and `executePhase` values.
- No `requiresDependencyResolution`: the mojos resolve in `execute()` (javadoc/jar: compile + provided + direct system; test goals: + test + runtime), so a goal no longer fails before the mojo for an unresolvable dependency but inside it.
- `locale` is validated against the JVM locales only; the Doxia site tool also required a Maven Site translation.
- Nested Maven runs for `detectOfflineLinks` use the default settings and toolchains files; `-s`, `-gs`, `-t`, `-gt` are not passed on (no v4 API).
- Class path order of the dependencies differs from 3.x (same set).
- `mvn site` with the plugin under `<reporting>` fails until maven-site-plugin has a v4 release.
- Public/protected Java API: `AbstractJavadocMojo` implements `org.apache.maven.api.plugin.Mojo`; constructors with injected components are gone (field `@Inject` of `Session`, `Project`, `MojoExecution`, `Log`); `MavenProject`/`MavenSession`/`Toolchain` signatures become `Project`/`Session`/`org.apache.maven.api.Toolchain`; `ResourceResolver` is a plain class (was a Sisu component) and `SourceResolverConfig` takes a `Session`; `resolveDependency` takes `AdditionalDependency` and returns a `Path`.
**Gaps**
- Site reports: no v4 report contract accepted by maven-site-plugin 3.x (error above); needs the v4 site plugin and the Doxia site-tools port.
- `@Execute(phase = "none")` fails plugin-tools 4.0.0-beta-3 (`No enum constant LifecyclePhase.none`) and `@Execute` is inherited, so no-fork mojos cannot opt out; worked around by reordering the classes.
- No `requiresDependencyResolution` and no `threadSafe` attribute on `@Mojo`.
- No `PathScope` includes `system`, and none combines compile, provided, runtime and test. The resolver therefore drops system dependencies (probe: `-classpath` empty where 3.11.2 had the jar) and the runtime scope for test goals. Workaround: direct `system` dependencies are read from the model's `systemPath`, test goals merge `TEST_COMPILE` and `TEST_RUNTIME`. Transitive system dependencies stay missing.
- `DependencyResolverResult.getDispatchedPaths()` (what the jlink port uses) is not adopted for the module path: on a probe with `requires org.objectweb.asm` only, it still put the unrequired named module commons-lang3 on `MODULES`, and the result is the same before and after `compile`. The javadoc logic needs the main descriptor parsed from `module-info.java` sources (the `javadoc` goal forks only `generate-sources`), `requires static`, patch-module and `Automatic-Module-Name` cases, which plexus-java `LocationManager` provides; it depends on no Maven 3 type and stays. A switch would change which JARs go on the module path.
- `${project.name}` does not evaluate in parameter defaults and `${project.model.name}` has no artifact id fallback and stays literal when the project has no name; the titles are resolved in code.
- `Project.getBuild().getSourceDirectory()`/`getResources()` are not reliable in v4; `ProjectManager.getEnabledSourceRoots` is used. Project instances are not identity stable, so projects are compared by GAV.
- Session exposes no settings or toolchains file location from `-s`/`-gs`/`-t`/`-gt`, only the configured defaults (`Constants.MAVEN_USER_SETTINGS` etc.).
- Doxia `SiteTool` (doxia-integration-tools) is bound to Maven 3 types and Sisu: dropped, locale parsing reimplemented. Plexus `ArchiverManager` cannot be injected: `new JarArchiver()` / `ZipUnArchiver` are used directly.
- Test harness (maven-testing rc-7): object-array parameters that declare a `property` make `MojoExtension` throw an NPE unless the test POM lists the element; an exact `${project.basedir}` evaluates to a `Path`, so a `String` parameter stays null; `ProjectStub.getLanguage()` is null (the mojo treats a null language as Java); a test `@Provides` needs `@Singleton`.
**Tests:** the 13 stubs under `src/test/java/.../stubs` are replaced by `TestSessions` (mock session with source roots, dependencies, artifact resolution from a local repo directory) and POM-based reactor projects; 37 test POMs list empty object arrays, use `${project.basedir}`, and three aggregate configs declare `<modules>`; `stale-test` declares `jar` packaging (it said `pom`, which the old harness ignored). Added: default titles fall back to the artifact id, system scope class path, test goal runtime class path, locale parsing.
**Shared snapshots consumed:** `maven-common-artifact-filters` 4.0.0-SNAPSHOT (from `maven-common-artifact-filters`, branch `agent/mvn4-api`, already in the local repository). Released: `maven-archiver` 4.0.0-beta-5, `maven-reporting-api` 4.0.0.
**Improvements:** drops `maven-core`, `maven-model`, `maven-settings`, `maven-plugin-api`, `maven-artifact`, `maven-plugin-annotations`, `maven-resolver-api/impl/util`, `javax.inject`, `maven-reporting-impl` (javadoc link only), `doxia-integration-tools`, the Sisu index plugin, and the test dependencies `maven-plugin-testing-harness`, resolver connector/transport, Sisu; Mockito 4.11 → 5.24.
**Recommendation:** port the non-report goals (`jar`, `test-jar`, `aggregate-jar`, `test-aggregate-jar`, `resource-bundle`, `test-resource-bundle`) and direct `javadoc:*` use; they are complete and verified. Do not merge as a replacement for 3.x: `mvn site` reporting breaks until maven-site-plugin, maven-reporting-impl and doxia-sitetools have v4 releases in that order, and `common-artifact-filters` 4.0.0 must be released first. Keep a 3.x line. Open question for plugin-tools: make `@Execute` cancellable (or accept `none`) so the no-fork mojos need not become base classes.
</details>
<details><summary><b>maven-jdeprscan-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` and `mvn verify -Prun-its` with Maven 4.0.0-rc-7, JDK 21 → unit tests 3 before, 6 after (new: `ToolchainSelectionTest`, 3 tests), 0 failures; ITs 6 passed, 1 skipped before and after (invoker), 0 failures; spotless clean; `dependency:analyze-only` runs and passes.
**User-visible changes**
- Plugin now requires Maven 4.0.0-rc-7 (`<prerequisites>` follows `mavenVersion`) and Java 17 (was Maven 3.6.3 / Java 8). It no longer runs under Maven 3.
- Goals `jdeprscan`, `test-jdeprscan`, `list` and all parameters (`failOnWarning`, `forRemoval`, `release`, `for-removal`) keep their names, properties and defaults.
- `@Mojo(threadSafe = true)` is gone: the v4 `Mojo` annotation and `MojoDescriptor` have no thread-safety flag.
- `list` loses `requiresDirectInvocation = true`: the v4 annotation has no such attribute (the descriptor has `directInvocationOnly`, the annotation cannot set it), so `plugin.xml` now says `directInvocationOnly=false`. The goal has no default phase, so it is still not bound implicitly.
- `requiresDependencyResolution` (COMPILE / TEST) is replaced by an explicit `DependencyResolver.resolve(session, project, PathScope.MAIN_COMPILE | TEST_COMPILE)` in the mojo. The `--class-path` order is kept: classes directory (plus main classes for `test-jdeprscan`), then dependencies.
**Gaps**
- None blocking. v4 `ToolchainManager` covers both lookups the old code needed: `getToolchainFromBuildContext(session, "jdk")` and `getToolchains(session, "jdk", {version=[9,)})`. The reflection fallback for Maven 3.3.0 is gone because the API has the method directly.
- `Toolchain.findTool("jdeprscan")` exists on the v4 interface, so no toolchain internals are needed.
**Improvements:** drops `maven-core`, `maven-plugin-api`, `maven-model`, `javax.inject` (constructor injection replaced by `@Inject` fields on `Session`, `ToolchainManager`, `DependencyResolver`, `Log`); adds only `maven-api-core`, `maven-api-di`, `maven-api-model` (provided). No new test dependency: the toolchain-selection test uses `java.lang.reflect.Proxy` stubs. `commons-lang3` and `plexus-utils` (`Commandline`, `CommandLineUtils`) stay because forking the tool has no v4 API.
**Recommendation:** port; it is small and needs no shared component. Ship as 4.0.0-beta-1 on master and keep a 3.x line for Maven 3 users.
</details>
<details><summary><b>maven-jdeps-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 11 unit tests before and after, 0 failures; `mvn verify -Prun-its` → 7 passed, 0 failed, 2 skipped before (5m13s) and after (5m44s), the two skipped are `unsupported-api_main`/`unsupported-api_test` ("SKIPPED due to JRE version", same before and after); spotless clean. Toolchain fallback checked by hand (see Gaps). Shared snapshots consumed: none.
**Public API changes** (Mojo base class, for subclasses only)
- `AbstractJDepsMojo` implements `org.apache.maven.api.plugin.Mojo` instead of extending `AbstractMojo`; `@Inject` fields for `Log`, `Project`, `Session`, `ToolchainManager` (`org.apache.maven.api.services`), `DependencyResolver`. The `(ToolchainManager)` constructor is gone.
- `getProject()` returns `org.apache.maven.api.Project`; `getClassesDirectory()` returns `Path`; `getClassPath()` no longer throws `DependencyResolutionRequiredException`; new abstract `getPathScope()`.
- Mojos declare `@Mojo(name, defaultPhase)` with string phases; `execute()` throws the unchecked `MojoException`. `dotOutput` is a `Path`. Goal names, parameter names and `-D` properties are unchanged.
**Gaps**
- `@Resolution` field injection does not work with maven-plugin-tools 4.0.0-beta-3: the generated `plugin.xml` has no `<resolutions>`, the field stays null (NPE "this.resolution is null" in all 7 ITs). Maven core supports it (`DefaultMavenPluginManager` reads `getResolutions()`), the descriptor generator does not write it (`PluginDescriptorFilesGenerator` only writes `dependencyResolution`). Worked around with an injected `DependencyResolver` and `resolve(session, project, PathScope)` inside `execute()`.
- Constructor injection of a mojo fails: the generated `JDKInternalsMojoFactory` calls a no-arg constructor ("method 'void <init>()' not found"). Field injection only.
- `threadSafe = true` has no v4 `@Mojo` attribute; the flag is dropped, nothing replaces it.
- `requiresDependencyResolution` has no attribute either (only `dependencyResolutionPathScopes`, whose generation I did not test). Resolution therefore happens on first use inside the mojo, not before it.
- v3 `getCompileClasspathElements()`/`getTestClasspathElements()` included the project's own output directories; v4 `resolveDependencies` returns dependencies only, so the mojos prepend `getOutputDirectory(ProjectScope.MAIN/TEST)` themselves. `ResolutionScope.TEST` maps to `PathScope.TEST_RUNTIME`, `COMPILE` to `MAIN_COMPILE`.
- `project.getArtifacts()` (used to match `dependenciesToAnalyzeIncludes`) maps to `DependencyResolverResult.getDependencies()` keyed by `groupId:artifactId`; same filtering.
- Toolchains: covered. `org.apache.maven.api.services.ToolchainManager` has `getToolchainFromBuildContext(Session, "jdk")` (Optional) and `getToolchains(Session, "jdk", Map)`, which replaces the 3.2.6 reflection hack; `Toolchain.findTool("jdeps")` is unchanged. Checked by hand with the installed plugin and a `toolchains.xml` holding only zulu-8: jdeps ran from `zulu-8.jdk/.../bin/jdeps` with the file and from the `zulu-21.jdk` JAVA_HOME with an empty `<toolchains/>`. Not tested: a toolchain selected by `maven-toolchains-plugin` (the build-context branch). No IT exercises toolchains, before or after.
**User-visible changes**
- Runs on Maven 4 only (v4 mojo descriptor); the plugin needs Java 17 to run. No 3.x support, so a 3.x line must stay for Maven 3 users.
- Readonly parameters `project`, `session` are removed from the descriptor.
- `src/site/markdown/index.md` still describes Maven 3.2.6 toolchain behaviour and the workflow still lists JDK 8 in `matrix-exclude`; neither was touched.
**Improvements:** drops `javax.inject`, `maven-plugin-annotations`, `maven-plugin-api`, `maven-core`, `maven-model`, `maven-artifact`; adds `maven-api-core`, `maven-api-di`, `maven-api-annotations` (provided). `commons-lang3` and `plexus-utils` stay (`MatchPatterns`, `Commandline`). The reflection on `ToolchainManager.getToolchains` is gone.
**Recommendation:** port for the Maven 4 line, keep 3.x for Maven 3. Nothing in the plugin is blocked; the two tooling gaps (`@Resolution` descriptor output, constructor injection) are worth a plugin-tools issue.
</details>
<details><summary><b>maven-jlink-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` and `mvn verify -Prun-its` with Maven 4.0.0-rc-7, JDK 21 → unit tests 14 before (1 skipped, the Windows-only one), 17 after (1 skipped); ITs 28 passed, 1 skipped before and after (invoker, 23 min before, 21 min after); 0 failures; spotless clean; `dependency:analyze-only` (failOnWarning) passes. One removed test: `getCompileClasspathElementsShouldSkipPomTypeArtifacts`, because the code it covered (`project.getArtifacts()`, skipping `pom` artifacts) is gone; the resolver returns paths only. Four new tests for module-path resolution (plain JAR, directory without descriptor, project `module-info.class`, project without it).
**Do the v4 APIs cover toolchains and module-path resolution?** Yes for both, with two small workarounds.
- Toolchains: `ToolchainManager.getToolchains(session, "jdk", requirements)`, `getToolchainFromBuildContext(session, "jdk")`, `Toolchain.findTool("jlink")` and `Toolchain.matchesRequirements(...)` replace the reflection on `getToolchains`, the `ToolchainPrivate` cast and `JavaToolchainImpl`. No gap.
- Module path: `DependencyResolver.resolve(session, project, PathScope.MAIN_RUNTIME)` replaces `requiresDependencyResolution = RUNTIME`, `project.getArtifacts()` and plexus-java `LocationManager`. On a probe project (asm 6.0 with `module-info.class`, commons-lang3, `javax.inject:1` with no module name) `getDispatchedPaths()` gave `JavaPathType.MODULES` = asm, lang3 and `CLASSES` = javax.inject, i.e. the same split the old code made (module, module, skipped as automatic). The mojo uses `getPaths()` plus `DependencyResolverResult.getModuleDescriptor(path)` because it needs the module name and the automatic flag; the resulting `--add-modules` set was identical to the 3.x plugin's on the probe (asm, lang3, project).
- Workaround 1: `getModuleDescriptor` returns empty for the project's own `target/classes`, so the project's `module-info.class` is read with `java.lang.module.ModuleDescriptor.read`.
- Workaround 2: it also returns empty for a JAR with only a file-name-based automatic name (plexus-java returned an automatic descriptor). An empty result for a regular file is treated as automatic and skipped; for a directory it is still the "does not have a module-info.java file" error.
- Not expressible: the toolchain's JDK home can no longer be passed to module resolution (`ResolvePathsRequest.setJdkHome`). No IT or probe output changed; effect on system-module resolution is unmeasured.
**User-visible changes**
- Requires Maven 4.0.0-rc-7 (`<prerequisites>` follows `mavenVersion`) and Java 17 (was Maven 3.6.3 / Java 11).
- `additionalResources` element type is now `org.apache.maven.shared.filtering.Resource` (maven-filtering 4) instead of the model `Resource`; `MJLINK-80_additionalResources` passes with the same configuration.
- All other parameters and the `jlink` goal keep names, properties and defaults. `requiresDependencyResolution` is now an explicit resolve in the mojo.
- The `jlink` packaging (artifact handler and lifecycle mapping) is still declared in `META-INF/plexus/components.xml`. Maven 4.0.0-rc-7 still honours it: every IT with `<packaging>jlink</packaging>` and `<extensions>true</extensions>` passes. The native SPI (`TypeProvider`, `LifecycleProvider`, `PackagingProvider`) was not adopted.
- The classified artifact is attached with `Session.createProducedArtifact(..., classifier, "zip", "jlink")` and `ProjectManager.attachArtifact`; the unclassified one replaces the project's main artifact as before. `projectHasAlreadySetAnArtifact` now asks `ProjectManager.getPath`.
**Gaps**
- `ProjectManager` is not bound for `@Inject`; a `Providers` class with `@Provides` (as in maven-jar-plugin) supplies it. Same for plexus-build-api's `BuildContext`, which maven-filtering 4 needs.
- `ThreadBuildContext` needs `org.codehaus.plexus.logging`, which the plugin realm does not see for a plain `jar` project (`MJLINK-52_classifiers_duplicate_classifier` failed loading `org.codehaus.plexus.logging.AbstractLogEnabled`); `org.eclipse.sisu.plexus` is declared for it (as maven-resources-plugin does) and whitelisted for `dependency:analyze`. Packaging-`jlink` ITs passed without it, so this is a class-loading difference between the two realms.
- `maven-shared-utils` 3.5.0 (`Commandline`) and plexus-archiver stay: forking `jlink` and zipping have no v4 API.
**Improvements:** drops `maven-core`, `maven-plugin-api`, `maven-model`, `maven-artifact`, `javax.inject`, `plexus-java`, `maven-plugin-annotations`; the `JavaVersion.isAtLeast("14")` check for the no-toolchain case is dead on a Java 17 baseline and is reduced to `Runtime.version().feature()`.
**Shared snapshots consumed:** none. `maven-archiver` 4.0.0-beta-5, `maven-filtering` 4.0.0-beta-1 and `plexus-build-api` 0.0.7 are released versions.
**Recommendation:** port; nothing blocks it. Keep a 3.x line for Maven 3 users. Open question for the list: whether to move the `jlink` packaging to the v4 SPI or keep `components.xml` while Maven 4 honours it.
</details>
<details><summary><b>maven-jmod-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → the module has no unit tests, before or after; `mvn verify -Prun-its` → 18 ITs passed, 0 failed before (12m27s) and after (9m16s); spotless clean, RAT and `dependency:analyze-only` pass. Toolchain selection checked by hand (see Gaps). A first full IT run was cut short at the last IT (`base-it`) by a hung Maven process; the counts above are from a clean rerun after the final edit. Shared snapshots consumed: none.
**User-visible changes**
- Runs on Maven 4 only; needs Java 17 (was 8). A 3.x line must stay for Maven 3 users.
- Goals, parameter names and `-D` properties are unchanged. `jmodFile`, `modulePath`, `config`, `libs`, `outputDirectory`, `targetClassesDirectory` are `Path` instead of `File`. Readonly `project` and `session` leave the descriptor, and so does the unused readonly `compilePath` (`${project.compileClasspathElements}` does not exist in v4).
- `hash` no longer declares `requiresDependencyResolution = COMPILE`; it never used the result (it builds a command line and does not run it, same as before).
- `create` resolves dependencies for `main-runtime` (compile and runtime, the same scopes as v3 `RUNTIME`) inside `execute()` through `DependencyResolver`, not before the mojo.
- `MojoFailureException` and `MojoExecutionException` both become `MojoException`, so failures like "JMODS folder does not exists" are no longer separated from execution errors in the exception type.
- The jmod file is attached with `ProjectManager.attachArtifact(project, project.getMainArtifact())`; the "You have to use a classifier" check is kept, based on `ProjectManager.getPath(project)`.
- Subclass API: `AbstractJModMojo` implements `org.apache.maven.api.plugin.Mojo`; `@Inject` fields `Project`, `Session`, `ToolchainManager` (`org.apache.maven.api.services`), `Log`; the `(ToolchainManager)` constructor and `JModCreateMojo(ToolchainManager, LocationManager)` are gone; `getToolchain()` returns `org.apache.maven.api.Toolchain`, `getProject()` the v4 `Project`, `executeCommand(Commandline, Path)`.
**Gaps**
- ToolchainManager: covered. `getToolchains(Session, "jdk", Map)` replaces the reflection on `MavenSession`, `getToolchainFromBuildContext(Session, "jdk")` (Optional) replaces the 3.x call, and `Toolchain.findTool("jmod")` is unchanged. Checked by hand with the installed plugin and a `toolchains.xml` holding a `zulu-21` symlink marked `vendor=tc-test`: with `<jdkToolchain><vendor>tc-test</vendor></jdkToolchain>` the debug line shows `jmod` from the toolchain path; without it, from `JAVA_HOME`. Not tested: a toolchain selected by `maven-toolchains-plugin` (build-context branch); no IT touches toolchains. `JavaToolchainImpl.getJavaHome()` has no v4 accessor (`Toolchain` has `findTool`, `getModel`, `matchesRequirements`), so `ResolvePathsRequest.setJdkHome` now gets the JDK home derived from the `jmod` executable, which only differs from v3 if a toolchain exists but provides no `jmod`.
- PathType/JavaPathType: do not cover the module-path logic. rc-7 `DependencyResolverResult.getDispatchedPaths()` classifies each dependency alone from `Type.getPathTypes()` and the dependency's own module info; `addOutputDirectory`, which would take the project's own `module-info.class`, is documented "currently not called" (`DefaultDependencyResolverResult`). `create` needs the opposite: only modules reachable from the main module's `requires` go on `--module-path`, the rest on `--class-path`, `.jmod` dependencies move to the module path, and filename-based automodules get a warning. That stays in `plexus-java` `LocationManager.resolvePaths` (a plain library, now constructed with `new LocationManager()`), fed with the files from the resolver. `DependencyResolverResult.warningForFilenameBasedAutomodules()` exists but I did not wire it, to keep the message and the boxed warning unchanged.
- `JavaPathType.option(paths)` returns two arguments (`["--class-path", "a:b"]`); the plugin passes `--class-path=a:b` with backslashes doubled for jmod, so it does not use it.
- Packaging registration has no v4 equivalent and is untouched: `META-INF/plexus/components.xml` (`ArtifactHandler` and `LifecycleMapping` for `jmod`) still works, the ITs with `<packaging>jmod</packaging>` and `<type>jmod</type>` dependencies pass. rc-7 `DefaultPackagingRegistry.lookup` only consults a legacy `LifecycleMapping` and never the `PackagingProvider` beans of a project extension (read in `maven-4.0.x`, tag rc-7 plus 11 commits).
- `@Inject ProjectManager` fails in a real build ("No binding to construct an instance for key ProjectManager" seen in the sibling rar port); used `session.getService(ProjectManager.class)`.
- `@Resolution` is not written to `plugin.xml` by `maven-plugin-plugin` 4.0.0-beta-1, so the field stays null and dependencies would be silently dropped; I avoided it by injecting `DependencyResolver`. Nothing here would have caught it: no unit tests, and the ITs only fail if the jmod is wrong.
- `maven-api-annotations` has to be declared (provided) or `dependency:analyze` fails with "used undeclared" after the port.
- `maven-shared-utils` 3.5.0 (`Commandline`, `CommandLineUtils`, `Os`, `StringUtils`, `FileUtils`, `MessageUtils`) and `plexus-java` 1.6.0 stay; neither is Maven API.
- Not covered: a toolchain that lacks `jmod`; JDK 24+ without a `jmods` folder (the existing JEP 493 message is unchanged, I ran JDK 21 only).
**Consumers that break:** none in the Apache Maven plugin and shared-component repositories reference `maven-jmod-plugin` or its classes; the `jmod` packaging is consumed by user projects and, in the estate, only by this plugin's own ITs.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-model`, `maven-artifact`, `maven-plugin-annotations`, `javax.inject`; adds `maven-api-core`, `maven-api-di`, `maven-api-annotations` (provided). The reflection on `ToolchainManager.getToolchains` and `JavaToolchainImpl` are gone.
**Recommendation:** port for the Maven 4 line, keep 3.x for Maven 3. Not blocked. Two API requests for apache/maven: a main-module-aware dispatch in `DependencyResolverResult` (wire `addOutputDirectory`) so `LocationManager` is no longer needed, and a Toolchain accessor for the JDK home.
</details>
<details><summary><b>maven-pmd-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally (Maven 4.0.0-rc-7, zulu-21, plugin-tools 4.0.0-beta-3, plugin-testing 4.0.0-beta-4):
- before `mvn -B -ntp verify`: 65 tests run, 0 failures, 0 errors, 8 skipped (Windows-only tests on macOS); BUILD SUCCESS. `-Prun-its -DskipTests`: 46 ITs, Passed 41, Failed 0, Skipped 5, 14m25s.
- after `mvn -B -ntp verify -Prun-its`: 20 tests run, 0 failures, 0 errors, 8 skipped (same 8 Windows tests); ITs Passed 5, Failed 0 (5 new ITs, see below); BUILD SUCCESS, 1m36s. `spotless:check` passes; RAT and dependency:analyze ran in the same build.
- 45 tests and 46 pre-existing ITs no longer run, see Gaps. Negative control: changing one expected count in a new IT's verify.groovy makes the IT FAIL.
- Real Maven 4 runs of the installed plugin against hand-made `target/pmd.xml` / `cpd.xml` (no PMD run): see "Key finding".
**What ported.** Non-report goals `check`, `cpd-check`, `aggregate-pmd-check`, `aggregate-cpd-check` are v4 mojos (`org.apache.maven.api.plugin.Mojo`, `@Inject Log/Project`, `MojoException`). Report goals `pmd`, `cpd`, `aggregate-pmd`, `aggregate-cpd`, `aggregate-pmd-no-fork` are **blocked**: their sources stay in the tree but are excluded from compilation (pom `<excludes>`/`<testExcludes>` with a comment).
#### Key finding: check does not need the report goal; the only coupling is a fork plus a file
- `check`/`cpd-check` (and the aggregate variants) read exactly one file: `${targetDirectory}/pmd.xml` (`cpd.xml` for CPD), default `${project.build.directory}`. They never touch the report object, resolution, rulesets or PMD analysis. Only PMD library use: `PMDVersion.VERSION` in the message, the modello xpp3 readers, and `RuleViolation` in `ExcludeViolationsFromFile`.
- The coupling is the annotation `@Execute(goal = "pmd")` / `"cpd"` / `"aggregate-pmd"` / `"aggregate-cpd"`: before each check, Maven forks the report goal, which runs `PmdExecutor`/`CpdExecutor` and writes `pmd.xml`/`cpd.xml` (XML is always produced, `canGenerateReportInternal` returns true for xml even with no files, so check can run on an empty result). No other state is passed.
- Measured in a real Maven 4 build (installed plugin, scratch projects, no report goal):
- `mvn pmd:check` with a handwritten `target/pmd.xml` (1 priority-3 and 1 priority-4 violation): BUILD FAILURE `PMD 7.28.0 has found 2 violations. For more details see: .../target/pmd.xml`; `-Dpmd.verbose=true -Dpmd.failOnViolation=false` prints the two `PMD Failure:` lines and BUILD SUCCESS; `-Dpmd.failurePriority=2` gives `has issued 2 warnings`, BUILD SUCCESS; `-Dpmd.skip=true` skips. `cpd-check`: fails on `cpd.xml` with 1 duplication, passes with `-Dcpd.failOnViolation=false`, `-Dcpd.skip` skips.
- Missing file: `Unable to perform check, unable to find .../target/pmd.xml`; `-e` shows `Caused by: org.apache.maven.api.plugin.MojoException`. v4 has no failure/error split: output reads the same as the old MojoFailureException ("Failed to execute goal ... on project x: message", BUILD FAILURE), and the same type is used for unreadable XML.
- Multi-module (root pom + a + b): `pmd:check` runs per module, pom-packaging root skipped; `pmd:aggregate-pmd-check` runs once on the root (module steps SKIPPED), reads root `target/pmd.xml`; deprecated `-Daggregate=true` with `check` checks only the top project (`isExecutionRoot()` became `Project.isTopProject()`).
- E1, fork to a goal that does not exist (check still annotated `@Execute(goal="pmd")`, report sources excluded): `Could not find goal 'pmd' in plugin ... among available goals aggregate-cpd-check, aggregate-pmd-check, check, cpd-check, help`. Fails before any check logic. That is why `@Execute` was removed from the four check mojos in this port.
- E3, scratch copy with a stub v4 goal `pmd` that only writes `pmd.xml`, `check` annotated `@Execute(goal = "pmd")` (v4 annotation): rc-7 forks the v4 goal (`>>> pmd:...:check > :pmd @ exp >>>`, then `--- pmd:check`), check reads its output and fails as expected. So v4 fork v4 works; a v4 non-report producer goal can restore the original `check` behaviour.
- Why the whole plugin cannot hold the report goals (one concrete error, not re-proven at length): with report and check mojos together, plugin-tools 4.0.0-beta-3 writes a 2.0.0 `plugin.xml` whose report mojos carry `<requirements>` (role `org.codehaus.plexus.PlexusContainer`, `org.apache.maven.doxia.siterenderer.Renderer`, `org.apache.maven.doxia.tools.SiteTool`; they come from `@Component` fields of `AbstractMavenReport` in reporting-impl 4.0.0). Maven 4.0.0-rc-7 then fails on **every** goal of the plugin: `Failed to parse plugin descriptor ... ParseError at [row,col]:[357,7] Message: Unrecognised tag: '{http://maven.apache.org/PLUGIN/2.0.0}requirements'`. A v4 and a v3-report mojo cannot share one artifact today. The already-proven chain (site plugin cast error, reporting-impl needing maven-core) stays as the reason the report goals cannot simply be ported.
#### Aux classpath and ruleset resolution without Sisu
Ruleset resolution (`PmdReport.resolveRulesets`, plexus-resources `ResourceManager`):
- `DefaultResourceManager` (1.4.0) has a **public constructor taking `Map<String, ResourceLoader>`**; the loaders have public no-arg constructors. No Sisu needed: `new DefaultResourceManager(Map.of(FileResourceLoader.ID, new FileResourceLoader(), URLResourceLoader.ID, new URLResourceLoader(), ThreadContextClasspathResourceLoader.ID, new ThreadContextClasspathResourceLoader(), JarResourceLoader.ID, new JarResourceLoader()))`.
- Verified with a standalone program (plexus-resources 1.4.0 + slf4j + plexus-utils only, no container): after `addSearchPath(FileResourceLoader.ID, dir)` and `setOutputDirectory(out)`, `getResourceAsFile("myrules.xml","001-myrules.xml")` copies the file from the search path; a classpath resource (`t/cp-rules.xml`) is found through the thread-context classloader; a missing one throws `ResourceNotFoundException`. NOT exercised: http(s) rulesets (URLResourceLoader), and whether the TCCL is the plugin realm inside a v4 mojo (the ported plugin default rulesets live in plugin resources). The search paths the report adds map to `project.getPomPath().getParent()`, `project.getBasedir()`, and the session base directory (v4: `session.getRootDirectory()`/top directory, not compared against `getRequest().getBaseDirectory()`).
- The copy-to-`rulesetsTargetDirectory` logic, `determineRulesetFilename`, `getLocationTemp` and the `001-name.xml` naming are plain Java.
Aux classpath (`PmdReport.determineAuxClasspath` + `ConfigurationService`):
- v3 uses `MavenProject.getCompileClasspathElements()`/`getTestClasspathElements()` (needs `requiresDependencyResolution=TEST`) and, for aggregation, an aether `CollectRequest` through `Provider<MavenSession>` + `RepositorySystem` (both Sisu-injected), excluding reactor siblings and then adding each module's class dirs.
- v4 equivalent, prototyped in a scratch mojo (`aggregator=true`, `@Inject Session`, `session.getService(DependencyResolver.class)`, `DependencyResolverRequest.builder().session(s).project(p).requestType(RESOLVE).pathScope(...)`, `getPaths()`), run on root + a (commons-io compile, javax.inject provided, junit test, slf4j-simple runtime) + b (depends on a):
- `PathScope.MAIN_COMPILE` = {COMPILE, PROVIDED, COMPILE_ONLY}: the same set as `getCompileClasspathElements` (a gets commons-io + javax.inject). `PathScope.TEST_COMPILE` = {COMPILE, PROVIDED, TEST, TEST_ONLY} omits runtime deps; `PathScope.TEST_RUNTIME` = {PROVIDED, COMPILE, RUNTIME, TEST_RUNTIME, TEST} (adds slf4j-simple) is the match for `getTestClasspathElements`.
- The project's own output directories are **not** in the result: prepend `project.getOutputDirectory(ProjectScope.MAIN)` and, for tests, `ProjectScope.TEST`, and keep the existing `emptyOrNotExisting` filter.
- Reactor siblings ARE resolved by the v4 resolver: with `mvn compile`, b's resolved paths contain `a/target/classes` (a DIR) plus a's transitive commons-io. That replaces the v3 exclusion-list and per-module class-dir loop of `ConfigurationService`; `aggregate-*` only needs to loop `session.getProjects()` (filtering to the aggregated modules by base directory, as `modulesForAggregatedProject` does) and call the resolver per project. NOT verified: behaviour without `compile` in the same build (sibling would resolve to a jar/repo artifact), and system-scope deps.
- Source roots: `session.getService(ProjectManager.class).getEnabledSourceRoots(p, ProjectScope.MAIN|TEST, Language.JAVA_FAMILY)` gives `src/main/java` and the generated-sources dir (prototype output). There is no `getCompileSourceRoots` in rc-7 `ProjectManager`; `compileSourceRoots`/`testSourceRoots` parameters (`${project.compileSourceRoots}`) need re-checking in a v4 build.
- Toolchains: `org.apache.maven.toolchain.Toolchain/ToolchainManager` are no longer in maven-core 4.0.0-rc-7 (only in maven-compat). The v4 API is `org.apache.maven.api.Toolchain` and `org.apache.maven.api.services.ToolchainManager` (`getToolchains(session,"jdk",map)`, `getToolchainFromBuildContext(session,"jdk")` returns Optional), obtained with `session.getService(...)`. The report-side edits below use it; they compiled before the sources were excluded, but were never run.
#### Public API changes
- `AbstractPmdViolationCheckMojo<D>`: `extends AbstractMojo` becomes `implements org.apache.maven.api.plugin.Mojo`; field `project` is `org.apache.maven.api.Project` (`@Inject`, no longer a `${project}` parameter); `log` via `@Inject Log`, `getLog()` kept; `targetDirectory` is `Path` with `defaultValue=${project.build.directory}` (property `project.build.directory` kept); `execute()` throws `MojoException` only.
- Check mojos: `@Mojo` is `org.apache.maven.api.plugin.annotations.Mojo` (`defaultPhase="verify"`; `threadSafe` has no v4 attribute and is dropped); `@Execute` removed from all four.
- `ExcludeFromFile`/`ExcludeViolationsFromFile`/`ExcludeDuplicationsFromFile.loadExcludeFromFailuresData` throw `MojoException` (was `MojoExecutionException`); `AbstractPmdReport.getPmdVersion()` no longer used by check (`PMDVersion.VERSION`).
- Edited but excluded from the build (never run): `ServiceExecutor`, `PmdServiceExecutor`, `CpdServiceExecutor`, `PmdReport`, `AggregatorPmdReport`, `AggregatorPmdNoForkReport` lost the `ToolchainManager` constructor parameter and use the v4 toolchain API; `CpdExecutor`/`PmdExecutor` catch `MojoException`.
- Version 3.29.0-SNAPSHOT to 4.0.0-beta-1-SNAPSHOT; `javaVersion` 17; `mavenVersion` 4.0.0-rc-7; `<prerequisites><maven>` is `${mavenVersion}`; plugin-tools 4.0.0-beta-3; plugin-testing 4.0.0-beta-4.
#### Gaps
- Report goals (`pmd`, `cpd`, `aggregate-pmd`, `aggregate-cpd`, `aggregate-pmd-no-fork`) blocked: plugin.xml `<requirements>` parse error above, plus the proven reporting chain. Not ported, not running.
- No non-report producer goal yet, so nothing in the Maven 4 plugin runs PMD/CPD; `check` needs a `pmd.xml`/`cpd.xml` from elsewhere (an older plugin's `pmd:pmd`, the PMD CLI, or a future v4 goal).
- PMD/CPD execution engine (`exec/*`) is not ported. Its only hard ties to the report API are `MavenReportException` and the classloader fork path: `Executor.buildClasspath()` walks `URLClassLoader.getURLs()` of the plugin realm and of `ConsoleLogger`'s classloader (plexus-container-default from core); not exercised on Maven 4.
- No v4 `isExecutionRoot`: `Project.isTopProject()` is used; difference from `MavenSession.isExecutionRoot()` with `-f`/`-pl` not tested.
- No v4 failure/error distinction (`MojoFailureException` vs `MojoExecutionException`): one `MojoException`.
- Removed from the build, all exercising the excluded report code (with `src/test` left in the tree): `CpdReportTest` (13), `PmdReportTest` (26), `PmdReportNumberOfThreadsTest` (5), `exec/ExecutorTest` (1); helpers `CapturingPrintStream` (needs `org.slf4j.impl.MavenSlf4jSimpleFriend`, which no longer ships with Maven 4), `DependencyArtifactStubFactory`, `stubs/**` (v3 `MavenProject` stubs). Also the 46 pre-existing ITs are not selected (`<pomIncludes>` is `check-*/pom.xml`): they run `clean site`, `pmd:pmd` or a forked `pmd:check`. Test dependencies only those tests used were removed: wiremock, commons-io, commons-lang3, maven-embedder, maven-resolver-* (the Maven 3 resolver 1.9.27 `provided` jar also broke the v4 harness with `NoClassDefFoundError: org/eclipse/aether/collection/VersionFilterBuilder`).
- `PmdViolationCheckMojoOnWindowsTest` ported identically (8 tests) but only skipped here (macOS).
- Unverified at runtime: `@Mojo(aggregator=true)` under `-T`, `Project` injection on projects loaded from `-f` other poms.
#### User-visible changes
- Requires Maven 4.0.0-rc-7+ and Java 17 (was Maven 3.6.3 / Java 8); not usable on Maven 3.
- Goals no longer in the artifact: `pmd`, `cpd`, `aggregate-pmd`, `aggregate-cpd`, `aggregate-pmd-no-fork`. `<reporting>` entries for this plugin and `mvn site` output (HTML report, xref links) are gone.
- `check`, `cpd-check`, `aggregate-pmd-check`, `aggregate-cpd-check` no longer run PMD/CPD first. A build that bound `check` to `verify` and relied on the fork now fails with `Unable to perform check, unable to find <dir>/pmd.xml` unless an earlier step produced the file.
- Parameters of the check goals are unchanged by name/property/default (`failOnViolation`, `failurePriority`, `maxAllowedViolations`, `excludeFromFailureFile`, `verbose`, `printFailingErrors`, `skip`, deprecated `aggregate`, `targetDirectory`). `project` is no longer a configurable parameter. `${basedir}` in parameter values is not expanded by v4: use `${project.basedir}` (two unit-test poms changed for that).
- `threadSafe` flag not declared on the mojos.
- Failure output: same BUILD FAILURE message; stack trace under `-e` names `org.apache.maven.api.plugin.MojoException`.
#### Improvements
- Runtime dependencies dropped from the plugin: maven-core/artifact/model/plugin-api (now maven-api-core/di/annotations/xml, provided), org.eclipse.sisu.plexus and javax.inject (DI index is generated: `META-INF/maven/org.apache.maven.api.di.Inject`, no hand upkeep needed here, `<proc>` is not `none`), plexus-utils, plexus-resources, plexus-i18n, doxia-core/sink-api, maven-reporting-api/impl, slf4j-api; sisu-maven-plugin and animal-sniffer-maven-plugin removed (its `java18` signature would reject Java 17 APIs). Kept: pmd-core (needed), pmd-java/javascript/jsp runtime (only the excluded report goals need them), plexus-xml (xpp3 readers).
- 5 new ITs (maven-invoker, through the existing `run-its` profile) that run the goals against precomputed results in `results/` with `<targetDirectory>${project.basedir}/results</targetDirectory>`: fails on 2 violations; `failurePriority=3` with `verbose` gives `1 violation and issued 1 warning`; `cpd-check` with `failOnViolation=false` succeeds; missing results fail with the message; `aggregate-pmd-check` on a pom root checks only the root.
#### Recommendation
Land the check goals as a v4 plugin slice now and do not try to keep the reports in the same artifact until plugin-tools/Maven accept v3 report mojos in a 2.0.0 descriptor. Next step for a usable v4 plugin: a non-report producer goal (`PmdExecutor`/`CpdExecutor` with `MojoException` instead of `MavenReportException`, rulesets via the hand-built `DefaultResourceManager`, aux classpath via `DependencyResolver` with `MAIN_COMPILE`/`TEST_RUNTIME` plus own output dirs, toolchain via `api.services.ToolchainManager`), which the check goals can fork with the v4 `@Execute(goal=...)` (E3 shows that works). The HTML report then stays with the 3.x line or a separate artifact once the reporting chain moves.
</details>
<details><summary><b>maven-rar-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported** (packaging registration stays on the Maven 3 component model), 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 4 unit tests before, 5 after, 0 failures, 0 skipped; `mvn verify -Prun-its` → 3 ITs passed, 0 failed before (3m08s), 4 passed, 0 failed after (2m42s), the fourth (`dependencies`) is new; spotless clean, RAT and `dependency:analyze-only` pass in the verify run. The unit tests were rewritten for the v4 harness (`maven-testing`), so the counts are not like-for-like: the three former tests are kept, plus one for optional and non-library dependencies. Shared snapshots consumed: none (maven-archiver 4.0.0-beta-5 and maven-filtering 4.0.0-beta-1 are released).
**User-visible changes**
- Runs on Maven 4 only; needs Java 17. A 3.x line must stay for Maven 3 users.
- Goal, parameter names and `-D` properties are unchanged. Readonly `session` and `project` leave the descriptor; `threadSafe = true` has no v4 `@Mojo` attribute and is dropped.
- `RarResource` (the `<rarResources>` element type) now extends `org.apache.maven.shared.filtering.Resource` instead of `org.apache.maven.model.Resource`; the XML elements are the same.
- `rarSourceDirectory`, `raXmlFile`, `manifestFile`, `outputDirectory` are `Path` instead of `File`; `getBuildDir()` and `getRarFile(...)` (protected) change to `Path`.
- Dependencies are resolved for `main-runtime` inside `execute()`; the v3 mojo declared `requiresDependencyResolution = TEST`, so test-scope dependencies are no longer resolved and an unresolvable test dependency no longer fails the goal.
- A dependency is copied when it is not optional and its `Type` has path types (class path or module path); that replaces `ArtifactHandler.isAddedToClasspath()`. A `pom` or `rar` dependency is left out by construction (`RarArtifactHandler` sets `addedToClasspath=false`); only `jar`, optional and test scope are covered by a test.
- A blank `classifier` is now treated as no classifier and sets the main artifact. I did not measure what the v3 mojo did with the empty default.
- `@Parameter` defaults use `${project.basedir}` (see Gaps).
**Gaps**
- Packaging registration has no v4 equivalent. `RarLifecycleMappingProvider` (`Provider<LifecycleMapping>`) and `RarArtifactHandler` still use `javax.inject` and `maven-core` classes (`org.apache.maven.lifecycle.mapping.*`, `DefaultArtifactHandler`), so `maven-core` and `javax.inject` stay as `provided` dependencies. `maven-api-spi` has `PackagingProvider`, `TypeProvider` and `LifecycleProvider`, but in rc-7 `DefaultPackagingRegistry.lookup` only looks up a legacy `LifecycleMapping` by id, and its provider list is injected at construction, so a provider shipped by a project extension is never consulted (read in `maven-4.0.x`, tag rc-7 plus 11 commits). The `default-extension` IT passes with the legacy classes.
- `@Inject ProjectManager` fails in a real build: "No binding to construct an instance for key ProjectManager" (the `maven-testing` harness does bind it, so the unit tests were green). Workaround: `session.getService(ProjectManager.class)`.
- `@Resolution` field injection is not usable: `maven-plugin-plugin` 4.0.0-beta-1 writes no resolution into `plugin.xml`, the field stays null. My first port copied no dependencies and passed all unit tests and the 3 existing ITs, none of which has a dependency. Fixed with an injected `DependencyResolver` and `resolve(session, project, PathScope.MAIN_RUNTIME)`; the new `dependencies` IT guards it. I did not run a negative control against the `@Resolution` version.
- `${basedir}` is not expanded in a v4 `@Parameter(defaultValue)` (the work directory ended up as `<basedir>/${basedir}/src/main/rar`); `${project.basedir}` is. The harness does not expand `${basedir}` in plugin configuration either, so the tests set path parameters in code.
- `maven-filtering` 4.0.0-beta-1 needs a `BuildContext` binding, so the plugin adds `Providers` (`@Provides BuildContext`) and `plexus-build-api` 0.0.7; `ThreadBuildContext` extends Plexus `AbstractLogEnabled`, so `org.eclipse.sisu.plexus` 1.1.0 stays on the plugin class path (`NoClassDefFoundError` without it).
- `MavenArchiver.createArchive` (maven-archiver 4.0.0-beta-5) takes the v4 `Session` and `Project` and throws unchecked `MavenArchiverException`; `archive.setManifestFile` takes a `Path`. `JarArchiver` is no longer injectable, so the mojo does `new JarArchiver()`.
- Not covered: a multi-module reactor build in which the RAR depends on a sibling module; `filterRarSourceDirectory` with delimiters (only the existing `filtered` IT).
**Consumers that break:** none in the Apache Maven plugin and shared-component repositories use its classes. `maven-ear-plugin` only lists `maven-rar-plugin:${mavenRarPluginVersion}` as an IT extra artifact and stays on the 3.x version until bumped.
**Improvements:** drops `maven-plugin-api`, `maven-core` (only for the packaging registration, see Gaps), `maven-model`, `maven-artifact`, `maven-plugin-annotations`, `plexus-utils`, `junit` 4, `junit-vintage-engine`, `maven-plugin-testing-harness` 3.x and the five Maven 3 project/artifact test stubs; adds `maven-api-core`, `maven-api-di` (provided), `maven-testing`, `mockito-core` (test) and the two runtime dependencies named under Gaps.
**Recommendation:** port for the Maven 4 line, keep 3.x for Maven 3. Not blocked; the packaging registration should move to the SPI once `DefaultPackagingRegistry` consults `PackagingProvider` for project extensions, which is an API request for apache/maven. Worth a plugin-tools issue: `@Resolution` is not written to `plugin.xml`.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5919283073
### Wave 4 findings, part 2 of 4: maven-doap-plugin to maven-jarsigner-plugin
Each plugin is a local branch `agent/mvn4-api` with a "Build with Maven 4 only" commit and a "Port to the Maven 4 API" commit; the PRs are not opened yet.
<details><summary><b>maven-doap-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17. Five approximations, all under Gaps; the release listing and the `artifact` parameter differ from Maven 3 behaviour in ways the unit tests cannot show.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 15 tests before and after, 0 failures, 0 skipped; `mvn verify -Prun-its` → 4 of 4 ITs pass before and after; `spotless:check` clean. Smoke runs on rc-7 against Maven Central (scratch projects, not committed): a project whose releases exist on Central (release list, `file-release` URLs and `created` date came out right) and `<artifact>` set to `org.apache.maven:maven-artifact:3.9.9` (parent inherited, URL and SCM effective). The pre-port plugin could not be compared on the same projects: under rc-7 it fails with `NoClassDefFoundError: org/codehaus/plexus/util/xml/XmlStreamReader` as soon as a repository returns metadata, which none of the ITs do.
**Public API changes**
- `DoapMojo` implements `org.apache.maven.api.plugin.Mojo`, `@Mojo(name = "generate")` from `org.apache.maven.api.plugin.annotations`; `execute()` throws `MojoException`. `project` is the injected `org.apache.maven.api.Project`, dates and model getters read from `project.getModel()`.
- Removed fields and read-only parameters: `localRepository`, `projectBuildingRepositories`, `remoteRepositories`, `repositorySystemSession`, `settings`, `project` (as a parameter).
- `DoapUtil.interpolate(String, Project, Settings)` takes the v4 `Project` and `org.apache.maven.api.settings.Settings`. `DoapUtil.getContributorsWith*Role(List<Contributor>)` lose the `I18N` argument and use `org.apache.maven.api.model.Contributor`. `ASFExtOptionsUtil.isASFProject(Project)` and `findChair`/`findPMCMembers` take `org.apache.maven.api.model.Developer`.
- Modello classes (`DoapOptions`, `ASFExtOptions`, `ExtOptions`, `DoapArtifact`) are unchanged.
**Gaps** (rc-7 `maven-api-core`, `maven-api-model`, `maven-api-settings`)
- Building a `Project` from coordinates: the v4 `ProjectBuilder` takes a path or a `Source`, not an artifact. `<artifact>` now resolves the POM with `Session.resolveArtifact` and builds from its path. A build from a `Source` (`Sources.resolvedSource`) returns an empty `Optional<Project>` with no problems listed, because `DefaultSession.getProject` drops a project without base directory; the plugin used it first and silently fell back to the current project. The request builder has no validation level, so Maven 3's `VALIDATION_LEVEL_MINIMAL` is gone.
- `RemoteRepository` has no release or snapshot policy (`getId`, `getType`, `getUrl`, `getProtocol` only). The plugin picks the first repository that serves releases but not snapshots; it now reads the policies from the repository of the same id in `project.getModel().getRepositories()`. A repository that is not declared there, such as a mirror or one from `settings.xml`, is taken as releases only, which can change which repository is chosen.
- No repository metadata service. `Transport` (from `TransportProvider`) fetches `g/a/maven-metadata.xml` by relative URI, and the XML is parsed with `MetadataStaxReader`, which ships in `maven-support`, not in an API module; it is bundled, as maven-jar-plugin does. Lost: the update and checksum policy, the local copy of the metadata, and the distinction resolver makes between a missing file and a failed transfer beyond `Optional.empty()`.
- `Transport` has no existence check. Whether a release file exists is now read from its `.sha1`, so a repository that serves artifacts without checksum files reports no `file-release`. The alternative was downloading every artifact of every version.
- No repository layout service: `Session.getPathForRemoteArtifact` is the path in the local cache, not in the remote repository. The default-layout location is built by hand (`g/a/v/a-v[-c].ext`); the extension comes from `session.requireType(type).getExtension()`, or the type itself when unknown, as the old handler manager did.
- `ScmManager` and `I18N` are Plexus components with no v4 injection. `ScmManager` is now a `BasicScmManager` holding only `SvnExeScmProvider`, the same provider set the old classpath had; `I18N` is replaced by `ResourceBundle.getBundle("doap-person")`.
- `${project.reporting.outputDirectory}` is empty in Maven 4 unless the POM sets it (Maven 3 always gave `${project.build.directory}/site`); the plugin applies that default itself. The `basic` IT caught it as an NPE.
- `Metadata.getVersioning().getVersions()` is immutable; the old code reversed it in place. The unit fixture had one version, which hid the failure until the real run.
- `ProjectManager` has no DI binding in rc-7; `ProjectBuilder` and `TransportProvider` are bound, but their implementations cannot be built in the test harness (`DefaultTransportProvider` needs resolver's `TransporterProvider`). All three are looked up with `session.getService(...)`.
- Interpolation: the `project` and `pom` prefixes now resolve against the effective `Model` (getter names match for `name`, `url`, `scm.*`, `developers[n].*`); `basedir` is added by hand. Anything that only `MavenProject` had (`${project.artifact...}`, `${project.file}`) no longer resolves.
- Test harness: `maven-plugin-testing-harness` 4.0.0-beta-4 has no real repository session (3.5.1 had `realRepositorySession = true`), so the two tests that resolved plexus-utils 1.5.5 and xstream 1.1 from Central now use fixture POMs (`src/test/resources/unit/artifact`, reduced by hand) and a mocked `Session`/`ProjectBuilder`, and the release tests use a directory-backed fake `Transport`. The real resolution path is covered only by the smoke run above, not by a committed test.
**User-visible changes**
- Needs Maven 4.0.0-rc-7 or newer and Java 17; `<prerequisites>` follows `mavenVersion`. The `generate` goal and its writable parameters keep their names.
- Release listing: repository choice, existence check and metadata handling differ as described above.
- `<artifact>` builds a model with Maven 4's default POM validation instead of minimal validation.
- `.github/workflows/maven-verify.yml` still carries the JDK 8 / Maven 3.9.0 `matrix-include` entry, which cannot run a Maven 4 plugin; not touched.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-settings`, `maven-model`, `maven-model-builder`, `maven-repository-metadata`, `maven-resolver-api/impl/spi`, `maven-scm-manager-plexus`, `plexus-i18n`, `javax.inject` and the resolver test connectors; `XmlStreamReader` is no longer needed on the release path.
**Recommendation:** port, and ask apache/maven for four things: a policy accessor on `RemoteRepository`, an existence check on `Transport`, a `Metadata` read service, and `ProjectBuilder` by coordinates that returns a `Project` for a repository POM. Until then a plugin that lists releases is the kind that loses most by moving. Release it as a 4.x line next to the 3.x one.
</details>
<details><summary><b>maven-ear-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT (was 3.4.1-SNAPSHOT), Java 17.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` -> 48 unit tests before (8 classes) and 49 after, 0 failures/errors/skipped (one test added, see Tests). `mvn verify -Prun-its` -> before: 18/18 invoker ITs and 103/103 `EarMojoIT` pass (45 min, run with other builds in parallel); after: 17/18 invoker ITs pass and 103/103 `EarMojoIT` pass (13 min). The one failing IT is `skinny-wars-timestamp` (see Gaps); the before run is the 3.4.1 plugin under Maven 4. `spotless:check` clean. Released artifacts: maven-archiver 4.0.0-beta-5, maven-filtering 4.0.0-beta-1, plugin-tools 4.0.0-beta-1. Local snapshot consumed: maven-mapping 4.0.0-SNAPSHOT (`agent/mvn4-api` at 1f0a2fa, worktree `wt-fbf-dep-mapping`, `mvn install -DskipTests`).
**User-visible changes**
- Runs only on Maven 4 (no `maven-plugin-api`, `maven-core`, `maven-artifact`, `javax.inject`, `maven-shared-utils`). A 3.x line has to stay for Maven 3 builds.
- Goals `ear` and `generate-application-xml`, their phases and every parameter name are unchanged; `threadSafe` is no longer declared (v4 `@Mojo` has no such attribute), nor `requiresDependencyResolution` (the plugin resolves `PathScope.TEST_RUNTIME` itself through `DependencyResolver`).
- `earSourceDirectory` default is `${project.basedir}/src/main/application` (`${basedir}` is not evaluated in v4, the directory was silently ignored), and the `description` default is `${project.model.description}`.
- `@{version}@` (the default `outputFileNameMapping`) of a SNAPSHOT dependency expands to `1.0-SNAPSHOT`, no longer to the timestamped `1.0-20150825.210557-91`; the documented "timestamp postfix" in customize-file-name-mapping is not reproducible (see Gaps). EAR entry names and the Class-Path of skinny modules change accordingly for SNAPSHOT dependencies.
- maven-mapping tokens (`outputFileNameMapping`): the documented ones (`groupId`, `artifactId`, `version`, `baseVersion`, `dashClassifier?`, `extension`) are unaffected. The v4 port drops the `ArtifactHandler` value source and `api.Artifact` has no `type`/`scope`; because the plugin passes the `Dependency`, `@{type}@` now prints the `Type` object's `toString()` (not `ejb`) and `@{scope}@` prints `COMPILE` (not `compile`), and `@{packaging}@`, `@{language}@`, `@{file}@` stay literal in the file name. None of these is documented or used in the repo's poms/ITs.
- Free-form parameters `artifactTypeMappings`, `jboss`, `security`, `envEntries`, `ejbRefs`, `resourceRefs` are `XmlNode` instead of `PlexusConfiguration`; the XML users write is unchanged.
- Modules are still typed by the dependency type: `Dependency.getType().id()` is the declared string (`ejb`, `war`, `rar`, `sar`, `har`, `par`, `wsr`, `app-client`, `ejb-client`, `test-jar`, `jboss-sar`/`-har`/`-par`, custom types through `artifactTypeMappings`), so the type to module mapping works and is covered by 103 `EarMojoIT` projects. `ejb`, `ejb-client`, `war`, `ear`, `test-jar` are registered types in rc-7; the rest fall back to the legacy handler (extension = type) and resolve fine. The v4 `Type` replaces the `ArtifactHandler` for `includesDependencies`/extension only; the ear-specific mapping (`EarModuleFactory`, `ArtifactTypeMappingService`) stays in the plugin, nothing in v4 replaces it.
- Public Java API: `EarModule.getArtifact()` returns the new `util.ResolvedArtifact` (dependency + resolved `Path`; v4 `Dependency` carries no file) instead of `Artifact`; module constructors, `ArtifactRepository`, `EarExecutionContext` follow; `resolveArtifact` no longer throws the checked `MojoFailureException`, `InvalidJavaEEVersion` extends the unchecked `MojoException`; `ArtifactTypeMappingService.configure` takes the new `util.XmlConfig` (a read-only view over `XmlNode`); `EarMavenArchiver.getManifest` takes `api.Session/Project` and the deprecated `getManifest(MavenProject, config)` overload is removed; `EarMojo` has no constructor (archivers are created inside; `ArchiverManager` replaced by `new ZipUnArchiver()`).
- New `Providers` (`@Provides` `ProjectManager`, `BuildContext`) for `MavenFileFilter`; the ear artifact is attached with `ProjectManager.attachArtifact(project, project.getMainArtifact(), ear)` or a produced artifact of type `ear` for a classifier.
**Gaps**
- `skinny-wars-timestamp` IT fails (only after-failure): v4 gives the resolved SNAPSHOT `Dependency` version `1.0-SNAPSHOT` and a `-SNAPSHOT` local-repo file name; `session.resolveArtifact` returns the same. The timestamped version is unreachable through the API, so the IT's expectations (`eartest-jar-sample-one-1.0-20150825.210557-91.jar` in Class-Path, timestamped jar removed from the WAR built by the 3.x war plugin) cannot hold. With a v4 war plugin both sides use `-SNAPSHOT` and the original-file-name lookup matches; only mixed 3.x-war/4.x-ear builds leave the duplicate jar in `WEB-INF/lib`. IT left red on purpose, not edited.
- `DependencyResolver` ignores `Type.isIncludesDependencies()` (`war`, `ear`, `rar`) although the session has `FatArtifactTraverser`: the war's transitives appear in the result, and an artifact reachable by several paths is listed only below the nearest one (`skinny-wars-javaee5` and `project-089..096` failed with it). Worked around in `AbstractEarMojo.resolveProjectArtifacts`: a RESOLVE tree plus a verbose COLLECT tree; an artifact is kept only if reachable without passing through an `includesDependencies` node (a reachable winner's subtree counts). Approximation: a version conflict won by the fat path is not re-mediated.
- `XmlNode` mojo parameters lose XML attributes (`DefaultBeanConfigurator.XmlConverter` builds the node with `null` attributes; same on core master): `artifactTypeMapping type= mapping=`, `security-role id`, `loader-repository class`. Worked around by reading those elements from the injected `MojoExecution.getConfiguration()` (model `XmlNode`, attributes intact); values are model-interpolated only, `${session.*}`-style expressions are not evaluated. `PlexusConfiguration` parameters cannot work at all ("Cannot create instance of interface"): core does not export `org.codehaus.plexus.configuration` to plugin realms, `@Mojo(configurator = "basic")` does not help.
- `Session` has no build start time; `deleteOutdatedResources` uses the JVM start time, so under a long-lived JVM (mvnd) stale files from an earlier build in the same daemon are not deleted.
- Mojo failure vs error is lost (`MojoException` only), so `MojoFailureException` paths (unknown artifact, missing candidate) now report as errors.
- `META-INF/plexus/components.xml` (ear `ArtifactHandler` and `LifecycleMapping`) is kept untouched and not exercised: Maven 4 core has built-in `ear` type and `ear` lifecycle mapping (`EarLifecycleMappingProvider`), which the ITs use; a plugin-provided packaging needs the Plexus components in rc-7.
- System-scope dependencies: `PathScope.TEST_RUNTIME` has no `SYSTEM` scope in rc-7, so they are not part of the module set; not covered by any IT.
**Tests:** all 48 unit tests kept. `AbstractEarTestBase` builds `ResolvedArtifact` over a new `stub/DependencyStub` (implements `api.Dependency`); removed `stub/ArtifactHandlerTestStub` (v3 `ArtifactHandler`, unused now). `ArtifactTypeMappingServiceTest` builds `XmlNode` instead of `XmlPlexusConfiguration`; its `testConfigWithSameCustomType` never populated the second mapping (it set the attributes on the first element twice), so it only exercised the missing-attribute path: kept as is and `testConfigWithSameCustomTypeRegisteredTwice` added for the real duplicate (49 tests). `AbstractEarPluginIT` uses plexus-utils `FileUtils`. No IT source changed.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-plugin-annotations`, `javax.inject`, `maven-shared-utils`; adds `maven-api-core/di/annotations/model/xml` (provided), `plexus-build-api` and `org.eclipse.sisu.plexus` (needed at runtime by `ThreadBuildContext`, `AbstractLogEnabled`; `dependency:analyze` ignore entry added).
**Recommendation:** not mergeable as is. Port for Maven 4 and keep a 3.x line, but only after the core gaps are filed: `includesDependencies` not honoured by the API resolver, `XmlNode` parameter conversion dropping attributes, no snapshot timestamp version and no session start time in the API. The ear plugin itself ports with workarounds that restore behaviour for all 103 `EarMojoIT` cases and 17 of 18 invoker ITs; `skinny-wars-timestamp` is the one documented behaviour that cannot be kept.
</details>
<details><summary><b>maven-ejb-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT (was 3.3.1-SNAPSHOT), Java 17.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` → 36 tests before (19 EjbMojoTest, 10 EjbHelperTest, 7 IncludesExcludesTest) and 36 after, 0 failures/errors/skipped. `mvn verify -Prun-its` → 9/9 invoker ITs pass before (4m58s) and after; `spotless:check` clean. Released artifacts only, no local snapshots: maven-archiver 4.0.0-beta-5, maven-filtering 4.0.0-beta-1, maven-plugin-plugin 4.0.0-beta-1, maven-testing 4.0.0-rc-7.
**User-visible changes**
- Runs only on Maven 4 (no `javax.inject`, `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-model`, `maven-settings`, sisu annotations). A 3.x line has to stay for Maven 3 builds.
- Goal `ejb`, phase `package` and every parameter (`classifier`, `clientClassifier`, `ejbJar`, `ejbVersion`, `generateClient`, `clientIncludes/Excludes`, `excludes`, `archive`, filtering options, `outputTimestamp`) are unchanged; `threadSafe` is no longer declared (v4 `@Mojo` has no such attribute).
- Public API: `EjbMojo.getProject()` now returns `org.apache.maven.api.Project` (was `MavenProject`); `validateEjbVersion` throws the unchecked `MojoException` (was checked `MojoExecutionException`). `EjbHelper` is unchanged.
- Main jar is attached via `ProjectManager.attachArtifact(project, project.getMainArtifact(), path)`; classified jar and client jar via `session.createProducedArtifact(..., type "ejb" / "ejb-client")`. The old unreachable `FIXME` branch for a null client classifier did the same call as the valid branch and is merged into it.
- Maven 4 prints the "You have to use a classifier ..." failure without the trailing ` -> [Help 1]`, so the IT `mejb-93` now matches the message without it (it still asserts the same behaviour: a second execution without classifier fails).
- New `Providers` class (`@Provides`) supplies `ProjectManager` and `BuildContext` (required by `DefaultMavenFileFilter` 4.0.0-beta-1).
**Gaps**
- `org.eclipse.sisu:org.eclipse.sisu.plexus` must be a compile dependency: `ThreadBuildContext` (plexus-build-api 0.0.7) extends `org.codehaus.plexus.logging.AbstractLogEnabled`, which a v4 plugin realm does not provide. Without it all 7 ITs failed with `NoClassDefFoundError: org/codehaus/plexus/logging/AbstractLogEnabled`. maven-resources-plugin master carries the same dependency.
- `@Mojo(requiresDependencyResolution = RUNTIME)` has no usable v4 equivalent with maven-plugin-plugin 4.0.0-beta-1 (`dependencyResolutionPathScopes` fails descriptor generation: "Method: 'dependencyResolutionPathScopes' not found in class MojoAnnotationContent"). Dropped; `MavenArchiver.getManifest` resolves `MAIN_RUNTIME` itself through `DependencyResolver`, and the `manifest-content` IT passes.
- The v3 harness (`AbstractMojoTestCase`, `MavenProject` stubs) has no v4 counterpart.
**Tests:** `EjbMojoTest` rewritten on JUnit 5 with `maven-testing` (`ProjectStub`, `SessionMock`), `@TempDir` and a mocked `ProjectManager`; all 18 original scenarios kept with the same assertions, one lookup test moved to `@MojoTest`/`@InjectMojo` (resource renamed `plugin-config.xml` to `pom.xml`), and two attach assertions added (`verify` on `ProjectManager`/`Session` for the default and classified+client cases). Removed and replaced: `stub/MavenProjectBasicStub`, `MavenProjectBuildStub`, `MavenProjectResourcesStub`, `ModelStub` (v3 `MavenProject` subclasses; replaced by the nested `TestProject`). `vintage-engine` and `maven-plugin-testing-harness` 3.5.1 dropped. `EjbMojo` fields are set by reflection in these tests, as before.
**Improvements:** drops `javax.inject`, `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-model`, `maven-settings`, `maven-shared-utils`, `plexus-utils`, `org.eclipse.sisu.inject`, JUnit vintage, the v3 testing harness.
**Recommendation:** port for Maven 4; keep a 3.x line for Maven 3 users. maven-ear-plugin's pom only lists maven-ejb-plugin as an `extraArtifact` for its ITs (`mavenEjbPluginVersion`), so it is not a compile-time consumer; its ITs that resolve the ejb plugin would need a 4.x version together with Maven 4.
</details>
<details><summary><b>maven-gpg-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17. All three goals (`sign`, `sign-and-deploy-file`, `sign-deployed`) ported and exercised by the ITs; one behaviour cannot be ported with the API (encrypted settings passphrases, see Gaps). No test or IT removed.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn -B -ntp verify`: 10 tests, 0 failures, 1 skipped (`BcSignerTest` 6, `GpgVersionTest` 3, `GpgVersionConsumerTest` 1), before and after. `-Prun-its` with the Bouncy Castle signer (`bc-integration-tests` plus failsafe `Bc*IT`): invoker 13 of 13 passed and `BcSignArtifactIT` 4 of 4, before and after. The `gpg-integration-tests` execution and `GpgSignArtifactIT` could not be measured: the system gpg 2.5 fails with "can't connect to the gpg-agent: File name too long" (macOS socket path limit; the worktree path is too long), which gave 1 of 13 before, so for the comparison that execution was switched off in a scratch copy of the pom in both runs. The `gpg` signer path is therefore not exercised after the port beyond compilation. Spotless clean.
**v4 routes**
- Attach: `MavenProjectHelper.attachArtifact(project, type, classifier, file)` becomes `ProjectManager.attachArtifact(Project, ProducedArtifact, Path)` with `session.createProducedArtifact(g, a, v, classifier, extension + ".asc", null)` (the 6-argument factory, because the short `attachArtifact` overloads cannot carry a classifier). `FilesCollector` reads `ProjectManager.getPath/getAttachedArtifacts` and `ArtifactManager.getPath`.
- `sign-and-deploy-file` outside a project: yes. Same shape as `maven-deploy-plugin` 4.0.0-beta-3 `DeployFileMojo` (`projectRequired = false`): artifacts from `session.createProducedArtifact`, paths via `ArtifactManager.setPath`, deploy via `ArtifactDeployer` with `ArtifactDeployerRequest` (its `retryFailedDeploymentCount` replaces the hand-written retry loop), repository from `session.createRemoteRepository(id, url)`, POM read/generated with `ModelXmlFactory`. Signing itself has no API and stays in `GpgSigner`/`BcSigner`.
- `sign-deployed`: `session.withLocalRepository(session.createLocalRepository(tmp))` for the private repo, `resolveArtifacts(coordinates, repos)`, `ArtifactDeployer` for the `.asc` files.
**Public API changes**
- Mojos implement `org.apache.maven.api.plugin.Mojo`; `MojoExecutionException`/`MojoFailureException` become the unchecked `MojoException` in all public signatures (`AbstractGpgSigner`, `GpgSigner`, `BcSigner`, `GpgVersionParser`, `FilesCollector`).
- `BcSigner(Session, ...)` and its `Loader` methods take `org.apache.maven.api.Session` instead of the aether session; `FilesCollector(Session, Project, String[], Log)` (was `MavenProject, String[], Log`); `AbstractGpgMojo.getPassphrase(Project)`.
- `ArtifactCollectorSPI.collectArtifacts(Session, RemoteRepository)` now uses `org.apache.maven.api.Artifact/RemoteRepository/Session`: an SPI break for any implementor.
- The `settings` parameter (`${settings}`) and the injected `SettingsDecrypter` are gone; `session.getSettings()` is used.
- Env variables (`env.MAVEN_GPG_*`) are read from the session user then system properties (`BcSigner.getEnv`), replacing `RepositorySystemSession.getConfigProperties()`.
**Gaps**
- Encrypted passphrases in `settings.xml`: rc-7 has no decrypt service in any `maven-api-*` module (`SettingsDecrypter` exists only in compat `maven-settings-builder`, and `maven-impl` never calls it). `gpg.passphraseServerId` values that look encrypted (`{...}`) now fail with an explicit `MojoException` instead of being signed with as cipher text; plain passphrases still work (IT `sign-with-passphase-from-maven-settings` passes). Needs a settings-decrypt service in `maven-api-core` to be closed.
- The "old way" passphrase-from-project-properties read no longer copies the found value onto the reactor root project (`Project.getModel().getProperties()` is immutable).
- `ModelValidator` strict validation of the coordinates in `sign-and-deploy-file` has no API equivalent; replaced by a local check (groupId/artifactId `[A-Za-z0-9_.-]+`, version without path or whitespace characters, packaging non-blank), which is looser than the model validator.
- `ArtifactHandlerManager` replaced by `TypeRegistry.lookup(packaging)`; unknown types fall back to extension = type, as before.
- Mojo constructor injection does not work with the generated `MojoFactory` (`NoSuchMethodError: SignDeployedMojo.<init>()`): `SignDeployedMojo` uses field injection, `@Inject @Nullable Map<String, ArtifactCollectorSPI>` (an empty map otherwise fails to inject).
- `BcSignerTest` built an aether session with `maven-resolver-impl`; it now uses a `java.lang.reflect.Proxy` over `Session` that answers only the two property maps (no new test dependency, which would need a pgpverify keys-map entry).
- `<proc>none</proc>` removed from the compiler configuration so the api.di index is generated.
- `plexus-utils` (`FileUtils`, `SelectorUtils`, `Os`, `cli.*`, `CachingOutputStream`) is not a Maven API and stays.
**User-visible changes**
- Requires Maven 4; Java 17; `<prerequisites>` follows `mavenVersion`.
- Failure text `MojoFailureException: Do not store passphrase...` is now `MojoException: ...` (IT `sign-release-best-practices-fail` updated).
- Encrypted server passphrase: explicit failure, see Gaps. `retryFailedDeploymentCount` log lines ("Retrying deployment attempt") no longer come from the plugin.
- `maven-resolver-impl` test dependency and the `resolverVersion` property removed.
**Improvements:** drops `maven-core`, `maven-plugin-api`, `maven-artifact`, `maven-model`, `maven-model-builder`, `maven-settings`, `maven-settings-builder`, `maven-resolver-api/util`, `maven-plugin-annotations`, `javax.inject`.
**Recommendation:** port is viable; do not merge until the settings-decrypt gap is decided (file against apache/maven), and run the `gpg` signer ITs on a machine with a short checkout path.
</details>
<details><summary><b>maven-help-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT (was 3.5.3-SNAPSHOT), Java 17. Two goals are degraded, see Gaps.
Verified locally: Maven 4.0.0-rc-7, JDK 21. `mvn verify` before → 30 tests, 0 failed, 0 skipped; after → 61 tests, 0 failed, 0 skipped. `mvn verify -Prun-its` before → 34 passed, 0 failed, 2 skipped (12m27s); after → 36 passed, 0 failed, 0 skipped (18m03s, run on a copy of the tree); `describe-cmd-with-goal-report` failed on its first attempt (the report check logged `Couldn't identify if this goal is a report goal: org/apache/maven/plugin/AbstractMojo`, cause not isolated) and passed on the invoker retry. `spotless:check` clean. No local snapshots consumed, released artifacts only.
**User-visible changes**
- All 11 goals are `org.apache.maven.api.plugin.Mojo`s; `session`, `project`, `Log` and the services are `@Inject`ed. Goal names, phases and parameter names/properties are unchanged; `output` is now a `Path` (same XML syntax). The plugin no longer loads under Maven 3: a 3.x line has to stay.
- `evaluate`: the expression evaluator of Maven 3 is gone. The new one (`ExpressionEvaluator`) handles `project`, `session`, `settings`, `mojo`, `plugin`, `localRepository`, `reactorProjects`, `basedir`, `rootDirectory`, `env.X`, then project properties, session properties and system properties, through the public getters of the API objects (`a.b.c`, `list[0]`, `map(key)`). `${project.x}` falls back to the model when `Project` has no getter, so `project.name` and `project.properties` work. Objects that are not a model, settings or scalar are written by `XmlRenderer` (bean, list, map), not by XStream, so the element order of such output is alphabetical instead of field order. Interactive mode uses the `Prompter` service instead of `InputHandler`.
- `effective-pom`: properties are written sorted (the IT `effective-pom_properties` expected the reversed hash order of Maven 4 with the old plugin; it now expects the sorted order on every Maven version). Verbose location comments go through `XmlWriterRequest.inputLocationFormatter`.
- `active-profiles`: the source of a POM profile is the `g:a:v` of the POM in the parent chain that declares it (from `getDeclaredActiveProfiles`), settings profiles are listed once as `external`. The ITs `active-profiles` and `active-profiles_multimodule` pass.
- `list-lifecycle-phases`, `describe -Dcmd=<phase>`: phases are the Maven 4 ones (`before:compile`, `after:resources`, ...). `describe -Dcmd=process-resources` still works through `Lifecycle.aliases()`.
- `list-packaging`, `list-dependency-types`: only the ids Maven itself defines are listed (see Gaps).
- `describe`: plugin `groupId:artifactId[:version]` works through the plugin jar and its `META-INF/maven/plugin.xml`; `-Dplugin=<prefix>` and `-Dcmd=<prefix>:<goal>` work for the plugins of the project and for `maven-<prefix>-plugin` / `<prefix>-maven-plugin` in the plugin groups of settings, `org.apache.maven.plugins` and `org.codehaus.mojo`.
- The two ITs `evaluate-model-collections` and `evaluate-settings-servers` were skipped on Maven 4 (`invoker.maven.version = 4-`, XStream could not serialise immutable maps); they now run and pass, the skip line is removed.
**Gaps**
- No v4 route, goal `describe` only: plugin prefix resolution from the repositories' group metadata (`MojoDescriptorCreator.findPluginForPrefix`, `PluginPrefixResolver`). The prefix heuristic above cannot find a plugin with a non-conventional artifactId that the project does not declare. No plugin version resolver either: a missing version is the one of the project's `build/plugins` or `pluginManagement`, else the highest non-snapshot of the version range. Relocations of the plugin POM are not followed (`ArtifactResolver` does not read the descriptor).
- No v4 route, goals `list-packaging` and `list-dependency-types`: `PackagingRegistry` and `TypeRegistry` only look up by id (`ExtensibleEnumRegistry` has no listing), and the legacy handlers come from Sisu components. The goals probe the constants of `org.apache.maven.api.Type` plus `ejb`, `ejb-client`, `war`, `ear`, `rar`, `par`, `sources`, `test-sources`, and the packagings `pom, jar, maven-plugin, ejb, ejb3, war, ear, rar`. A packaging or type that a third-party extension registers is not listed.
- `describe` with a plugin whose POM Maven 4 rejects (the IT uses maven-help-plugin:2.0): `ProjectBuilderRequest` has no validation level, so the name is read from the POM file and the report-goal check falls back to the runtime dependencies.
- v4 `MojoDescriptor`/`Parameter` drop the `<configuration>` element of a Maven 3 `plugin.xml` (default value, expression). `describe` reads it with its own DOM pass so that "Default" and "User property" still show for Maven 3 plugins.
- `evaluate` cannot evaluate what Maven 3 evaluated through `PluginParameterExpressionEvaluator` and the session internals: anything that is not reachable through a public getter or method of the API objects (for example the plugin context). Unmeasured beyond the expressions in the ITs and `ExpressionEvaluatorTest`.
- `active-profiles`: Maven 4 gives no per-model activation record, only `getDeclaredActiveProfiles()` per project, so the source is the POM in the parent chain that declares the active profile.
Tests: `AbstractHelpMojoTest` now tests `parseCoordinates` (same four cases); in `DescribeMojoTest` the three lookup tests that mocked `MojoDescriptorCreator`/`PluginVersionResolver`/`MavenPluginManager` are replaced by lookups on a generated plugin jar (prefix with and without version, GAV); the `describeCommand` tests run on mocked `LifecycleRegistry`/`Packaging`. No test was deleted; new: `EffectivePomMojoTest`, `EffectiveSettingsMojoTest`, `ExpressionEvaluatorTest`, `ListMojosTest`.
**Improvements:** drops `maven-artifact`, `maven-core`, `maven-model`, `maven-model-builder`, `maven-plugin-api`, `maven-settings`, `maven-resolver-api`, `javax.inject`, `org.eclipse.sisu.plexus`, `maven-plugin-annotations`, `maven-shared-utils`, `plexus-interactivity-api` and `xstream`. `plexus-utils` (needed at runtime by `HtmlToPlainTextConverter`, whose own dependencies are excluded), `plexus-xml`, `jdom2`, `maven-reporting-api` 4.0.0 (only the `MavenReport` type check) and `maven-plugin-tools-generators` stay. Adds `maven-api-core/di/annotations` and `maven-xml` (provided).
**Recommendation:** port for Maven 4 and keep a 3.x line for Maven 3. Upstream follow-ups worth filing: a listing method on `ExtensibleEnumRegistry`; a plugin-prefix and plugin-version resolution service in the API; `MojoDescriptor` keeping the v3 `<configuration>` defaults; a validation-level option on `ProjectBuilderRequest`; a public expression evaluator for plugins.
</details>
<details><summary><b>maven-invoker-plugin</b>: partial</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **partial**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 67 unit tests before and after, 0 failures, 0 skipped; spotless clean. `-Prun-its` (92 IT projects): before, the 30 min time-box hit after 45 ITs (all 45 passed, none failed); after, the same 45 ITs ran in 1770 s and all pass (44 at first, `staging-pom` after the fix below), plus 26 more selected by the code they touch (`-Dinvoker.test=` list of settings-*, script-*, local-repo-*, staging-*, install-*, invoker-report, ...): 24 pass, 2 fail (`MINVOKER-377-install-ignore-split-repo`, `invoker-report`, see Gaps). Not run, before or after: 22 ITs (MINVOKER-196, -288-failed-setup-verify, -289, -294, -330, exec-timeout-mojo-level, fail-build-with-verify*, fail-ignore*, fail-noprojects_verify, invocation-cmdline-exclude, invocation-debug, invocation-group-properties, invocation-reactor-indirect, invocation-spaces, multiple-pre-post-build, project-cloning-reactor, rerun-build, rerun-build-invoker-test-in-config, script-strea
mLogs-false). Not measured: running the ported plugin under Maven 3; heavy machine load (load average >100) makes the IT timings unreliable.
Uses `maven-api-core`/`-di`/`-annotations`/`-model`/`-settings` 4.0.0-rc-7 (provided), plugin-tools 4.0.0-beta-3, and the local snapshots `maven-reporting-api` and `maven-reporting-impl` 5.0.0-SNAPSHOT (agent/mvn4-api branch of reporting-impl, already in the local repository, not rebuilt here). maven-invoker 3.3.0 and maven-script-interpreter 1.9 use no Maven API and are unchanged.
**v4 route for install into an alternate local repository** (`invoker:install`): `Session.withLocalRepository(session.createLocalRepository(path))` gives a session bound to the staging repo; `DependencyResolver.resolve(DependencyResolverRequest{project|root dependency, PathScope})` returns `getDependencies()` (Dependency to Path) for the transitive closure; POMs and their parent chains come from `session.resolveArtifact(createArtifactCoordinates(g, a, v, "pom"), repos)`; `ProjectManager.getRemoteProjectRepositories/getRemotePluginRepositories` supply the repositories; `altSession.installArtifacts(...)` writes them. Scope `runtime`/`compile`/`test` maps to `PathScope.MAIN_RUNTIME`/`MAIN_COMPILE`/`TEST_RUNTIME`. Two traps, both hit by ITs:
- `Session.setArtifactPath(ProducedArtifact, Path)` rewrites the file of every reactor project artifact with the same id and throws `UnsupportedOperationException: transformed artifact file cannot be set` for the project's own (transformed) POM. Reactor artifacts must be installed as they are (`Project.getArtifacts()` + `ProjectManager.getAttachedArtifacts()`, the file travels inside the artifact); `setArtifactPath` only for downloaded ones.
- `Project.getParent()` returns only reactor parents, unlike `MavenProject.getParent()`; the parent chain has to be walked through `project.getModel().getParent()` and resolved (IT `staging-pom` caught it).
**Script-visible bindings** (`ScriptRunner` globals, maven-script-interpreter): none of them carries a Maven type, so no binding changes type. `basedir` (script dir, `File`), `context`, `scriptFile`, `logger`, `localRepositoryPath` (`File`), `mavenVersion` (`String`) and `scriptVariables` are as before. Value changes: `localRepositoryPath` default is now `session.getLocalRepository().getPath()` (follows `-Dmaven.repo.local`; was `${settings.localRepository}`); `mavenVersion` with no `mavenHome` is `session.getMavenVersion()`. What does change is the script class path: scripts used to see the Maven 3 plugin realm, so `org.apache.maven.plugin.MojoExecutionException` (IT `settings-merge/postbuild.groovy`, now throws `IllegalStateException`), `MavenProject` and friends resolved; in a v4 plugin realm they do not (`unable to resolve class org.apache.maven.plugin.MojoExecutionException`). With `addTestClassPath` the test class path is resolved by `session.resolveDependencies(project, Pat
hScope.TEST_RUNTIME)` plus the project's test and main output directories, minus the plugin's own artifact and dependencies.
**Public API changes**
- Plugin runs on Maven 4 only (v4 `Mojo`, `@Inject`, `@Mojo(defaultPhase = "...")`); all mojos throw the unchecked `MojoException`. `MojoFailureException` (BUILD FAILURE) and `MojoExecutionException` (error) are no longer distinguishable.
- Goals `install`, `run`, `integration-test`, `verify`, `report` and their parameters keep names and properties. `requiresDependencyResolution = TEST` and `threadSafe = true` are gone (no v4 attribute); `install` and `run` resolve what they need themselves.
- Defaults that changed: `localRepositoryPath` (install and run) has no expression default; it falls back to the session's local repository. `projectsDirectory` default is `${project.basedir}/src/it/` because `${basedir}` is not evaluated in v4 (it stays literal and `run` then reports "No projects were selected"). `invoker.install.scope` also accepts the v4 path scope ids.
- `AbstractInvokerMojo`/`InstallMojo` constructors are gone (`Invoker`, `SettingsBuilder`, `ToolchainManager`, `MavenProject`, `MavenSession` are no longer injected; `DefaultInvoker` is instantiated, v4 services come from `session.getService`). `InvokerReport` no longer takes an `I18N`; it reads the `invoker-report` bundle directly.
- Interpolation (`CompositeMap`) now reads `project.*`/`pom.*` from the effective `Model` (plus `basedir`, `file`): expressions that hit `MavenProject`-only getters (`project.artifact`, `project.file` as `File`, `project.compileSourceRoots`) no longer resolve.
- `mergeUserSettings`: the merge is hand-written (`mergeSettings` in `AbstractInvokerMojo`), dominant entries win by id, because the v4 API has no `SettingsUtils.merge`; the MINVOKER-133 `sourceLevelSet` reset has no counterpart (immutable settings model).
- POM scanning also follows `<subprojects>`, which v3 could not read (not exercised by an IT).
**Gaps**
- `invoker:install` cannot pin the resolver config of the staging repository. The v3 code cloned the repository session with `aether.enhancedLocalRepository.split=false` (MINVOKER-377); `Session.withLocalRepository` inherits the outer build's config and offers no way to override it. IT `MINVOKER-377-install-ignore-split-repo` fails (artifacts land under `installed/`, not the flat path). Not worked around: copying files and writing `maven-metadata-local.xml` by hand would be inventing an installer. The forked builds still get `-Daether.enhancedLocalRepository.split=false`, so `run` is unaffected.
- Report goal: **blocked**. It compiles against the local v4 `AbstractMavenReport` (reporting-impl 5.0.0-SNAPSHOT) but cannot run. Standalone, `mvn org.apache.maven.plugins:maven-invoker-plugin:4.0.0-beta-1-SNAPSHOT:report` fails with `A required class was missing ... report: org/apache/maven/execution/MavenSession` (`NoClassDefFoundError` at `LegacyMavenBridge.<init>` from `AbstractMavenReport.getSiteTool`, because the doxia-tools/site-tool side still needs maven-core classes that a v4 plugin realm does not have). Through `mvn site`, maven-site-plugin 3.22.0 fails with `Failed to get report for org.apache.maven.plugins:maven-invoker-plugin: Unable to lookup Mojo: Cannot cast org.apache.maven.plugins.invoker.InvokerReportFactory to org.apache.maven.plugin.Mojo` (IT `invoker-report`). Needs doxia-sitetools, site plugin and reporting-exec on v4 first.
- No v4 `Mojo`/`Plugin` API for "the plugin realm's artifacts" (`plugin.artifacts`): approximated with `MojoExecution.getPlugin().getArtifact()/getDependencies()` and `Session.getArtifactPath`.
- v4 dependency resolution omits the project's own output directories, added by hand for `addTestClassPath`.
- No removed tests; test changes: mocks of `MavenProject`/`MavenSession`/`Settings` replaced by mocks of `Project`/`Session`/`Settings`, constructors without arguments, `InterpolatorUtils` takes a `Map`. IT `settings-merge` script changed as above.
**User-visible changes**
- Maven 3 users stay on 3.x; the 4.x line needs Maven 4.
- IT scripts (Groovy/BeanShell) and `invoker.properties` keep working unless they touch Maven 3 API classes (see bindings); `${project.*}` filtering keeps working for model properties.
- `invoker:report`/site integration does not work on the 4.x line yet; `invoker:verify` and the `invoker-reports` XML are unchanged.
- Split local repository layouts of the invoking build are not neutralised by `invoker:install` (MINVOKER-377 regression).
**Improvements:** drops `maven-core`, `maven-model`, `maven-plugin-api`, `maven-artifact`, `maven-settings`, `maven-settings-builder`, `maven-resolver-api`/`-util`, `maven-plugin-annotations`, `javax.inject`, `plexus-i18n` and `sisu-maven-plugin`; the install logic no longer talks to `RepositorySystem`/`RepositoryUtils`/`ProjectArtifact`. `<prerequisites><maven>` follows `${mavenVersion}`.
**Recommendation:** port the run, install and verify goals as a 4.x line once MINVOKER-377 has an answer (a Session-level way to set resolver config, or a documented flat-layout install); keep the report goal on 3.x until the reporting chain is on v4 (then only `InvokerReport` and the renderer need touching). Scope: the 22 unrun ITs should be run before any merge.
</details>
<details><summary><b>maven-jarsigner-plugin</b>: ported</summary>
Branch `agent/mvn4-api`; PR not opened yet. Status: **ported**, 4.0.0-beta-1-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 51 tests before, 52 after (one added for the proxy path), 0 failures, 0 skipped; `mvn verify -Prun-its` → 9 of 9 ITs pass before and after; `spotless:check` clean. Smoke runs outside the ITs on rc-7 (scratch project, not committed): toolchain selected through maven-toolchains-plugin 3.2.0, active proxy passed to jarsigner (offline run), `storepass`/`keypass` encrypted in the legacy `{...}` form with a `settings-security.xml` master password. Not exercised: the new-format `settings-security4.xml`, the `gpg-agent`, `pinentry-prompt` and `system-property` master sources, Windows.
**Public API changes**
- `AbstractJarsignerMojo` implements `org.apache.maven.api.plugin.Mojo` instead of extending `AbstractMojo`; `execute()` and the protected hooks throw `MojoException` instead of `MojoExecutionException`. The protected constructor taking `JarSigner`, `ToolchainManager` and `SecDispatcher` is gone; the mojos get a `DefaultJarSigner` and their services injected.
- `@Parameter` types `File` → `Path` for `archive`, `archiveDirectory`, `workingDirectory` and `certchain`. `project`, `settings` and `session` are no longer parameters.
- `getLog()` returns `org.apache.maven.api.plugin.Log`.
- New public `ToolchainAdapter` (see Gaps), package-private `SecDispatchers`; `META-INF/plexus/components.xml` deleted.
- `maven-jarsigner` 3.1.0 is unchanged. It uses no Maven API, so it needed no port.
**Gaps**
- No service to decrypt a configuration value. The plugin decrypts `storepass` and `keypass` itself, and Maven's own decryptor is wired inside `maven-impl` (`DefaultSettingsBuilder`), not reachable from a plugin. `SecDispatchers` rebuilds it as `ApiRunner$SecDispatcherBindings` does, from `internal` classes of plexus-sec-dispatcher 4.2.0 (`AESGCMNoPadding`, `MasterDispatcher`, `LegacyDispatcher`, `DefaultSecDispatcher`), reading `${user.home}/.m2/settings-security4.xml`. That is a copy of Maven's wiring and will drift from it.
- Correction to the premise: the plugin reads no passwords from `Settings`, only the active proxy host, port and `nonProxyHosts`. For settings passwords the v4 route is `Session.getSettings()`: `maven-impl` wraps settings in a `DecryptingSettingsTransformer` for server and proxy passwords (seen in bytecode, not executed here).
- `Settings` has no `getActiveProxy()`; the plugin takes the first `Proxy` with `isActive()`.
- `ProjectManager` has no DI binding in rc-7 (`No binding to construct an instance for key ProjectManager`; `ArtifactManager`, `ToolchainManager`, `Session`, `Project`, `Log` do bind). The plugin uses `session.getService(ProjectManager.class)`.
- Toolchains silently stop working if the v4 toolchain is handed over as is: maven-shared-utils calls `findTool(String)` reflectively on the object's class, which is the non-public `DefaultJavaToolchainFactory$DefaultJavaToolchain`, so it logs `unexpected IllegalAccessException` at WARN and runs the JDK that runs Maven. `ToolchainAdapter` is a public wrapper for that call. A plugin on any `maven-shared-utils` `JavaTool` (jmod, jlink, jdeps, jdeprscan) has the same trap.
- `@Mojo` has no `threadSafe` attribute; `sign` keeps its own `threadCount` executor.
- The v4 `plugin.xml` lists every parameter with `<defaultValue>` and has no `<configuration>` block; the test helper `PluginXmlParser` reads the new layout. An unset `String[]` parameter (`tsa`, `tsacert`, `tsapolicyid`) arrives as an empty array, as the `basic` IT shows.
**User-visible changes**
- Needs Maven 4.0.0-rc-7 or newer and Java 17; the `<prerequisites>` follows `mavenVersion`. The plugin no longer loads under Maven 3.
- No goal or parameter name changes. Old-format encrypted passwords keep working through the legacy dispatcher.
- Runtime dependencies: plexus-sec-dispatcher goes from `org.sonatype.plexus:1.4` to `org.codehaus.plexus:4.2.0`, both bundled.
**Improvements:** drops `maven-plugin-api`, `maven-core`, `maven-artifact`, `maven-settings`, `maven-plugin-annotations`, `javax.inject` and the Plexus component descriptor.
**Recommendation:** port once the gaps are in the open: a decrypt service in the API, `ProjectManager` bindable, and a public toolchain type or `findTool` hook in maven-shared-utils. Release it as a separate 4.x line; the 3.x line keeps serving Maven 3.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Measure the impact of porting Maven components and plugins to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz closed issue #13302: Measure the impact of porting Maven components and plugins to the Maven 4 API
URL: https://github.com/apache/maven/issues/13302
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913797429
### maven-mapping
PR: apache/maven-mapping#77. Status: **ported**, 4.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 8 tests before, 10 after (new: timestamped SNAPSHOT `baseVersion`, non-jar extension), 0 failures; spotless clean.
**Public API change:** `MappingUtils.evaluateFileNameMapping(String, org.apache.maven.artifact.Artifact)` → `(String, org.apache.maven.api.Artifact)`. Dependencies drop to `maven-api-core` only.
**Gaps: tokens that no longer resolve**
- The v4 `Artifact` has no `ArtifactHandler`: `@{packaging}@`, `@{language}@`, `@{directory}@`, `@{addedToClasspath}@`, `@{includesDependencies}@` are gone. `@{extension}@` now comes from `Artifact.getExtension()`.
- No counterpart for the reflective `@{type}@`, `@{scope}@`, `@{file}@`. The path is available only via `ArtifactManager` or `DownloadedArtifact`.
- No plugin source or site doc in the estate uses the removed tokens; user POMs are unknown.
- Tests use a record stub because `Session.createArtifact` needs an `InternalSession`, so no public test fixture exists for a v4 `Artifact`.
**Consumers that break (compile):** maven-war-plugin `AbstractWarPackagingTask`; maven-ear-plugin `EarMojo`, `AbstractEarModule`. Both must move to the v4 `Artifact` together.
**Recommendation:** port; small change and every commonly used token keeps a source. Keep 3.x for the Maven 3 lines of war and ear.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "hboutemy (via GitHub)" <gi...@apache.org>.
hboutemy commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5914640683
Maven 4.0.0 is not out: cannot we wait a little bit before creating double maintenance?
I know it is funny to use AI and burn tokens, but it's not funny to augment the maintenance
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5915142764
### maven-build-cache-extension
PR: apache/maven-build-cache-extension#544 (CI only). Status: **blocked**, 1.3.1-SNAPSHOT, no code change.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 97 tests, 0 failures, 4 skipped. Smoke ITs not measured: `CoreExtensionTest` needs the extension installed in `target/local-repo`, which `verify` does not do.
31 `src/main` files use the Maven 3 API: `MavenProject` 22, `MavenSession` 16, `@SessionScoped` 11, `MojoExecution` 8.
**Gaps** (rc-7 `maven-api-spi`, `maven-api-core`)
- No SPI to skip or replace a mojo execution, which is how the cache restores a hit. `org.apache.maven.api.spi` has only the enum, language, lifecycle, model, packaging, scope, property and type providers.
- `Listener.onEvent(Event)` observes `MOJO_*` events but cannot skip one; a port on it could save but never restore.
- No lifecycle participant (`afterProjectsRead`, `afterSessionStart`, `afterSessionEnd`).
- No mojo-parameter expression evaluator or plugin manager, which the cache uses to compare effective mojo parameters.
- `MojosExecutionStrategy`, `MojoExecutionRunner`, `AbstractMavenLifecycleParticipant` exist only in `maven-core`.
**Consumers that break:** none in the estate; users load it through `.mvn/extensions.xml`.
**Recommendation:** do not port until the v4 SPI can skip or replace a mojo execution and hook project and session lifecycle; that is an API request for apache/maven.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913953337
### maven-fluido-skin
PR: apache/maven-fluido-skin#351 (CI only)
:white_check_mark: **Migration not needed:** no Java code.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → BUILD SUCCESS.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913667459
### maven-shared-resources
PR: apache/maven-shared-resources#89 (CI only; supersedes apache/maven-shared-resources#87)
Resource bundle only, no Java code. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → BUILD SUCCESS (no tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913666086
### maven-invoker
PR: apache/maven-invoker#189 (CI only)
No Maven API in `src/main`; nothing to port. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 108 tests, 0 failures, 1 skipped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913666944
### maven-script-interpreter
PR: apache/maven-script-interpreter#223 (CI only)
No Maven API in `src/main`; nothing to port. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 35 tests, 0 failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913665620
### maven-file-management
PR: apache/maven-file-management#119 (CI only)
No Maven API in `src/main`; nothing to port. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 14 tests, 0 failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913666483
### maven-jarsigner
PR: apache/maven-jarsigner#117 (CI only)
No Maven API in `src/main`; nothing to port. CI switched to `maven4-build`.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 13 tests, 0 failures.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913951602
### maven-reporting-exec
PR: apache/maven-reporting-exec#167. Status: **partial**, 3.0.0-SNAPSHOT, Java 17. Public API ported; implementation stays on maven-core.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 4 unit tests, 0 failures; ITs 0 of 5 pass (5 before). Every IT runs the released maven-site-plugin 3.22.0 against this snapshot and fails with `NoSuchMethodError: MavenReportExecutorRequest.setMavenSession(MavenSession)`. Spotless clean.
**Public API changes**
- `MavenReportExecutorRequest`: `get/setMavenSession(MavenSession)` → `get/setSession(org.apache.maven.api.Session)`; `get/setProject(MavenProject)` → `org.apache.maven.api.Project`; `setReportPlugins(org.apache.maven.model.ReportPlugin[])` → `org.apache.maven.api.model.ReportPlugin[]`.
- `MavenReportExecution`: `Plugin` → `org.apache.maven.api.model.Plugin`.
- `MavenReportExecutor.buildMavenReports` throws unchecked `MojoException` instead of checked `MojoExecutionException`.
**Gaps: the v4 API has no equivalent for what this component does**
- `MavenPluginManager`, `PluginDescriptor`, `MojoDescriptor`, `MojoExecution`, `PluginVersionResolver`, plugin realm setup, and `LifecycleExecutor.calculateForkedExecutions`/`executeForkedExecutions`. `DefaultMavenReportExecutor` and `MavenPluginManagerHelper` therefore stay on maven-core.
- `Session` → `MavenSession` and `Project` → `MavenProject` only via internal classes (`InternalMavenSession.from(...)`, `DefaultProject.getProject()`).
- `MavenProject.isExecutionRoot()` has no equivalent; `Project.isRootProject()` means the `.mvn` directory. This affects `canAggregate`.
- Tests stay on `@PlexusTest`, since maven-testing targets v4-DI mojos. They need `maven-compat` for `ToolchainManager` and `plexus-xml` 4.2.0, because parent 50 manages 3.0.1, which fails with `NoClassDefFoundError: Xpp3Dom$ChildrenTracking` on Maven 4.
**Consumers that break:** maven-site-plugin only (`AbstractSiteRenderingMojo`, `AutoRefreshMojo`, `SiteMojo`, `SiteJarMojo`, `SiteRunMojo`, `ReportDocumentRenderer`); shown at runtime by the ITs above.
**Recommendation:** keep a 3.x line; this port is a facade only. A real Maven 4 version needs a report-execution or plugin-manager API in `org.apache.maven.api`. If the Maven 4 site plugin gets one, retire this component in its favour.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5913952438
### maven-doxia
PR: apache/maven-doxia#1109 (CI only)
:white_check_mark: **Migration not needed:** no Maven API used in any module.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 681 tests, 0 failures, 3 skipped.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Port the shared components to the Maven 4 API [maven]
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on issue #13302:
URL: https://github.com/apache/maven/issues/13302#issuecomment-5914067962
### maven-dependency-analyzer
PR: apache/maven-dependency-analyzer#305. Status: **ported**, 2.0.0-SNAPSHOT, Java 17.
Verified locally: `mvn verify` with Maven 4.0.0-rc-7, JDK 21 → 134 unit tests before, 133 after, 0 failures. The removed test covered the null-session fallback, which no longer exists. ITs (`-P run-its`): 23 of 23 pass before and after; the IT mock plugin is now a Maven 4 API mojo. Spotless clean.
**Public API changes**
- `ProjectDependencyAnalyzer.analyze(MavenProject[, Collection])` → `analyze(Session, Project[, Collection])`. The analyzer resolves the classpath itself with `DependencyResolver.resolve(..., TEST_RUNTIME)` instead of reading `MavenProject.getArtifacts()`, so callers no longer need `requiresDependencyResolution`.
- `ProjectDependencyAnalysis`: `org.apache.maven.artifact.Artifact` → `org.apache.maven.api.Dependency` everywhere.
- `DependencyClassesProvider` and its implementations take `Project`; `getOutputClassesDirectory` returns `Path`.
- Injection moves from `javax.inject`/Sisu to `org.apache.maven.api.di`, with a hand-written index because the parent sets `<proc>none</proc>`.
**Gaps**
- No factory for a `Dependency` from `DependencyCoordinates`. Declared but unresolved dependencies (relocations) need one, so the port has a small package-private `DeclaredDependency`, its only shim.
- `DependencyResolverRequest.build()` requires a `pathScope` even for `RequestType.COLLECT` (NPE "pathScope cannot be null").
- `Type.getClassifier()` returns null for `jar`, and `Artifact.key()` then throws an NPE inside `hashCode`; the `jarWithRelocatedDependency` IT found it.
- `api.model.Build` has no `getPluginsAsMap()` (minor).
- IT plugins need maven-plugin-tools 4.0.0-beta-1 to build a v4 mojo.
**Consumers that break:** maven-dependency-plugin (`AbstractAnalyzeMojo`, `AnalyzeReport`, `AnalyzeReportRenderer`). It must become a Maven 4 API mojo to pass a `Session`. Its Plexus role-hint lookup of custom analyzers has no v4 DI equivalent.
**Improvements:** drops maven-core, maven-artifact, maven-model, resolver, plexus-xml and `javax.inject`. Replaces the `DependencyGraphProject extends MavenProject` hack with an explicit dependency list in the resolver request. `src/main` +680/-605 lines.
**Recommendation:** port as 2.0.0 and keep 1.17.x for maven-dependency-plugin 3.x.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org