gnodet-bot commented on code in PR #13365:
URL: https://github.com/apache/maven/pull/13365#discussion_r4206760917
##########
api/maven-api-core/src/main/java/org/apache/maven/api/MojoExecution.java:
##########
@@ -37,24 +37,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();
+ /**
+ * Returns the {@link MojoDescriptor} describing the mojo to be executed.
+ *
+ * @return the mojo descriptor, never {@code null}
+ */
@Nonnull
MojoDescriptor getDescriptor();
+ /**
+ * Returns the unique execution identifier within the plugin configuration.
+ *
+ * @return the execution ID, never {@code null}
+ */
@Nonnull
String getExecutionId();
+ /**
+ * Returns the goal name executed by this mojo.
+ *
+ * @return the mojo goal, never {@code null}
+ */
@Nonnull
String getGoal();
+ /**
Review Comment:
⚠️ **Inaccurate `@return` description for `getLifecyclePhase()`**
The doc says `"or an empty string if not bound to a phase"`, but the actual
contract is `null`, not `""`. The backing field (`MojoExecution.lifecyclePhase`
in `impl/maven-core`) is not initialized — it starts as `null` — and internal
callers (`BuildPlanExecutor`, `PhaseRecorder`) explicitly null-check it with
`if (execution.getLifecyclePhase() != null)`.
The `@Nonnull` annotation on this method is also inconsistent with this:
either the annotation should be dropped, or the implementation should guarantee
non-null. If the intent is that the interface contract is `@Nonnull`
(implementation must coerce null to `""`), that invariant is not currently
enforced.
Pick one of:
- If `null` is a valid return (not bound to a phase): drop `@Nonnull`,
change the `@return` to state `null` may be returned
- If the contract should be non-null: fix the implementation to return `""`
when unset
```suggestion
* Returns the build lifecycle phase to which this execution is bound.
*
* @return the lifecycle phase name, or {@code null} if not bound to a
phase
*/
```
--
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]