You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "mariuszs (via GitHub)" <gi...@apache.org> on 2026/03/12 22:05:26 UTC
[I] Maven 4 ignores from components.xml for standard lifecycle phases [maven]
mariuszs opened a new issue, #11796:
URL: https://github.com/apache/maven/issues/11796
## Description
When a Maven plugin registers a custom lifecycle via `META-INF/plexus/components.xml` with `<default-phases>` binding goals to **standard lifecycle phases** (e.g. `process-sources`), Maven 4 loads the custom lifecycle but does not apply the default phase bindings. The same plugin works correctly on Maven 3.
This is different from [MNG-8299](https://issues.apache.org/jira/browse/MNG-8299) which tests custom phase names invoked directly (`mvn phase3`). This issue is about binding plugin goals to standard `default` lifecycle phases via `<extensions>true</extensions>`.
## Steps to reproduce
Minimal reproducer: https://github.com/mariuszs/extension-maven-plugin
1. Clone the repo
2. `mvn install -DskipTests`
3. Run the extension-it test project:
```bash
cd src/it/extension-it
# substitute template variables
sed 's/@project.groupId@/com.skillpanel/;s/@project.artifactId@/extension-maven-plugin/;s/@project.version@/1.0-SNAPSHOT/' pom.xml > /tmp/test-pom.xml
mvn compile -f /tmp/test-pom.xml
```
4. Check for `target/touch.txt` — it should exist but doesn't on Maven 4.
The plugin's `components.xml`:
```xml
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>extension-maven-plugin</role-hint>
<configuration>
<id>extension-maven-plugin</id>
<phases>
<phase>extension-not-used-phase</phase>
</phases>
<default-phases>
<process-sources>
com.skillpanel:extension-maven-plugin:touch
</process-sources>
</default-phases>
</configuration>
</component>
</components>
</component-set>
```
The consuming project POM (no `<executions>` needed — extensions handle binding):
```xml
<plugin>
<groupId>com.skillpanel</groupId>
<artifactId>extension-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
```
## Expected behavior
On **Maven 3.9.x**: the `touch` goal is automatically bound to `process-sources` phase via `<default-phases>`. Running `mvn compile` produces `target/touch.txt`.
```
[INFO] --- extension:1.0-SNAPSHOT:touch (default-touch) @ extension-it ---
```
## Actual behavior
On **Maven 4.0.0-rc-5**: the custom lifecycle is loaded but `<default-phases>` bindings are not applied. Debug log shows:
```
[DEBUG] Lifecycle extension-maven-plugin -> [extension-not-used-phase]
```
Only the dummy phase is visible — no goal bindings to `process-sources`. The `touch` goal never executes, `target/touch.txt` is not created.
## Environment
- Maven 4.0.0-rc-5
- Maven 3.9.13 (works correctly)
- Java 25 (also reproduced on Java 17)
- Linux
--
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
Re: [I] Maven 4 ignores from components.xml for standard lifecycle phases [maven]
Posted by "mariuszs (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Maven 4 ignores from components.xml for standard lifecycle phases [maven]
Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet closed issue #11796: Maven 4 ignores <default-phases> from components.xml for standard lifecycle phases
URL: https://github.com/apache/maven/issues/11796
--
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
For queries about this service, please contact Infrastructure at:
users@infra.apache.org