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

   ## Context
   
   As part of assessing Tycho's readiness to migrate to the Maven 4 API, we 
identified
   areas where the v4 API/SPI surface is insufficient for deep build 
extensions. Tycho is
   a useful stress-test case because it touches nearly every Maven extension 
point:
   lifecycle participation, dependency resolution, reactor graph, plugin realm 
management,
   and classloading.
   
   This issue tracks gaps not already fully covered by #13460 sub-issues.
   
   ## Gaps
   
   ### 1. Lifecycle Participation SPI — implicitly in scope for #13464, not 
explicit
   
   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`.
   
   **Needed:** A lifecycle participation SPI with:
   - `afterProjectsRead` equivalent (with mutable project access)
   - Per-project before/after execution callbacks (with execution plan access)
   - Session end callback
   
   This overlaps with #13464 (lifecycle engine) and #13462 (session inversion), 
but the
   *public SPI contract* isn't explicitly scoped in either.
   
   ### 2. Workspace Reader SPI — partially addressed by #13094
   
   PR #13094 introduces `org.apache.maven.api.spi.WorkspaceReader` with 
`findArtifact()`
   and `findVersions()`. This covers the base `WorkspaceReader` contract.
   
   However, Tycho's `TychoWorkspaceReader` implements `MavenWorkspaceReader` 
which adds
   **`findModel(Artifact)`** — used to generate synthetic POMs for P2 artifacts 
that have
   no Maven pom.xml. This method is not in the PR #13094 SPI.
   
   **Needed:** Consider adding `findModel()` (or equivalent) to the v4 
`WorkspaceReader`
   SPI for extensions that resolve non-Maven artifacts requiring synthetic model
   generation.
   
   ### 3. Scoped SPI Discovery — partially covered by #13465 + #13223
   
   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.
   
   **Needed:**
   - Plugin descriptor/dependency introspection API
   - Scoped service lookup (find services contributed by a specific plugin's 
classloader)
   - Intersects with #13223 Layer 1 (per-realm import descriptor) and laeubi's 
comment
     about plugins declaring SPI artifacts
   
   ### 4. ClassRealm Abstraction — partially covered by #13223
   
   `PlexusFrameworkConnectServiceFactory` manages an embedded Equinox framework 
keyed by
   `ClassRealm`, using `realm.getParentRealm()`, `realm.getImportRealms()`,
   `realm.loadResourcesFromSelf()`, and cross-realm reflection for framework 
sharing.
   
   **Needed:** A stable classloader abstraction (or extension-classloader SPI) 
providing:
   - Classpath resource enumeration for a plugin/extension
   - Identity semantics for classloader-scoped caching
   - Cross-boundary service sharing without reflection
   
   #13223 Layer 1 would solve the `tycho-maven-plugin`-as-extension-shim 
problem, but
   the embedded OSGi framework management needs stable classloader primitives.
   
   ## Already tracked
   
   - **Reactor graph SPI** — #13463 explicitly acknowledges a new v4 API design 
is needed.
     Tycho's `TychoGraphBuilder` would 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 
#13462.
   
   ## Cross-references
   
   | Gap | Related |
   |-----|---------|
   | Lifecycle participation SPI | #13464, #13462 |
   | Workspace reader SPI | #13094, #13460 |
   | Scoped SPI discovery | #13465, #13223 |
   | ClassRealm abstraction | #13223, #13465 |
   | Reactor graph SPI | #13463 (tracked) |
   | LegacySupport | #13462 (tracked) |
   
   <!-- AI-Agent-Disclosure -->
   > 🤖 Drafted with Claude Code (Claude Opus 4.6, interactive mode). Reviewed 
and confirmed by @gnodet before submission.


-- 
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