Class AbstractGoalMojo

java.lang.Object
network.ike.plugin.support.AbstractGoalMojo
All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo

public abstract class AbstractGoalMojo extends Object implements org.apache.maven.api.plugin.Mojo
Common base class for IKE plugin mojos. Implements 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

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor — subclasses are instantiated by Maven's DI.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Run the goal and write its report.
    protected org.apache.maven.api.plugin.Log
    Access the Maven logger injected by Maven 4's plugin DI.
    protected IkePrompter
    The IkePrompter for this goal — built lazily from the session's interactive flag (IKE-Network/ike-issues#385).
    protected org.apache.maven.api.Session
    Access the Maven session injected by Maven 4's plugin DI.
    protected abstract GoalReportSpec
    Run this goal's work and return the report it produced.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 = false use it to derive the invocation directory from ProtoSession.getTopDirectory(), since Maven does not interpolate ${project.basedir} for them.

      Returns:
      the injected session (may be null in unit tests)
    • getPrompter

      protected IkePrompter getPrompter()
      The IkePrompter for 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.MojoException
      Run 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 implementing runGoal(); they cannot override execute() 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:
      execute in interface org.apache.maven.api.plugin.Mojo
      Throws:
      org.apache.maven.api.plugin.MojoException - if the goal fails
    • runGoal

      protected abstract GoalReportSpec runGoal() throws org.apache.maven.api.plugin.MojoException
      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 MojoException as 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