Class AbstractGWMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractActMojo,GWMojo,GWPerModuleMojo
GuidanceProcessor.
The mojo resolves Maven project and session context, scanner inputs, and
GenAI provider credentials before executing a scan. It loads configuration
from a file, optionally merges a Maven <server> configuration, and
finally applies explicit plugin parameters. Concrete goals create the
processor and invoke scanDocuments(GuidanceProcessor).
Maven parameters
model: provider/model identifier; for example,-Dgenai.model=openai:gpt-4o-mini.basedir: module directory, automatically injected from${basedir}.path: file, directory, glob, or pattern to scan; for example,-Dgenai.path=src/main/java.instructions: extra workflow instructions; for example,-Dgenai.instructions="Keep public APIs compatible".excludes: skipped paths or patterns; for example,-Dgenai.excludes=target,build.project: current project, injected from${project}.session: current session, injected from${session}.settings: Maven settings, injected from${settings}.serverId: credentials server id; for example,-Dgenai.serverId=machai-ai.params: configuration map; for example,<params><endpoint>https://api.example.test</endpoint></params>.configFile: configuration file; for example,-Dgenai.config=machai.properties.
Literal closing Javadoc delimiters in documentation must be written as
*/.
- Since:
- 1.1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileMaven module base directory injected from the${basedir}expression.protected ClassFunctionalToolsTool set exposed to the processor for class-related project introspection when Maven is executing with a project.protected FileOptional configuration file loaded before Maven server and explicit parameter values are applied.protected String[]Paths or patterns skipped during scanning.protected StringAdditional instructions passed to the workflow before scanning.(package private) static final org.slf4j.LoggerLogger shared by Maven goal implementations in this package.protected StringProvider/model identifier to pass to the workflow, optionally supplied with the "gw.model" Maven property.Additional key-value configuration entries merged into the processor configuration.protected StringOptional scan root override.protected org.apache.maven.project.MavenProjectCurrent Maven project, used to determine the module base directory and whether project-aware tools should be registered.protected StringMavenserverid used to resolve GenAI credentials and custom server configuration.static final StringMaven property name for the target GenAI server identifier.protected org.apache.maven.execution.MavenSessionCurrent Maven session, used to obtain execution-root and request context.protected org.apache.maven.settings.SettingsMaven settings used to resolve credentials and custom configuration fromsettings.xml.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected PropertiesConfiguratorBuilds the processor configuration.protected voidscanDocuments(GuidanceProcessor processor) Configures and executes document scanning for the current project context.voidsetBasedir(File basedir) Sets the Maven module base directory.voidsetConfigFile(File configFile) Sets the optional configuration file to load.voidsetExcludes(String[] excludes) Sets paths or patterns excluded from document scanning.voidsetInstructions(String instructions) Sets additional instructions for the workflow.voidSets the provider or model identifier passed to the workflow.voidSets explicit key-value configuration entries.voidSets the optional file, directory, glob, or pattern to scan.voidsetProject(org.apache.maven.project.MavenProject project) Sets the current Maven project.voidsetServerId(String serverId) Sets the Maven server id used to obtain GenAI credentials.voidsetSession(org.apache.maven.execution.MavenSession session) Sets the Maven session that supplies the execution root and request context.voidsetSettings(org.apache.maven.settings.Settings settings) Sets Maven settings used to look up the configured GenAI server.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute
-
Field Details
-
logger
static final org.slf4j.Logger loggerLogger shared by Maven goal implementations in this package. It records configuration and scanning lifecycle events. -
SERVERID_PROP_NAME
Maven property name for the target GenAI server identifier. Supply its value with-Dgenai.serverId=server-id.- See Also:
-
model
Provider/model identifier to pass to the workflow, optionally supplied with the "gw.model" Maven property. -
basedir
Maven module base directory injected from the${basedir}expression. -
path
Optional scan root override. When absent, scanning starts at the Maven execution root directory. -
instructions
Additional instructions passed to the workflow before scanning. -
excludes
Paths or patterns skipped during scanning. -
project
protected org.apache.maven.project.MavenProject projectCurrent Maven project, used to determine the module base directory and whether project-aware tools should be registered. -
session
protected org.apache.maven.execution.MavenSession sessionCurrent Maven session, used to obtain execution-root and request context. -
settings
protected org.apache.maven.settings.Settings settingsMaven settings used to resolve credentials and custom configuration fromsettings.xml. -
serverId
Mavenserverid used to resolve GenAI credentials and custom server configuration. -
params
Additional key-value configuration entries merged into the processor configuration.For example, plugin XML can provide
<params><timeout>30</timeout></params>. -
configFile
Optional configuration file loaded before Maven server and explicit parameter values are applied. For example,-Dfollowed byGWConstants.CONFIG_PROP_NAMEfollowed by=machai.propertiesselects a custom configuration file. -
classFunctionTools
Tool set exposed to the processor for class-related project introspection when Maven is executing with a project.
-
-
Constructor Details
-
AbstractGWMojo
protected AbstractGWMojo()Creates the base mojo instance.
-
-
Method Details
-
getConfiguration
protected PropertiesConfigurator getConfiguration() throws org.apache.maven.plugin.MojoExecutionExceptionBuilds the processor configuration.Configuration is loaded first from the explicitly configured file, or from the default workflow configuration file when no file is supplied. Values from the selected Maven server and then
paramsare applied in that order, so explicit plugin parameters take precedence over earlier sources.If a Maven server id is configured, this method reads the matching server entry from
settings.xmland copies its username, password, and any custom XML configuration values into the returned configurator.- Returns:
- a configurator containing the resolved workflow properties
- Throws:
org.apache.maven.plugin.MojoExecutionException- if a specified configuration file cannot be loaded, Maven settings are unavailable for a configured server id, or that server cannot be found
-
scanDocuments
protected void scanDocuments(GuidanceProcessor processor) throws org.apache.maven.plugin.MojoExecutionException Configures and executes document scanning for the current project context.This method applies configured excludes, optional instructions, input logging, and scan directory selection before invoking
AIFileProcessor.scanDocuments(File, String). When a Maven project is present in the request, class-related helper tools are also registered with the processor.- Parameters:
processor- the non-null processor to configure and execute- Throws:
org.apache.maven.plugin.MojoExecutionException- if project scanning or document processing fails; the original failure is retained as the exception cause
-
setSettings
@Parameter(readonly=true, defaultValue="${settings}") public void setSettings(org.apache.maven.settings.Settings settings) Sets Maven settings used to look up the configured GenAI server.- Parameters:
settings- Maven settings injected by the plugin runtime; may benulloutside normal Maven execution
-
setSession
@Parameter(defaultValue="${session}", readonly=true, required=true) public void setSession(org.apache.maven.execution.MavenSession session) Sets the Maven session that supplies the execution root and request context.- Parameters:
session- Maven session injected by the plugin runtime
-
setModel
Sets the provider or model identifier passed to the workflow.- Parameters:
model- provider/model identifier, ornullto use configured defaults
-
setBasedir
Sets the Maven module base directory.- Parameters:
basedir- module base directory injected by Maven
-
setPath
Sets the optional file, directory, glob, or pattern to scan.- Parameters:
path- scan input, ornullto scan from the execution root
-
setInstructions
@Parameter(property="gw.instructions", name="instructions") public void setInstructions(String instructions) Sets additional instructions for the workflow.- Parameters:
instructions- workflow instructions, ornullwhen none are provided
-
setExcludes
Sets paths or patterns excluded from document scanning.- Parameters:
excludes- excluded paths or patterns, ornullfor no explicit exclusions
-
setProject
@Parameter(readonly=true, defaultValue="${project}") public void setProject(org.apache.maven.project.MavenProject project) Sets the current Maven project.- Parameters:
project- Maven project injected by the plugin runtime
-
setServerId
Sets the Maven server id used to obtain GenAI credentials.- Parameters:
serverId- id of a<server>entry insettings.xml, ornullto rely on file-based configuration
-
setParams
Sets explicit key-value configuration entries. These values override values loaded from the configuration file and Maven server configuration.- Parameters:
params- configuration entries, ornullwhen none are supplied
-
setConfigFile
Sets the optional configuration file to load.- Parameters:
configFile- configuration file, ornullto use the default workflow configuration file when available
-