gnodet-bot commented on code in PR #13365:
URL: https://github.com/apache/maven/pull/13365#discussion_r4236655813
##########
api/maven-api-core/src/main/java/org/apache/maven/api/Plugin.java:
##########
@@ -28,33 +28,74 @@
import org.apache.maven.api.plugin.descriptor.lifecycle.Lifecycle;
/**
- * Represents a maven plugin runtime
+ * Represents a loaded Maven plugin runtime instance.
+ * <p>
+ * A {@code Plugin} provides access to the plugin's POM {@linkplain
org.apache.maven.api.model.Plugin model},
+ * its {@link PluginDescriptor descriptor}, custom build {@linkplain Lifecycle
lifecycles}, isolated
+ * {@link ClassLoader}, main {@link Artifact}, and runtime plugin {@linkplain
Dependency dependencies}.
+ * </p>
*
* @since 4.0.0
+ * @see MojoExecution#getPlugin()
*/
@Experimental
public interface Plugin {
+ /**
+ * Returns the POM model representation of this plugin.
+ *
+ * @return the plugin model from the POM, never {@code null}
+ */
@Nonnull
org.apache.maven.api.model.Plugin getModel();
+ /**
+ * Returns the plugin descriptor containing metadata about mojos,
parameters, and requirements.
+ *
+ * @return the plugin descriptor, never {@code null}
+ */
@Nonnull
PluginDescriptor getDescriptor();
+ /**
+ * Returns the custom build lifecycles defined by this plugin, if any.
+ *
+ * @return an unmodifiable list of custom {@link Lifecycle} definitions,
never {@code null}
+ */
@Nonnull
List<Lifecycle> getLifecycles();
+ /**
+ * Returns the {@link ClassLoader} used to load this plugin and its
dependencies.
+ *
+ * @return the plugin class loader, never {@code null}
+ */
@Nonnull
ClassLoader getClassLoader();
+ /**
+ * Returns the primary {@link Artifact} of this plugin.
+ *
+ * @return the plugin artifact, never {@code null}
+ */
@Nonnull
Artifact getArtifact();
Review Comment:
💡 **Informational:** `@return the plugin artifact, never {@code null}` — but
the `DefaultMojoExecution` anonymous `Plugin` implementation returns `null`
when `resolverArtifact` is null: `return resolverArtifact != null ?
session.getArtifact(resolverArtifact) : null`. Low-severity (the null path is
unlikely in practice) and pre-existing, but worth noting given this PR's goal
of improving API accuracy.
##########
api/maven-api-core/src/main/java/org/apache/maven/api/MojoExecution.java:
##########
@@ -37,24 +38,59 @@
@Experimental
public interface MojoExecution {
+ /**
+ * Returns the runtime {@link Plugin} associated with this execution.
+ *
+ * @return the plugin runtime, never {@code null}
+ */
@Nonnull
Plugin getPlugin();
+ /**
+ * Returns the POM model {@link PluginExecution} corresponding to this
execution.
+ *
+ * @return the plugin execution model, never {@code null}
+ */
@Nonnull
PluginExecution getModel();
Review Comment:
💡 **Informational:** The new `@return` says `never {@code null}`, but
`DefaultMojoExecution.getModel()` returns `.orElse(null)` — null is returned
when no `PluginExecution` element matches the execution ID (e.g. for direct CLI
invocations like `mvn group:artifact:goal` with no `<execution>` block in the
POM).
This is the same class of mismatch that was correctly fixed for
`getLifecyclePhase()`. The `@Nonnull` annotation is pre-existing on master, so
this isn't introduced by the PR, but the new Javadoc text reinforces an
inaccurate contract. Non-blocking since #13366 will rewrite `MojoExecution`
with `Optional<PluginExecution> model()` that makes the optionality explicit.
--
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]