Class GWPerModuleMojo

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

@Mojo(name="gw-per-module", aggregator=false, threadSafe=true, requiresProject=true, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public class GWPerModuleMojo extends AbstractGWMojo
Maven goal that processes documents for the current Maven module.

Unlike an aggregator goal, this mojo runs once per module in the active Maven reactor. Maven determines module execution order using the standard reactor dependency graph, so submodules are processed according to their dependencies.

The processor's processModule hook is intentionally disabled for this goal. Maven's reactor, rather than recursive processor calls, invokes the goal for every selected module in dependency order.

The goal reuses the shared scanning and GenAI configuration implemented by AbstractGWMojo. It initializes a GuidanceProcessor rooted at the reactor execution directory while binding Maven-specific project layout metadata for each processed module.

Parameters

This goal does not declare additional parameters. It uses every configurable parameter declared by its superclass, AbstractGWMojo; Maven injects those inherited fields into this goal in exactly the same way as fields declared directly on a mojo. The inherited implementation also uses AbstractGWMojo.getConfiguration() to load provider settings and AbstractGWMojo.scanDocuments(GuidanceProcessor) to apply the scan configuration.

Inherited parameters

  • gw.model (model) - Provider/model identifier passed to the workflow. For example, mvn gw:gw-per-module -Dgw.model=openai:gpt-4o-mini selects a model.
  • ${basedir} (basedir) - Maven module base directory used as the default module location. Maven supplies this value automatically; it can be configured explicitly with <basedir>/path/to/module</basedir>.
  • gw.path (path) - Optional scan root override. If not provided, the goal scans the current module base directory. For example, mvn gw:gw-per-module -Dgw.path=src/site scans that directory.
  • gw.instructions / <instructions> (instructions) - Instruction locations consumed by the workflow. For example, mvn gw:gw-per-module -Dgw.instructions=src/site/guidance.md supplies an instruction file.
  • gw.excludes / <excludes> (excludes) - Exclude patterns or paths skipped during scanning. For example, mvn gw:gw-per-module -Dgw.excludes=target,build excludes both paths.
  • ${project} (project) - The current Maven project injected by Maven and used to obtain the module base directory. It is normally supplied automatically; a typical invocation that supplies this context is mvn gw:gw-per-module from a Maven module.
  • ${session} (session) - The current Maven session, supplied automatically and used to determine the reactor execution root. For example, mvn gw:gw-per-module -pl module-a -am supplies the session containing the selected reactor projects.
  • ${settings} (settings) - Maven settings used to resolve credentials from settings.xml; Maven supplies this value. For example, mvn gw:gw-per-module -Dgenai.serverId=ai-server uses the settings object to resolve the ai-server entry.
  • genai.serverId (serverId) - Maven server id used to resolve GenAI credentials. For example, mvn gw:gw-per-module -Dgenai.serverId=my-model-server selects that server entry.
  • params (params) - Additional key-value properties merged into the workflow configuration. For example, <params><endpoint>https://api.example.test</endpoint></params> adds an endpoint property.
  • gw.config (configFile) - Optional configuration file used when genai.serverId is not set. For example, mvn gw:gw-per-module -Dgw.config=machai.properties loads that file.

Usage examples

Process each module in the current reactor build

 mvn gw:gw-per-module
 

Restrict scanning to a module documentation directory

 mvn gw:gw-per-module -Dgw.path=src/site
 

Use instructions and excludes while processing reactor modules

 mvn gw:gw-per-module \
   -Dgw.instructions=src/site/guidance.md \
   -Dgw.excludes=target,node_modules
 

Resolve GenAI credentials from Maven settings

 mvn gw:gw-per-module -Dgenai.serverId=my-model-server
 

Plugin configuration

 <plugin>
   <groupId>org.machanism</groupId>
   <artifactId>gw-maven-plugin</artifactId>
   <version>...</version>
   <configuration>
     <model>openai:gpt-4.1</model>
     <path>${project.basedir}/src/site</path>
     <instructions>src/site/guidance.md</instructions>
   </configuration>
 </plugin>
 
  • Constructor Details

    • GWPerModuleMojo

      public GWPerModuleMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Executes the guidance processor for this reactor module.

      The method initializes usage tracking, resolves workflow configuration, and scans this module's base directory unless path overrides it. When a Maven project is present, it also registers class-inspection tools before scanning.

      Throws:
      org.apache.maven.plugin.MojoExecutionException - if configuration cannot be resolved or document processing is terminated or fails