public class MojoInfo extends Object
MavenReporter
implementations are shielded to some extent from Maven internals.
For each mojo to be executed, this object is created and passed to
MavenReporter.
MavenReporter,
MavenReportInfo| Modifier and Type | Class and Description |
|---|---|
static class |
MojoInfo.Maven3ProvidesNoAccessToMojo
Instance will be set to
mojo to avoid NPE in plugins. |
| Modifier and Type | Field and Description |
|---|---|
org.codehaus.plexus.configuration.PlexusConfiguration |
configuration
Configuration of the mojo for the current execution.
|
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator |
expressionEvaluator
Object that Maven uses to resolve variables like "${project}" to its
corresponding object.
|
org.apache.maven.plugin.Mojo |
mojo
Deprecated.
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. Use
configuration to access
configuration values, but otherwise the ability to inject values is lost and there's no viable
alternative. |
org.apache.maven.plugin.MojoExecution |
mojoExecution
Object from Maven that describes the Mojo to be executed.
|
PluginName |
pluginName
PluginName of the plugin that contains this mojo.
|
| Constructor and Description |
|---|
MojoInfo(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) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
getConfigurationValue(String configName,
Class<T> type)
Obtains the configuration value of the mojo.
|
<T> T |
getConfigurationValue(String configName,
Class<T> type,
T defaultValue)
Obtains the configuration value of the mojo.
|
String |
getGoal()
Gets the goal name of the mojo to be executed,
such as "javadoc".
|
long |
getStartTime() |
<T> T |
inject(String name,
T value)
Deprecated.
as of 1.427
See the discussion in
mojo |
void |
intercept(String fieldName,
hudson.util.InvocationInterceptor interceptor)
Deprecated.
as of 1.427
See the discussion in
mojo |
boolean |
is(String groupId,
String artifactId,
String mojoName)
Returns true if this
MojoInfo wraps the mojo of the given ID tuple. |
public final org.apache.maven.plugin.MojoExecution mojoExecution
public final PluginName pluginName
public final org.apache.maven.plugin.Mojo mojo
configuration to access
configuration values, but otherwise the ability to inject values is lost and there's no viable
alternative.public final org.codehaus.plexus.configuration.PlexusConfiguration configuration
public final org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator
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)
public MojoInfo(org.apache.maven.execution.ExecutionEvent event,
long startTime)
public String getGoal()
public <T> T getConfigurationValue(String configName, Class<T> type, T defaultValue) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException
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 as String, often different types have a different
conversion rules associated with it (for example, File would
resolve relative path against POM base directory.)defaultValue - The default value to return in case the mojo doesn't have such
configuration valueorg.codehaus.plexus.component.configurator.ComponentConfigurationException - Not sure when exactly this is thrown, but it's probably when
the configuration in POM is syntactically incorrect.@CheckForNull public <T> T getConfigurationValue(String configName, Class<T> type) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException
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 as String, often different types have a different
conversion rules associated with it (for example, File would
resolve relative path against POM base directory.)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.public boolean is(String groupId, String artifactId, String mojoName)
MojoInfo wraps the mojo of the given ID tuple.public <T> T inject(String name, T value) throws NoSuchFieldException
mojoNoSuchFieldException - if the mojo doesn't have any field of the given name.public void intercept(String fieldName, hudson.util.InvocationInterceptor interceptor) throws NoSuchFieldException
mojo
Often for a MavenReporter to 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.
NoSuchFieldException - if the specified field is not found on the mojo class, or it is found but the type is not an interface.public long getStartTime()
Copyright © 2016–2017. All rights reserved.