Package hudson.maven
Class MojoInfo
java.lang.Object
hudson.maven.MojoInfo
- Direct Known Subclasses:
MavenReportInfo
Information about Mojo to be executed. This object provides
convenient access to various mojo information, so that
MavenReporter
implementations are shielded to some extent from Maven internals.
For each mojo to be executed, this object is created and passed to
MavenReporter.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classInstance will be set tomojoto avoid NPE in plugins. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal org.codehaus.plexus.configuration.PlexusConfigurationConfiguration of the mojo for the current execution.final org.codehaus.plexus.component.configurator.expression.ExpressionEvaluatorObject that Maven uses to resolve variables like "${project}" to its corresponding object.final org.apache.maven.plugin.MojoDeprecated.as of 1.427 Maven3 can no longer provide this information, so plugins cannot rely on this value being present.final org.apache.maven.plugin.MojoExecutionObject from Maven that describes the Mojo to be executed.final PluginNamePluginName of the plugin that contains this mojo. -
Constructor Summary
ConstructorsConstructorDescriptionMojoInfo(org.apache.maven.execution.ExecutionEvent event, long startTime) MojoInfo(org.apache.maven.plugin.MojoExecution mojoExecution, org.apache.maven.plugin.Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration configuration, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator, long startTime) -
Method Summary
Modifier and TypeMethodDescription<T> TgetConfigurationValue(String configName, Class<T> type) Obtains the configuration value of the mojo.<T> TgetConfigurationValue(String configName, Class<T> type, T defaultValue) Obtains the configuration value of the mojo.getGoal()Gets the goal name of the mojo to be executed, such as "javadoc".long<T> TDeprecated.as of 1.427 See the discussion inmojovoidintercept(String fieldName, InvocationInterceptor interceptor) Deprecated.as of 1.427 See the discussion inmojobooleanReturns true if thisMojoInfowraps the mojo of the given ID tuple.
-
Field Details
-
mojoExecution
public final org.apache.maven.plugin.MojoExecution mojoExecutionObject from Maven that describes the Mojo to be executed. -
pluginName
PluginName of the plugin that contains this mojo. -
mojo
public final org.apache.maven.plugin.Mojo mojoDeprecated.as of 1.427 Maven3 can no longer provide this information, so plugins cannot rely on this value being present. For the time being we are setting a dummy value to avoid NPE. Useconfigurationto access configuration values, but otherwise the ability to inject values is lost and there's no viable alternative.Mojo object that carries out the actual execution. -
configuration
public final org.codehaus.plexus.configuration.PlexusConfiguration configurationConfiguration of the mojo for the current execution. This reflects the default values, as well as values configured from POM, including inherited values. -
expressionEvaluator
public final org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluatorObject that Maven uses to resolve variables like "${project}" to its corresponding object.
-
-
Constructor Details
-
MojoInfo
public MojoInfo(org.apache.maven.plugin.MojoExecution mojoExecution, org.apache.maven.plugin.Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration configuration, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator, long startTime) -
MojoInfo
public MojoInfo(org.apache.maven.execution.ExecutionEvent event, long startTime)
-
-
Method Details
-
getGoal
Gets the goal name of the mojo to be executed, such as "javadoc". This is local to the plugin name. -
getConfigurationValue
public <T> T getConfigurationValue(String configName, Class<T> type, T defaultValue) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException Obtains the configuration value of the mojo.- Parameters:
configName- The name of the child element in the<configuration>of mojo.type- The Java class of the configuration value. While every element can be read asString, often different types have a different conversion rules associated with it (for example,Filewould resolve relative path against POM base directory.)defaultValue- The default value to return in case the mojo doesn't have such configuration value- Returns:
- The configuration value either specified in POM, or inherited from parent POM, or default value if one is specified in mojo, or the defaultValue parameter if no such configuration value exists.
- Throws:
org.codehaus.plexus.component.configurator.ComponentConfigurationException- Not sure when exactly this is thrown, but it's probably when the configuration in POM is syntactically incorrect.
-
getConfigurationValue
@CheckForNull public <T> T getConfigurationValue(String configName, Class<T> type) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException Obtains the configuration value of the mojo.- Parameters:
configName- The name of the child element in the<configuration>of mojo.type- The Java class of the configuration value. While every element can be read asString, often different types have a different conversion rules associated with it (for example,Filewould resolve relative path against POM base directory.)- Returns:
- The configuration value either specified in POM, or inherited from parent POM, or default value if one is specified in mojo, or null if no such configuration value exists.
- Throws:
org.codehaus.plexus.component.configurator.ComponentConfigurationException- Not sure when exactly this is thrown, but it's probably when the configuration in POM is syntactically incorrect.
-
is
Returns true if thisMojoInfowraps the mojo of the given ID tuple. -
inject
Deprecated.as of 1.427 See the discussion inmojoInjects the specified value (designated by the specified field name) into the mojo, and returns its old value.- Throws:
NoSuchFieldException- if the mojo doesn't have any field of the given name.- Since:
- 1.232
-
intercept
public void intercept(String fieldName, InvocationInterceptor interceptor) throws NoSuchFieldException Deprecated.as of 1.427 See the discussion inmojoIntercept the invocation from the mojo to its injected component (designated by the given field name.)Often for a
MavenReporterto really figure out what's going on in a build, you'd like to intercept one of the components that Maven is injecting into the mojo, and inspect its parameter and return values.This mehod provides a way to do this. You specify the name of the field in the Mojo class that receives the injected component, then pass in
InvocationInterceptor, which will in turn be invoked for every invocation on that component.- Throws:
NoSuchFieldException- if the specified field is not found on the mojo class, or it is found but the type is not an interface.- Since:
- 1.232
-
getStartTime
public long getStartTime()
-