Class AbstractGoalMojo
- All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo
execute()
as a final template: every goal does its work in
runGoal() and returns a GoalReportSpec, and the
base class writes exactly one markdown session report to
<projectRoot>/<prefix>꞉<goal>.md (e.g.
ike꞉release-publish.md, idoc꞉asciidoc.md). Because
the report is a required return value, a goal cannot be written
that silently produces none (IKE-Network/ike-issues#413, #407).
The report writer self-heals .gitignore to keep reports
out of source control — see GoalReport. A single base class
serves every IKE plugin because goals identify themselves via the
GoalRef interface, not a plugin-specific enum type.
See ike-issues #215 for the split that introduced this class.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor — subclasses are instantiated by Maven's DI. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidexecute()Run the goal and write its report.protected org.apache.maven.api.plugin.LoggetLog()Access the Maven logger injected by Maven 4's plugin DI.protected IkePrompterTheIkePrompterfor this goal — built lazily from the session's interactive flag (IKE-Network/ike-issues#385).protected org.apache.maven.api.SessionAccess the Maven session injected by Maven 4's plugin DI.protected abstract GoalReportSpecrunGoal()Run this goal's work and return the report it produced.
-
Constructor Details
-
AbstractGoalMojo
protected AbstractGoalMojo()Default constructor — subclasses are instantiated by Maven's DI.
-
-
Method Details
-
getLog
protected org.apache.maven.api.plugin.Log getLog()Access the Maven logger injected by Maven 4's plugin DI.- Returns:
- the injected logger
-
getSession
protected org.apache.maven.api.Session getSession()Access the Maven session injected by Maven 4's plugin DI.Goals annotated
projectRequired = falseuse it to derive the invocation directory fromProtoSession.getTopDirectory(), since Maven does not interpolate${project.basedir}for them.- Returns:
- the injected session (may be
nullin unit tests)
-
getPrompter
TheIkePrompterfor this goal — built lazily from the session's interactive flag (IKE-Network/ike-issues#385). Renders an inline prompt on a real terminal, an own-line prompt in a piped IDE runner, and declines in batch mode.- Returns:
- the prompter (never
null)
-
execute
public final void execute() throws org.apache.maven.api.plugin.MojoExceptionRun the goal and write its report.This method is
final: every IKE goal follows the same template — do the work, then write exactly one report. Subclasses supply the work and the report content by implementingrunGoal(); they cannot overrideexecute()to skip the report. That is what makes report-writing structural — a goal that compiles necessarily writes a report (the #407 bug class becomes impossible; IKE-Network/ike-issues#413).- Specified by:
executein interfaceorg.apache.maven.api.plugin.Mojo- Throws:
org.apache.maven.api.plugin.MojoException- if the goal fails
-
runGoal
Run this goal's work and return the report it produced.Implementations do the goal's actual work here and return a
GoalReportSpec— the goal identity, the directory the report file lands in, and the Markdown body. The base class writes it. A goal cannot be implemented without producing a report, which is the structural fix for the missing-report bug class (IKE-Network/ike-issues#413 / #407).On failure, throw
MojoExceptionas usual — a failed goal produces no report, and Maven surfaces the exception.- Returns:
- the report this goal produced (never
null) - Throws:
org.apache.maven.api.plugin.MojoException- if the goal fails
-