Class ActMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="act", aggregator=true, threadSafe=true, requiresProject=false, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public class ActMojo extends AbstractActMojo
Maven goal that executes a Ghostwriter act against project files.

This goal creates an ActProcessor, resolves configuration from Maven parameters, user configFile, and Ghostwriter configuration files, and then scans the selected path. The goal is an aggregator, is thread-safe, and can run without a pom.xml. Its direct superclass, AbstractActMojo, supplies act resolution, interactive prompting, and act scanning. The parent AbstractGWMojo supplies common Ghostwriter parameters such as the base directory, model, path, instructions, excludes, Maven execution context, configuration, and shared class-scanning tools.

Processing order for gw:act

Files are processed in reverse order, matching the Ghostwriter CLI behavior: sub-modules are processed first and parent modules are processed afterward. When Maven parallel execution is enabled, modules are processed by Ghostwriter rather than by the Maven reactor. For improved performance, run for example:


 mvn -T 4 gw:act
 

Parameters declared by this goal

  • gw.act: action prompt text or the name of a predefined act. If it is omitted, the goal obtains the value from configured properties or, when interactive input is available, prompts for it. Examples:
    
     mvn gw:act -Dgw.act="Add missing Javadocs"
     mvn gw:act -Dgw.act=review
     
  • gw.acts: optional local directory or URL containing predefined act definitions. It changes the location searched when gw.act names an act. Examples:
    
     mvn gw:act -Dgw.acts=.ghostwriter/acts -Dgw.act=review
     mvn gw:act -Dgw.acts=src/gw/acts -Dgw.act=documentation
     

Inherited Maven plugin parameters

The following commonly used parameters are inherited from AbstractGWMojo and are honored by this goal when present:

  • gw.path: file, directory, glob, or other supported path expression to scan. When omitted, scanning uses the configured base directory. Example:
    
     mvn gw:act -Dgw.act=review -Dgw.path=src/main/java
     
  • gw.model: AI provider or model override passed to the act processor. Example:
    
     mvn gw:act -Dgw.act=review -Dgw.model=gpt-4.1
     
  • gw.instructions: additional instructions supplied to the act processor. Example:
    
     mvn gw:act -Dgw.act=review -Dgw.instructions="Focus on public API compatibility"
     
  • gw.excludes: comma-separated files, directories, or patterns to exclude from scanning. Example:
    
     mvn gw:act -Dgw.act=review -Dgw.excludes=target,*.class
     

Additional inherited Maven parameters

  • basedir: Maven module base directory. Maven supplies this automatically from ${basedir}; it normally does not need to be set explicitly. Plugin XML may override it, for example: <configuration><basedir>${project.basedir}</basedir></configuration>.
  • project: current Maven project, supplied by Maven from ${project}. It is used to discover project metadata and reactor modules. Typical plugin configuration leaves Maven's default in place: <configuration><project>${project}</project></configuration>.
  • session: current Maven session, supplied by Maven from ${session}. It provides the execution root, reactor state, and parallel-build settings. Typical plugin configuration leaves Maven's default in place: <configuration><session>${session}</session></configuration>.
  • settings: Maven settings, supplied by Maven from ${settings}. The goal uses it to resolve the configured server; for example, Maven injects <settings>${settings}</settings> when the parameter is not overridden.
  • reactorProjects: projects in the current reactor, supplied by Maven from ${reactorProjects}; for example, Maven injects <reactorProjects>${reactorProjects}</reactorProjects> for a multi-module build.
  • genai.serverId: optional Maven server identifier for provider credentials. Example: mvn gw:act -Dgenai.serverId=machai-ai -Dgw.act=review.
  • gw.config: optional properties-file path used when no server id is configured. Example: mvn gw:act -Dgw.config=.ghostwriter/config.properties -Dgw.act=review.
  • params: optional plugin configuration entries merged into workflow configuration. Example: <configuration><params><timeout>30</timeout></params></configuration>.

Configuration setting

gw.interactive is read from the effective Ghostwriter configuration rather than declared as a Maven @Parameter. It enables or disables prompting when an act value is missing; for example, set gw.interactive=false in the configuration file selected by gw.config.

If Javadoc text needs to mention the literal closing tag, write it as *&#47; so generated documentation does not terminate the comment early.

Since:
1.1.2
  • Constructor Details

    • ActMojo

      public ActMojo()
  • Method Details

    • updateMavenProjectLayout

      protected void updateMavenProjectLayout(org.machanism.machai.project.layout.MavenProjectLayout mavenProjectLayout, org.apache.maven.model.Model model)
      Updates Maven layout metadata for the matching reactor project.
      Overrides:
      updateMavenProjectLayout in class AbstractActMojo
      Parameters:
      mavenProjectLayout - layout to update
      model - model used to identify the reactor project
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Executes the configured Ghostwriter act.

      This method delegates act resolution and execution to the inherited AbstractActMojo.performAct(String) implementation. That implementation resolves a missing act from Maven properties or Ghostwriter configuration and, when enabled, interactive input.

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the act cannot be resolved or executed