You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "gnodet (via GitHub)" <gi...@apache.org> on 2026/10/13 09:35:58 UTC

[I] Migrate Session to v4 API (invert MavenSession / Session) [maven]

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

   Part of #13460 — Migrate Maven internals from v3 to v4 API
   
   ## Context
   
   Currently the v4 `DefaultSession` wraps the v3 `MavenSession`. This means every v4 service that needs session state reaches through to the v3 object underneath. Inverting this is foundational for all later migration phases — every service needs a session.
   
   ## Goal
   
   Create a v4-native session implementation so `MavenSession` (v3) becomes a thin compat wrapper over the v4 session, instead of the other way around.
   
   ## Key files
   
   - **v4 API**: `api/maven-api-core/.../Session.java`, `ProtoSession.java`
   - **v4 impl**: `impl/maven-core/.../internal/impl/DefaultSession.java`
   - **v3 session**: `impl/maven-core/.../execution/MavenSession.java`
   - **Bridge**: `impl/maven-core/.../internal/impl/InternalMavenSession.java`
   
   ## Approach
   
   1. Create a v4-native session implementation in `impl/maven-impl` that holds its own state (projects, settings, repositories, properties, etc.)
   2. Make `MavenSession` (v3) a thin wrapper that delegates to the v4 session
   3. Update `DefaultMaven` to create the v4 session first, then wrap it for v3 callers
   4. `MavenSession` is imported in ~59 files — these don't all need to change at once, since `MavenSession` stays available
   
   ## Compatibility
   
   `MavenSession` stays available for plugin injection (`@Parameter`). Plugins calling `session.getCurrentProject()`, `session.getGoals()`, etc. continue to work unchanged.
   
   ## Dependencies
   
   - Ideally done after or alongside the Project Builder inversion (#13461), since the session holds projects
   
   ## Complexity
   
   High. `MavenSession` is a data holder used in 59+ files, but the inversion is conceptually straightforward since the interface doesn't change.
   
   _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: issues-unsubscribe@maven.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org