public abstract class AbstractMojo extends Object implements Mojo, ContextEnabled
Mojo
except for
the execute method.Mojo
annotation with the name of the goal:
@Mojo( name = "<goal-name>" )
There are also a number of attributes which can be used to control how and when the
Mojo
is executed:
Descriptor Element | Annotation | Required? | Notes |
---|---|---|---|
goal | name = "<goal-name>" | Yes | The name for the Mojo that users will reference from the command line to execute the Mojo directly, or inside a POM in order to provide Mojo-specific configuration. |
implementation | none (detected) | Yes | The Mojo's fully-qualified class name (or script path in the case of non-Java Mojos). |
language | none (detected) | No. Default: java |
The implementation language for this Mojo (Java, beanshell, etc.). |
configurator | configurator = "<role-hint>" | No | The configurator type to use when injecting parameter values into this Mojo. The value is normally
deduced from the Mojo's implementation language, but can be specified to allow a custom
ComponentConfigurator implementation to be used.
NOTE: This will only be used in very special cases, using a highly controlled vocabulary of possible values. (Elements like this are why it's a good idea to use the descriptor tools.) |
phase | defaultPhase = LifecyclePhase.<phase> | No | Binds this Mojo to a particular phase of the standard build lifecycle, if specified.
NOTE: This is only required if this Mojo is to participate in the standard build process. |
execute | @Execute ( phase=LifecyclePhase.<phase>, goal= "<goal-name>", lifecycle="<lifecycle-id>" ) | No | When this goal is invoked, it will first invoke a parallel lifecycle, ending at the given phase.
If a goal is provided instead of a phase, that goal will be executed in isolation.
The execution of either will not affect the current project, but instead make available the
${executedProject} expression if required. An alternate lifecycle can also be provided:
for more information see the documentation on the
build lifecycle.
|
requiresDependencyResolution | requiresDependencyResolution = ResolutionScope.<scope> | No | Flags this Mojo as requiring the dependencies in the specified scope (or an implied scope) to be
resolved before it can execute.
NOTE: Currently supports compile, runtime, and test scopes. |
description | none (detected) | No | The description of this Mojo's functionality. Using the toolset, this will be the class-level
Javadoc description provided. NOTE: While this is not a required part of the Mojo specification, it SHOULD be provided to enable future tool support for browsing, etc. and for clarity. |
parameters | N/A | No | Specifications for the parameters which this Mojo uses will be provided in parameter sub-elements
in this section.
NOTE: Parameters are discussed in more detail below. |
This is only a small set of all the options. A complete list can be found at Maven Plugin Tool for Annotations.
Constructor and Description |
---|
AbstractMojo() |
Modifier and Type | Method and Description |
---|---|
Log |
getLog()
Returns the logger that has been injected into this mojo.
|
Map |
getPluginContext() |
void |
setLog(Log log)
Inject a standard
Maven logging mechanism to allow this Mojo to communicate events
and feedback to the user. |
void |
setPluginContext(Map pluginContext)
Set a new shared context
Map to a mojo before executing it. |
public void setLog(Log log)
Mojo
Maven
logging mechanism to allow this Mojo
to communicate events
and feedback to the user.public Log getLog()
Returns the logger that has been injected into this mojo. If no logger has been setup yet, a
SystemStreamLog
logger will be created and returned.
getLog
in interface Mojo
"debug"
,
"info"
, "warn"
, and "error"
. This logger is the accepted means to display
information to the user.Mojo.getLog()
public Map getPluginContext()
getPluginContext
in interface ContextEnabled
Map
stored in the plugin container's context.public void setPluginContext(Map pluginContext)
ContextEnabled
Map
to a mojo before executing it.setPluginContext
in interface ContextEnabled
pluginContext
- a new Map
Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.