Package org.machanism.machai.mcp.maven
Class AbstractMCPServerMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.machanism.machai.mcp.maven.AbstractMCPServerMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
HttpStatelessServerMojo,HttpStreamableMcpServerMojo
public abstract class AbstractMCPServerMojo
extends org.apache.maven.plugin.AbstractMojo
Abstract base class for MCP server Maven plugin Mojos.
Provides common configuration and utility methods for managing environment variables and credentials required by the MCP server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileThe Maven module base directory.Map of environment variables for MCP server.protected intThe port on which the MCP server will run.protected org.apache.maven.project.MavenProjectThe current Maven project.private StringMavenserverid used to resolve GenAI credentials.private org.apache.maven.settings.SettingsMaven settings used to resolve credentials fromsettings.xml.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidApplies environment parameters and credentials to the system properties.protected PropertiesConfiguratorBuilds the processor configuration.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
-
basedir
The Maven module base directory. -
project
@Parameter(readonly=true, defaultValue="${project}") protected org.apache.maven.project.MavenProject projectThe current Maven project. -
port
@Parameter(property="mcp.port", required=true) protected int portThe port on which the MCP server will run. -
params
Map of environment variables for MCP server. -
serverId
Mavenserverid used to resolve GenAI credentials. -
settings
@Parameter(readonly=true, defaultValue="${settings}") private org.apache.maven.settings.Settings settingsMaven settings used to resolve credentials fromsettings.xml.
-
-
Constructor Details
-
AbstractMCPServerMojo
public AbstractMCPServerMojo()Constructs a newAbstractMCPServerMojo.
-
-
Method Details
-
applyParameters
public void applyParameters() throws org.apache.maven.plugin.MojoExecutionExceptionApplies environment parameters and credentials to the system properties.Sets each parameter in
paramsas a system property if not already set. IfserverIdis specified, resolves credentials from Mavensettings.xmland sets them as system properties. Also applies any custom configuration properties found in the server configuration.- Throws:
org.apache.maven.plugin.MojoExecutionException- if the specified server ID is not found in Maven settings
-
getConfiguration
protected PropertiesConfigurator getConfiguration() throws org.apache.maven.plugin.MojoExecutionExceptionBuilds the processor configuration.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:
- configuration for downstream workflow execution
- Throws:
org.apache.maven.plugin.MojoExecutionException- if Maven settings are unavailable or the configured server cannot be found
-