Class GWMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.machanism.machai.gw.maven.AbstractGWMojo
org.machanism.machai.gw.maven.GWMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="gw", threadSafe=true, aggregator=true, requiresProject=false, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public class GWMojo extends AbstractGWMojo
Maven goal that scans project files for Ghostwriter guidance comments and executes the configured AI-assisted processing workflow.

This goal is exposed as gw:gw. It can run in a normal Maven project, across a multi-module build, or without a pom.xml. When Maven parallel execution is enabled, module traversal is coordinated by gw rather than by the Maven reactor. Sub-modules are processed before their parent modules, matching the reverse-order behavior of the Ghostwriter CLI and the gw:act goal.

Parameters inherited from AbstractGWMojo

model
Provider/model identifier used by the workflow. Example: mvn gw:gw -Dgw.model=openai:gpt-4o-mini.
basedir
Maven module base directory, injected from ${basedir} by default. Example plugin configuration: <basedir>${project.basedir}</basedir>.
path
Optional scan root override. Example: mvn gw:gw -Dgw.path=src/main/java.
instructions
Additional workflow instructions or instruction file locations. Example: mvn gw:gw -Dgw.instructions=docs/gw-instructions.md.
excludes
Path or glob-like patterns skipped during scanning. Example plugin configuration: <excludes><exclude>target/**</exclude></excludes>.
project
The current Maven project, injected from ${project} when a project is present.
session
The current Maven session, injected from ${session} and used to resolve reactor projects, execution root, and parallel execution settings.
settings
Maven settings, injected from ${settings}, used for credentials resolution.
serverId
Maven settings.xml server id used to resolve GenAI credentials. Example: mvn gw:gw -Dgenai.serverId=my-ai-provider.
reactorProjects
Read-only list of reactor projects injected from ${reactorProjects} for multi-module builds.

Usage examples


 mvn gw:gw
 mvn -T 4 gw:gw
 mvn gw:gw -Dgw.path=src/test/java -Dgw.instructions=docs/guidance.md
 mvn gw:gw -Dgenai.serverId=my-ai-provider
 

To include the literal closing Javadoc delimiter in generated documentation, escape it as *&#47;.

Since:
1.1.2
  • Constructor Details

    • GWMojo

      public GWMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Executes the gw:gw goal.

      The method builds the effective processor configuration, creates a GuidanceProcessor, resolves Maven module layout information when available, configures non-recursive and parallel execution behavior, and then delegates scanning to AbstractGWMojo.scanDocuments(GuidanceProcessor).

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if configuration, scanning, or processing fails
    • resolveProjectByArtifactId

      private static org.apache.maven.project.MavenProject resolveProjectByArtifactId(List<org.apache.maven.project.MavenProject> allProjects, org.apache.maven.model.Model effectiveModel)
      Resolves the Maven project from the current session that matches the artifact id of the supplied effective model.
      Parameters:
      allProjects - all Maven projects available in the session
      effectiveModel - effective model discovered from a project layout
      Returns:
      the matching Maven project, or null when no unique match is available
      Throws:
      IllegalStateException - if multiple session projects share the same artifact id
    • toCoord

      private static String toCoord(org.apache.maven.project.MavenProject project)
      Formats a Maven project as a coordinate string used in duplicate-artifact diagnostics.
      Parameters:
      project - project to format
      Returns:
      coordinate in groupId:artifactId:version@basedir form