mariuszs commented on issue #11796:
URL: https://github.com/apache/maven/issues/11796#issuecomment-4055716318

   ## Root cause analysis
   
   The issue is in `DefaultLifecycleRegistry.LifecycleWrapperProvider.wrap()` 
([source](https://github.com/apache/maven/blob/maven-4.0.x/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java)).
   
   ### The conversion path
   
   1. Plexus creates legacy `Lifecycle` with 
`phases=["extension-not-used-phase"]` and `defaultPhases={"process-sources": 
"com.skillpanel:extension-maven-plugin:touch"}`
   
   2. `LifecycleWrapperProvider.wrap()` converts this to the new 
`org.apache.maven.api.Lifecycle` interface, but **only creates `Phase` objects 
for names from `getPhases()`** — i.e. only `extension-not-used-phase`
   
   3. Each Phase's `plugins()` method does consult 
`lifecycle.getDefaultLifecyclePhases()`, but it looks up by its own name. Since 
no `Phase` object exists for `process-sources`, that binding is silently lost.
   
   4. `DefaultLifecycles.lookupLifecycles()` then wraps the new API Lifecycle 
back into a legacy `Lifecycle`. It extracts `defaultPhases` from the new API 
phases — but those have no plugins (lost in step 2). Result: `defaultPhases` is 
empty.
   
   5. 
`DefaultLifecyclePluginAnalyzer.getPluginsBoundByDefaultToAllLifecycles()` 
correctly reads `getDefaultLifecyclePhases()`, but receives an empty map.
   
   ### The fundamental issue
   
   In Maven 3, `<default-phases>` was a mechanism to bind plugin goals to 
phases of **other lifecycles** (the standard `default` lifecycle), not just 
phases of the custom lifecycle itself. The new Maven 4 `Lifecycle` API 
(`Phase.plugins()`) assumes bindings are scoped to the lifecycle's own phases. 
The bridge code in `wrap()` cannot represent these cross-lifecycle bindings.
   
   Debug log confirms the lifecycle is loaded but without bindings:
   ```
   [DEBUG] Lifecycle extension-maven-plugin -> [extension-not-used-phase]
   ```
   
   The `toString()` on the new API Lifecycle only shows phases from 
`getPhases()`, confirming `process-sources` binding was dropped during 
conversion.


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