Class GWMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
This goal is exposed as gw:gw. It is an aggregator goal that resolves
compile- and runtime-scoped dependencies, and 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.
Maven plugin parameters
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. Example plugin configuration:<project>${project}</project>. session- The current Maven session, injected from
${session}and used to resolve reactor projects, execution root, and parallel execution settings. Example plugin configuration:<session>${session}</session>. settings- Maven settings, injected from
${settings}, used for credentials resolution. Example plugin configuration:<settings>${settings}</settings>. serverId- Maven
settings.xmlserver id used to resolve GenAI credentials. Example:mvn gw:gw -Dgenai.serverId=my-ai-provideror<serverId>my-ai-provider</serverId>. params- Additional key-value configuration entries merged into the workflow.
Example plugin configuration:
<params><endpoint>https://api.example.test</endpoint></params>. configFile- Optional configuration file used when no
serverIdis configured. Example:mvn gw:gw -Dgw.config=machai.properties.
With the exception of the settings override declared by this goal,
the parameters above are inherited from AbstractGWMojo. The superclass
also supplies configuration creation and document-scanning support through
getConfiguration() and scanDocuments(GuidanceProcessor).
Parameters may be supplied either as Maven properties (for example,
-Dgw.model=openai:gpt-4o-mini) or in the plugin configuration.
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
mvn gw:gw -Dgw.config=machai.properties
To include the literal closing Javadoc delimiter in generated documentation,
escape it as */.
- Since:
- 1.1.2
-
Field Summary
Fields inherited from class org.machanism.machai.gw.maven.AbstractGWMojo
basedir, classFunctionTools, configFile, excludes, instructions, logger, model, params, path, project, serverId, SERVERID_PROP_NAME, session, settingsFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Executes thegw:gwgoal.private static org.apache.maven.project.MavenProjectresolveProjectByArtifactId(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.voidsetSettings(org.apache.maven.settings.Settings settings) Sets the Maven settings used to resolve configured GenAI credentials.private static StringtoCoord(org.apache.maven.project.MavenProject project) Formats a Maven project as a coordinate string used in duplicate-artifact diagnostics.Methods inherited from class org.machanism.machai.gw.maven.AbstractGWMojo
getConfiguration, scanDocuments, setBasedir, setConfigFile, setExcludes, setInstructions, setModel, setParams, setPath, setProject, setServerId, setSessionMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
GWMojo
public GWMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionExecutes thegw:gwgoal.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 toAbstractGWMojo.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 sessioneffectiveModel- effective model discovered from a project layout- Returns:
- the matching Maven project, or
nullwhen no unique match is available - Throws:
IllegalStateException- if multiple session projects share the same artifact id
-
toCoord
Formats a Maven project as a coordinate string used in duplicate-artifact diagnostics.- Parameters:
project- project to format- Returns:
- coordinate in
groupId:artifactId:version@basedirform
-
setSettings
@Parameter(readonly=true, defaultValue="${settings}") public void setSettings(org.apache.maven.settings.Settings settings) Sets the Maven settings used to resolve configured GenAI credentials.Maven injects this value from
${settings}. This override retains the inherited configuration behavior while exposing the parameter on thegw:gwgoal.- Overrides:
setSettingsin classAbstractGWMojo- Parameters:
settings- Maven settings supplied by the plugin runtime; may benullwhen Maven settings are unavailable
-