getService(DependencyFactory.class).create(...)
+ * @see DependencyCoordinateFactory#create(Session, Dependency)
+ */
+ @Nonnull
+ DependencyCoordinate createDependencyCoordinate(@Nonnull Dependency dependency);
+
/**
* Shortcut for getService(ArtifactFactory.class).create(...)
* @see org.apache.maven.api.services.ArtifactFactory#create(Session, String, String, String, String)
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java b/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
index 2dc3e224a5d9..375ac5f9f9ae 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/VersionRange.java
@@ -29,7 +29,7 @@
@Experimental
public interface VersionRange {
- // TODO: add access to the version information
+ // TODO: v4: add access to the version information
/**
* Determines whether the specified version is contained within this range.
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java b/api/maven-api-core/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
similarity index 51%
rename from api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java
rename to api/maven-api-core/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
index 305d3cc3929d..2fcbe07991ce 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/Component.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/di/MojoExecutionScoped.java
@@ -16,42 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.api.plugin.annotations;
+package org.apache.maven.api.di;
import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.apache.maven.api.annotations.Experimental;
-import org.apache.maven.api.annotations.Nonnull;
+import jakarta.inject.Scope;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Used to configure injection of Plexus components by
- *
- * MavenPluginManager.getConfiguredMojo(...).
+ * 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.
*
* @since 4.0.0
*/
-@Experimental
+@Scope
@Documented
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
-@Inherited
-public @interface Component {
- /**
- * role of the component to inject.
- * @return the role
- */
- @Nonnull
- Class> role() default Object.class;
-
- /**
- * hint of the component to inject.
- * @return the hint
- */
- @Nonnull
- String hint() default "";
-}
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+public @interface MojoExecutionScoped {}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java b/api/maven-api-core/src/main/java/org/apache/maven/api/di/SessionScoped.java
similarity index 58%
rename from api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java
rename to api/maven-api-core/src/main/java/org/apache/maven/api/di/SessionScoped.java
index 29cec2649a3d..d5e9a0ddbe53 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/annotations/InstantiationStrategy.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/di/SessionScoped.java
@@ -16,29 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.maven.api.plugin.annotations;
+package org.apache.maven.api.di;
-import org.apache.maven.api.annotations.Experimental;
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import jakarta.inject.Scope;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Component instantiation strategy.
+ * Indicates that annotated component should be instantiated before session execution starts
+ * and discarded after session execution completes.
*
* @since 4.0.0
*/
-@Experimental
-public enum InstantiationStrategy {
- PER_LOOKUP("per-lookup"),
- SINGLETON("singleton"),
- KEEP_ALIVE("keep-alive"),
- POOLABLE("poolable");
-
- private final String id;
-
- InstantiationStrategy(String id) {
- this.id = id;
- }
-
- public String id() {
- return this.id;
- }
-}
+@Scope
+@Documented
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+public @interface SessionScoped {}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/feature/Features.java b/api/maven-api-core/src/main/java/org/apache/maven/api/feature/Features.java
index 04ab33d8643c..027591c4dfb3 100644
--- a/api/maven-api-core/src/main/java/org/apache/maven/api/feature/Features.java
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/feature/Features.java
@@ -34,6 +34,8 @@ public final class Features {
/**
* Name of the Maven user property to enable or disable the build/consumer POM feature.
+ *
+ * TODO: v4: remove experimental bit
*/
public static final String BUILDCONSUMER = "maven.experimental.buildconsumer";
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/LifecycleProvider.java b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/LifecycleProvider.java
new file mode 100644
index 000000000000..05046da6a223
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/plugin/LifecycleProvider.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.plugin;
+
+import java.util.List;
+
+import org.apache.maven.api.annotations.Consumer;
+import org.apache.maven.api.annotations.Experimental;
+import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
+
+/**
+ * Interface that can be provided by the plugin to wire in custom lifecycles
+ * leveraged using the {@link org.apache.maven.api.plugin.annotations.Execute}
+ * annotation. If a {@code META-INF/maven/lifecycle.xml} file is packaged
+ * in the plugin, Maven will provide a default implementation that will parse
+ * the file and return the contained lifecycle definitions.
+ */
+@Experimental
+@Consumer
+public interface LifecycleProvider {
+
+ Listper-lookup and singleton are supported)
- * @return the instantiation strategy
- */
- @Nonnull
- InstantiationStrategy instantiationStrategy() default InstantiationStrategy.PER_LOOKUP;
+ ResolutionScope dependencyCollectionRequired() default ResolutionScope.NONE;
/**
* does your mojo requires a project to be executed?
* @return requires a project
*/
- boolean requiresProject() default true;
+ boolean projectRequired() default true;
/**
* if the Mojo uses the Maven project and its child modules.
@@ -91,9 +87,10 @@
* does this Mojo need to be online to be executed?
* @return need to be online
*/
- boolean requiresOnline() default false;
+ boolean onlineRequired() default false;
/**
+ * TODO: v4: add a SPI for the configurator
* configurator bean name.
* @return the configurator bean name
*/
diff --git a/api/maven-api-plugin/pom.xml b/api/maven-api-plugin/pom.xml
new file mode 100644
index 000000000000..b5b4713ea510
--- /dev/null
+++ b/api/maven-api-plugin/pom.xml
@@ -0,0 +1,105 @@
+
+
+Notice: this documentation is generated from a Modello model but the
- PluginDescriptor/MojoDescriptor
- code executed is not generated from this model. Please report if you find anything wrong this documentation.
An XSD is available at https://maven.apache.org/xsd/plugin-1.1.0.xsd
+ Maven 4 Plugin descriptor, stored inMETA-INF/maven/plugin.xml in a plugin's jar artifact.
+ This descriptor is generally using the information contained in the annotations of the plugin api.
+ An XSD is available at https://maven.apache.org/xsd/plugin-2.0.0.xsd
]]>
+ runtime, test,
+ compile+runtime (since Maven 3.0) or runtime+system (since Maven 3.0)
+ ]]>always.
@@ -331,7 +379,7 @@ under the License.