Repository navigation
Description
Context
As part of assessing the readiness of major Maven extensions to migrate to the Maven 4
API, we analyzed Tycho (build extension) and m2e (IDE embedder) — two projects
that together exercise nearly every Maven extension point: lifecycle participation,
dependency resolution, reactor graph, plugin realm management, classloading, and
embedded execution.
This issue tracks v4 API/SPI gaps not already fully covered by #13460 sub-issues.
Sub-issues
- v4 SPI: Lifecycle participation (afterProjectsRead, per-project callbacks, session end) #13514 — Lifecycle participation SPI (afterProjectsRead, per-project callbacks, session end)
- v4 SPI: Add findModel() to WorkspaceReader SPI #13515 — Add
findModel()to WorkspaceReader SPI - v4 SPI: Scoped service discovery from plugin classloaders #13516 — Scoped service discovery from plugin classloaders
- v4 API: Partial/filtered lifecycle execution for IDE embedders #13517 — Partial/filtered lifecycle execution for IDE embedders
- v4 API: Mojo configuration introspection without execution #13518 — Mojo configuration introspection without execution
- v4 API: Cache invalidation/eviction SPI for IDE embedders #13519 — Cache invalidation/eviction SPI for IDE embedders
- v4 SPI: Repository event listener for artifact/metadata changes #13520 — Repository event listener for artifact/metadata changes
Already tracked elsewhere
- Reactor graph SPI — Define v4 API for project dependency graph and migrate graph builder #13463 explicitly acknowledges a new v4 API design is needed.
Tycho'sTychoGraphBuilderwould benefit from a contributor/decorator model (add
edges to the graph) rather than requiring full graph builder replacement. - LegacySupport — should be obsoleted by proper session scoping in Migrate Session to v4 API (invert MavenSession / Session) #13462.
- Maven embedding API — Define v4 Maven execution service API for embedded use #13472 tracks the v4 execution service API for embedded
use. m2e's requirements (multi-session management, concurrent execution, extension
loading) should be scoped into this issue. - ClassRealm abstraction — Overall plan for classloader improvements in Maven 4.1 #13223 tracks classloader improvements. Tycho's
PlexusFrameworkConnectServiceFactoryand m2e'sEclipseClassRealmManagerDelegate
need stable classloader primitives covered by Layer 1.
Part 1 — Gaps identified from Tycho
Tycho is a build extension that replaces Maven's dependency resolution with P2/OSGi,
injects custom reactor graph edges, and bridges Maven's classloading with an embedded
Equinox runtime. It uses Maven 3 internals across ~400+ production source files.
1. Lifecycle Participation SPI → #13514
Tycho's TychoMavenLifecycleParticipant uses afterProjectsRead() to resolve the P2
target platform and inject dependencies into every MavenProject before any mojo
executes. TychoProjectExecutionListener uses beforeProjectLifecycleExecution() for
lazy per-project resolution with execution plan inspection.
The v4 Listener/Event mechanism is too generic — it lacks structured callbacks with
mutable project access. No equivalent of AbstractMavenLifecycleParticipant or
ProjectExecutionListener exists in org.apache.maven.api.spi.
2. Workspace Reader SPI → #13515
PR #13094 introduces org.apache.maven.api.spi.WorkspaceReader with findArtifact()
and findVersions(). However, Tycho's TychoWorkspaceReader implements
MavenWorkspaceReader which adds findModel(Artifact) — used to generate
synthetic POMs for P2 artifacts that have no Maven pom.xml.
3. Scoped SPI Discovery → #13516
Tycho's DefaultPluginRealmHelper uses BuildPluginManager.getPluginRealm(),
MavenPluginManager.getPluginDescriptor(), and PlexusContainer.lookupList() to
discover SPI extensions contributed by plugin dependencies. It switches thread context
classloaders to plugin ClassRealms for scoped lookups.
4. ClassRealm Abstraction → #13223
PlexusFrameworkConnectServiceFactory manages an embedded Equinox framework keyed by
ClassRealm. #13223 Layer 1 would solve the tycho-maven-plugin-as-extension-shim
problem; the embedded OSGi framework management needs stable classloader primitives.
Part 2 — Additional gaps identified from m2e
m2e is an IDE embedder that bootstraps the full Maven container, manages concurrent
sessions, executes filtered build plans, and reads plugin configuration for IDE project
setup. It uses Maven 3 internals across ~300+ production source files and overrides 8
Maven internal components to adapt Maven's single-shot build model to the IDE's mutable
workspace.
5. Partial/Filtered Lifecycle Execution → #13517
m2e computes the full lifecycle execution plan, filters it through lifecycle mapping
metadata, then executes surviving mojos one-by-one because there is no Maven API for
"run this filtered subset of the plan." It manually reimplements MojoExecutor's inner
loop with per-mojo dependency resolution and artifact state snapshot/restore.
6. Mojo Configuration Introspection → #13518
m2e project configurators read plugin parameter values without executing the mojo to
configure IDE projects. Uses MavenPluginManager.getConfiguredMojo() and
PluginParameterExpressionEvaluator — all internal APIs.
7. Cache Invalidation → #13519
m2e overrides 5 Maven cache components solely to add eviction/flushing for IDE
workspace mutability. Generalizing PR #13094's PluginRealmCache.invalidate() pattern
would eliminate all 5 overrides.
8. Repository Event SPI → #13520
m2e overrides RepositoryListener to index workspace repositories. A listener SPI for
repository events would eliminate this component override.
Cross-references
| Gap | Source | Sub-issue | Related |
|---|---|---|---|
| Lifecycle participation SPI | Tycho + m2e | #13514 | #13464, #13462 |
Workspace reader findModel |
Tycho | #13515 | PR #13094 |
| Scoped SPI discovery | Tycho | #13516 | #13465, #13223 |
| Partial lifecycle execution | m2e | #13517 | #13472, #13464 |
| Mojo config introspection | m2e | #13518 | #13465 |
| Cache invalidation | m2e | #13519 | PR #13094 |
| Repository event SPI | m2e | #13520 | — |
| ClassRealm abstraction | Tycho + m2e | — | #13223 |
| Reactor graph SPI | Tycho | — | #13463 (tracked) |
| LegacySupport | Tycho + m2e | — | #13462 (tracked) |
| Maven embedding API | m2e | — | #13472 (tracked) |
🤖 Drafted with Claude Code (Claude Opus 4.6, interactive mode). Reviewed and confirmed by @gnodet before submission.
Activity