This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/master by this push:
     new 4a57b5ae5e fix: deprecate org.apache.maven.api.di.MojoExecutionScoped 
(#13839) (#14147)
4a57b5ae5e is described below

commit 4a57b5ae5eaf22b0f51302f2a8ab0c499c387187
Author: Guillaume Nodet <[email protected]>
AuthorDate: Fri Nov 27 10:02:45 2026 +0100

    fix: deprecate org.apache.maven.api.di.MojoExecutionScoped (#13839) (#14147)
    
    Deprecates `MojoExecutionScoped` on master as proposed in #13839.
    
    Three reasons:
    1. The Guice/Sisu binding is commented out in MojoExecutionScopeModule — 
the annotation has no runtime effect.
    2. No proxy path: injecting a @MojoExecutionScoped component into a wider 
scope throws DIException at startup.
    3. v4 plugins don't need it: DefaultMavenPluginManager creates a fresh 
injector per mojo execution and binds Session, Project, MojoExecution, and Log 
via bindInstance.
    
    Forward-port of #14116 (maven-4.0.x).
    Fixes #13839
---
 .../apache/maven/api/di/MojoExecutionScoped.java   | 26 ++++++++++++++--------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git 
a/api/maven-api-di/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
 
b/api/maven-api-di/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
index 729ec5e107..ec0b8cf0fc 100644
--- 
a/api/maven-api-di/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
+++ 
b/api/maven-api-di/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
@@ -27,18 +27,26 @@
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
 /**
- * Indicates that the annotated bean has a lifespan limited to a given mojo 
execution,
- * which means each mojo execution will result in a different instance being 
injected.
- * <p>
- * The following objects will be bound to the mojo execution scope:
- *     <ul>
- *         <li>{@code org.apache.maven.api.MojoExecution}</li>
- *         <li>{@code org.apache.maven.api.Project}</li>
- *         <li>{@code org.apache.maven.api.plugin.Log}</li>
- *     </ul>
+ * Was intended to indicate that the annotated bean has a lifespan limited to 
a given
+ * mojo execution, but this annotation is unfinished and has no effect.
+ *
+ * @deprecated Unfinished — do not use. The Guice/Sisu binding for this scope 
is
+ *     commented out in {@code MojoExecutionScopeModule}, so the annotation 
has no
+ *     effect. Additionally, unlike {@link SessionScoped}, the mojo execution 
scope
+ *     does not create a proxy when a scoped component is injected into a 
wider scope,
+ *     causing a {@code DIException} at startup.
+ *     <p>
+ *     For v4 plugins, no scope annotation is needed: {@code 
DefaultMavenPluginManager}
+ *     creates a fresh injector per mojo execution and binds {@code Session},
+ *     {@code Project}, {@code MojoExecution}, and {@code Log} directly via
+ *     {@code bindInstance}, so plain {@code @Inject} is sufficient.
+ *     <p>
+ *     For legacy extension components in the shared Plexus/Sisu container, use
+ *     {@code org.apache.maven.execution.scope.MojoExecutionScoped} instead.
  *
  * @since 4.0.0
  */
+@Deprecated(since = "4.0.0", forRemoval = true)
 @Scope
 @Documented
 @Retention(RUNTIME)

Reply via email to