Class ActMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ActPerModuleMojo
This goal creates an ActProcessor, resolves configuration from Maven parameters, user properties 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. When a Maven project is present, inherited behavior from AbstractGWMojo
contributes common Ghostwriter parameters such as the base directory, model, path, instructions, excludes 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 predefined act name. Examples:mvn gw:act -Dgw.act="Add missing Javadocs" mvn gw:act -Dgw.act=reviewgw.acts: optional directory or path containing predefined act definitions. Examples:mvn gw:act -Dgw.acts=.ghostwriter/acts -Dgw.act=review mvn gw:act -Dgw.acts=src/gw/acts -Dgw.act=documentation
Common inherited 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. Example:mvn gw:act -Dgw.act=review -Dgw.path=src/main/javagw.model: AI model override. Example:mvn gw:act -Dgw.act=review -Dgw.model=gpt-4.1gw.instructions: additional instructions supplied to the act. Example:mvn gw:act -Dgw.act=review -Dgw.instructions="Focus on public API compatibility"gw.excludes: comma-separated exclusions. Example:mvn gw:act -Dgw.act=review -Dgw.excludes=target,*.classgw.interactive: enables or disables interactive prompting when configuration is incomplete. Example:mvn gw:act -Dgw.interactive=false -Dgw.act=review
If Javadoc text needs to mention the literal closing tag, write it as */ so generated documentation does
not terminate the comment early.
- Since:
- 1.1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringAction prompt text or predefined act name, supplied by thegw.actMaven property.private StringOptional directory or path containing predefined action definitions, supplied by thegw.actsMaven property.private static final Objectprotected org.codehaus.plexus.components.interactivity.PrompterInteractive prompt provider used to collect action input.Fields inherited from class org.machanism.machai.gw.maven.AbstractGWMojo
basedir, classFunctionTools, excludes, instructions, logger, model, path, project, reactorProjects, sessionFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyActPrompt(Configurator conf) Ensures an act prompt is stored in Maven user properties.voidconfigureAndScan(ActProcessor actProcessor) Resolves the effective act prompt and scans documents when an act is available.voidexecute()Executes the configured act goal.protected voidprocess(ActProcessor actProcessor) Applies runtime configuration to the supplied act processor and starts document scanning.Reads multi-line input from the interactivePrompter.protected voidscanDocuments(ActProcessor actProcessor) Scans the resolved project path with the configured act processor.private voidupdateMavenProjectLayout(org.machanism.machai.project.layout.MavenProjectLayout mavenProjectLayout, org.apache.maven.model.Model model) Methods inherited from class org.machanism.machai.gw.maven.AbstractGWMojo
getConfiguration, scanDocumentsMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
prompter
@Component protected org.codehaus.plexus.components.interactivity.Prompter prompterInteractive prompt provider used to collect action input. -
actPrompt
Action prompt text or predefined act name, supplied by thegw.actMaven property.When this parameter is not supplied, the goal first checks configured properties and then prompts the user interactively. Multi-line input is supported by ending each continued line with
GWConstants.MULTIPLE_LINES_BREAKER.mvn gw:act -Dgw.act=">Add missing Javadocs" mvn gw:act -Dgw.act=commit -
acts
Optional directory or path containing predefined action definitions, supplied by thegw.actsMaven property.When provided, this value overrides the default act lookup location used by
ActProcessor. It may point to a project-relative directory containing reusable act templates.mvn gw:act -Dgw.acts=acts -Dgw.act=site mvn gw:act -Dgw.acts=https://raw.githubusercontent.com/machanism-org/machai/refs/heads/main/acts -Dgw.act=site -
MONITOR
-
-
Constructor Details
-
ActMojo
public ActMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionExecutes the configured act goal.The method creates and configures an
ActProcessor, resolves Maven and Ghostwriter configuration values, applies inherited parameters such as path, model, instructions, excludes, and interactive mode, and then scans the selected documents. A zero-codeProcessTerminationExceptionis treated as normal termination.- Throws:
org.apache.maven.plugin.MojoExecutionException- if configuration, prompting, or file processing fails
-
updateMavenProjectLayout
private void updateMavenProjectLayout(org.machanism.machai.project.layout.MavenProjectLayout mavenProjectLayout, org.apache.maven.model.Model model) -
process
protected void process(ActProcessor actProcessor) throws org.apache.maven.plugin.MojoExecutionException Applies runtime configuration to the supplied act processor and starts document scanning.- Parameters:
actProcessor- the act processor to configure and execute- Throws:
org.apache.maven.plugin.MojoExecutionException- if scanning fails because of I/O or prompting errors
-
configureAndScan
public void configureAndScan(ActProcessor actProcessor) throws org.apache.maven.plugin.MojoExecutionException, IOException Resolves the effective act prompt and scans documents when an act is available.- Parameters:
actProcessor- the act processor that receives the resolved act- Throws:
org.apache.maven.plugin.MojoExecutionException- if interactive prompt collection failsIOException- if document scanning fails
-
applyActPrompt
protected void applyActPrompt(Configurator conf) throws org.apache.maven.plugin.MojoExecutionException Ensures an act prompt is stored in Maven user properties.- Parameters:
conf- configuration used to look up a non-interactive act value before prompting- Throws:
org.apache.maven.plugin.MojoExecutionException- if interactive prompt collection fails
-
scanDocuments
Scans the resolved project path with the configured act processor.- Parameters:
actProcessor- the processor used to scan documents- Throws:
IOException- if reading or writing project files fails
-
readText
public String readText(String prompt) throws org.codehaus.plexus.components.interactivity.PrompterException Reads multi-line input from the interactivePrompter.The user can enter multiple lines by ending a line with
GWConstants.MULTIPLE_LINES_BREAKER. Input collection stops when a line does not end with the breaker.- Parameters:
prompt- the initial prompt label displayed to the user- Returns:
- the collected text
- Throws:
org.codehaus.plexus.components.interactivity.PrompterException- if prompting fails
-