Package org.machanism.machai.gw.maven


package org.machanism.machai.gw.maven
Provides the Maven-plugin integration layer for Machai Ghostwriter workflows.

The package exposes Maven goals that configure Ghostwriter from the active Maven execution and then apply either guidance-driven processing or an explicit act to project files. It bridges Maven's project, reactor, session, settings, and dependency-resolution facilities to Ghostwriter processors, enabling project-aware workflows while retaining support for aggregator execution outside a pom.xml-based build.

Goal architecture

AbstractGWMojo supplies the common integration behavior. It accepts Maven context and configuration parameters, builds the effective Ghostwriter configuration from properties, plugin parameters, and an optional Maven settings.xml server, applies scan paths, instructions, and exclusions, and reports usage. When Maven is executing a project, it also registers the class-introspection tools supplied by the related org.machanism.machai.gw.maven.tools package.

Configuration is assembled from the selected Ghostwriter properties file, an optional Maven settings.xml server entry, and plugin params; later sources override earlier values. The mojos then create the appropriate processor, attach Maven-aware project-layout and class-introspection support when a project is available, and delegate file traversal and workflow execution to the processor layer. This separation keeps Maven parameter binding and reactor integration in this package while the processor package owns guidance and act execution.

GWMojo and GWPerModuleMojo create a GuidanceProcessor that locates files containing Ghostwriter guidance comments and executes their workflows. AbstractActMojo extends the shared infrastructure for an explicit Ghostwriter act: it resolves an act name or inline prompt, can collect multi-line interactive input, locates reusable act definitions, and delegates processing to an ActProcessor. ActMojo implements the aggregator act goal; AbstractActPerModuleMojo provides the reactor-aware behavior used by ActPerModuleMojo.

Public API relationships

The concrete goal classes are intentionally thin Maven entry points: GWMojo and GWPerModuleMojo run guidance discovery, while ActMojo and ActPerModuleMojo run a selected act. Their shared base classes centralize Maven parameter binding and processor setup so that aggregator and per-module variants apply the same provider configuration, exclusions, instructions, and project-aware tools. The accompanying org.machanism.machai.gw.maven.tools package supplies the class-information functions registered for executions that have Maven project context.

Execution models

gw:gw and gw:act
Thread-safe aggregator goals that can traverse a project tree, including a multi-module tree, and do not require a pom.xml. Ghostwriter performs traversal in reverse order, processing child modules before parent modules. During a Maven parallel build, Ghostwriter coordinates that traversal.
gw:gw-per-module and gw:act-per-module
Thread-safe, non-aggregator goals invoked by Maven for every selected reactor module. They suppress nested module traversal because Maven supplies module scheduling in its standard dependency order.

Configuration

All goals support the common gw.model, gw.path, gw.instructions, gw.excludes, genai.serverId, and gw.config properties, together with additional plugin configuration entries through params. Act goals additionally accept gw.act and gw.acts. A genai.serverId value selects a matching Maven settings.xml server, whose credentials and custom XML configuration become processor settings. In the absence of a server identifier, Ghostwriter loads its default or explicitly selected properties file. Concrete mojo classes document the complete parameter and plugin-XML forms.

Usage examples


 # Scan files containing Ghostwriter guidance comments.
 mvn gw:gw -Dgw.path=src/main/java -Dgw.instructions=docs/guidance.md

 # Execute either an inline action or a named act definition.
 mvn gw:act -Dgw.act="Add missing public API Javadocs"
 mvn -T 4 gw:act -Dgw.act=review

 # Let Maven invoke a non-aggregator goal for selected reactor modules.
 mvn gw:gw-per-module -Dgw.path=src/main/java
 mvn gw:act-per-module -Dgw.act=review

 # Resolve provider credentials from a Maven settings server.
 mvn gw:gw -Dgenai.serverId=my-ai-provider
 
See Also:
  • Classes
    Class
    Description
    Abstract base Maven mojo for goals that execute Ghostwriter acts.
    Base Maven mojo for acts that execute once for every eligible module in a Maven reactor.
    Base class for Maven goals that scan project files for guidance comments and delegate processing to a GuidanceProcessor.
    Maven goal that executes a Ghostwriter act against project files.
    Maven goal gw:act-per-module that runs an action for an eligible project in Maven's standard reactor build context.
    Maven goal that scans project files for Ghostwriter guidance comments and executes the configured AI-assisted processing workflow.
    Maven goal that processes documents for the current Maven module.