gnodet opened a new issue, #13460:
URL: https://github.com/apache/maven/issues/13460

   ## Goal
   
   Progressively migrate Maven's internal implementation from v3 API types 
(`MavenProject`, `MavenSession`, v3 `Artifact`, etc.) to v4 API types 
(`Project`, `Session`, v4 `Artifact`, etc.), while **preserving full backward 
compatibility** with existing Maven 3 plugins.
   
   This is a long-term effort toward Maven 5, where the `compat/` modules can 
be dropped entirely.
   
   ## Current State
   
   The **model builder** has already been successfully migrated: the real logic 
lives in `impl/maven-impl` using v4 types natively, and the v3 
`DefaultModelBuilder` in `compat/` delegates to it. This is the pattern to 
follow for all other subsystems.
   
   However, the **entire build orchestration pipeline** still runs on v3 types 
internally:
   
   ```
   DefaultMaven.doExecute(MavenExecutionRequest)           ← v3
     → DefaultGraphBuilder.build(MavenSession)              ← v3
       → Collection strategies → v3 ProjectBuilder           ← v3
         → builds List<MavenProject>                          ← v3
       → DefaultProjectDependencyGraph                        ← v3
     → LifecycleStarter.execute(MavenSession)               ← v3
       → BuildPlanExecutor / MultiThreadedBuilder             ← v3
         → LifecycleModuleBuilder → MojoExecutor              ← v3
           → BuildPluginManager / MavenPluginManager           ← v3
   ```
   
   In `impl/maven-core`, **~209 of 384 Java files** still import v3 types:
   - `MavenProject`: ~95 files
   - `MavenSession`: ~59 files
   - v3 `Artifact`: ~44 files
   
   ### Already v4-native (in `impl/maven-impl`)
   
   - Model builder + all sub-services (interpolator, normalizer, inheritance 
assembler, profile selector, etc.)
   - Artifact services (factory, resolver, installer, deployer)
   - Dependency resolver
   - Settings/toolchains builders
   - Repository services
   - Version resolver/range resolver
   
   ## Strategy: Inversion, Not Removal
   
   The migration follows the **inversion pattern** proven by the model builder:
   
   1. **Create a v4-native implementation** in `impl/maven-impl`
   2. **Invert the delegation**: make the v3 compat class delegate to the v4 
implementation (not the other way around)
   3. **Keep v3 types as wrappers** for plugin compatibility — plugins still 
inject `MavenProject`, `MavenSession`, etc.
   
   **Today:**
   ```
   v4 API wrapper → delegates to → v3 implementation (real logic)
   ```
   
   **After migration:**
   ```
   v3 compat wrapper → delegates to → v4 implementation (real logic)
   ```
   
   Plugins don't notice the change — they keep using v3 types that are now thin 
wrappers around v4 objects.
   
   ## Migration Phases
   
   Each phase is tracked as a separate sub-issue that can be picked up 
independently (though some have ordering dependencies noted below).
   
   ### Phase 1 — Project Builder inversion
   Move project-building logic from 
`maven-core/.../project/DefaultProjectBuilder` (v3, ~1420 lines) into a 
v4-native implementation in `maven-impl`. The v3 project builder already 
delegates to the v4 model builder internally, so the hardest sub-problem is 
solved.
   
   ### Phase 2 — Session inversion
   Invert so v3 `MavenSession` wraps a v4 `Session` (currently it's the 
opposite — v4 `DefaultSession` wraps v3 `MavenSession`).
   
   ### Phase 3 — Graph builder / reactor (v4 API design + implementation)
   Define a v4 API for the project dependency graph (no equivalent exists 
today), then implement it in `maven-impl`.
   
   ### Phase 4 — Lifecycle engine
   Migrate the lifecycle execution pipeline (~44 files) to v4 types. This is 
the largest phase and likely needs to be broken into sub-phases. Depends on 
phases 1-3.
   
   ### Phase 5 — Plugin system
   Migrate internal plugin resolution, caching, and management (~28 files) to 
v4 types. Plugin-facing API (`AbstractMojo`, `PluginDescriptor`, etc.) stays in 
`compat/`.
   
   ### Phase 6 — Orchestrator and CLI
   Once everything below is v4-native, `DefaultMaven` and the CLI can work with 
v4 types directly.
   
   ### Quick wins (can start now, no ordering dependency)
   - Event loggers (~6 files) — migrate to v4 `ExecutionEvent`
   - `DefaultProject` inversion — hold v4 types natively instead of wrapping 
`MavenProject`
   - Collection strategies — small classes, easy to migrate once project 
builder is done
   
   ## Public API Boundary (must stay for compat until Maven 5)
   
   These types are injected into plugins and **cannot be removed** until Maven 
5:
   - `org.apache.maven.project.MavenProject`
   - `org.apache.maven.execution.MavenSession`
   - `org.apache.maven.plugin.AbstractMojo` / `Mojo`
   - `org.apache.maven.plugin.descriptor.PluginDescriptor` / `MojoDescriptor`
   - `org.apache.maven.model.*` (v3 model types)
   - `org.apache.maven.artifact.Artifact`
   - `org.apache.maven.settings.Settings`
   
   They become thin wrappers over v4 types, not removed.
   
   _Claude Code on behalf of Guillaume Nodet_


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to