Package berlin.yuna.mavendeploy.plugin
Class PluginExecutor
- java.lang.Object
-
- berlin.yuna.mavendeploy.plugin.PluginExecutor
-
public class PluginExecutor extends java.lang.ObjectExecutes an arbitrary mojo using a fluent interface. This is meant to be executed within the context of a Maven mojo. Here is an execution that invokes the dependency plugin:executeMojo( plugin( groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.0") ), goal("copy-dependencies"), configuration( element(name("outputDirectory"), "${project.build.directory}/foo") ), executionEnvironment( project, session, pluginManager ) );
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPluginExecutor.AttributeAttribute wrapper classstatic classPluginExecutor.AttributesCollection of attributes wrapper classstatic classPluginExecutor.ElementElement wrapper class for configuration elementsstatic classPluginExecutor.ExecutionEnvironmentCollects Maven execution information
-
Constructor Summary
Constructors Constructor Description PluginExecutor()
-
Method Summary
Modifier and Type Method Description static java.lang.StringartifactId(java.lang.String artifactId)Wraps the artifact id string in a more readable formatstatic PluginExecutor.Attributeattribute(java.lang.String name, java.lang.String value)Constructs the attributestatic PluginExecutor.Attributesattributes(PluginExecutor.Attribute... attributes)Constructs the attributes wrapperstatic org.codehaus.plexus.util.xml.Xpp3Domconfiguration(PluginExecutor.Element... elements)Builds the configuration for the goal using Elementsstatic java.util.List<org.apache.maven.model.Dependency>dependencies(org.apache.maven.model.Dependency... dependencies)Creates a list of dependencies.static org.apache.maven.model.Dependencydependency(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)Defines a dependencystatic PluginExecutor.Elementelement(java.lang.String name, PluginExecutor.Attribute attribute, PluginExecutor.Element... elements)Constructs the element containing child elements and only attributestatic PluginExecutor.Elementelement(java.lang.String name, PluginExecutor.Attributes attributes, PluginExecutor.Element... elements)Constructs the element containing child elements and attributesstatic PluginExecutor.Elementelement(java.lang.String name, PluginExecutor.Element... elements)Constructs the element containing child elementsstatic PluginExecutor.Elementelement(java.lang.String name, java.lang.String value)Constructs the element with a textual bodystatic PluginExecutor.Elementelement(java.lang.String name, java.lang.String value, PluginExecutor.Attribute attribute)Constructs the element with a textual body and only attributestatic PluginExecutor.Elementelement(java.lang.String name, java.lang.String value, PluginExecutor.Attributes attributes)Constructs the element with a textual body and attributesstatic voidexecuteMojo(org.apache.maven.model.Plugin plugin, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom configuration, PluginExecutor.ExecutionEnvironment env)Entry point for executing a mojostatic PluginExecutor.ExecutionEnvironmentexecutionEnvironment(org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager)Constructs thePluginExecutor.ExecutionEnvironmentinstance fluentlystatic PluginExecutor.ExecutionEnvironmentexecutionEnvironment(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager)Constructs thePluginExecutor.ExecutionEnvironmentinstance fluentlystatic java.lang.Stringgoal(java.lang.String goal)Wraps the goal string in a more readable formatstatic java.lang.StringgroupId(java.lang.String groupId)Wraps the group id string in a more readable formatstatic java.lang.Stringname(java.lang.String name)Wraps the element name string in a more readable formatstatic org.apache.maven.model.Pluginplugin(java.lang.String groupId, java.lang.String artifactId)Defines the plugin without its version or dependencies.static org.apache.maven.model.Pluginplugin(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)Defines a plugin without dependencies.static voidsetLogger(Logger logger)static java.lang.Stringversion(java.lang.String version)Wraps the version string in a more readable format
-
-
-
Method Detail
-
executeMojo
public static void executeMojo(org.apache.maven.model.Plugin plugin, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom configuration, PluginExecutor.ExecutionEnvironment env) throws org.apache.maven.plugin.MojoExecutionExceptionEntry point for executing a mojo- Parameters:
plugin- The plugin to executegoal- The goal to executeconfiguration- The execution configurationenv- The execution environment- Throws:
org.apache.maven.plugin.MojoExecutionException- If there are any exceptions locating or executing the mojo
-
executionEnvironment
public static PluginExecutor.ExecutionEnvironment executionEnvironment(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager)
Constructs thePluginExecutor.ExecutionEnvironmentinstance fluently- Parameters:
mavenProject- The current Maven projectmavenSession- The current Maven sessionpluginManager- The Build plugin manager- Returns:
- The execution environment
- Throws:
java.lang.NullPointerException- if mavenProject, mavenSession or pluginManager are null
-
executionEnvironment
public static PluginExecutor.ExecutionEnvironment executionEnvironment(org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager)
Constructs thePluginExecutor.ExecutionEnvironmentinstance fluently- Parameters:
mavenSession- The current Maven sessionpluginManager- The Build plugin manager- Returns:
- The execution environment
- Throws:
java.lang.NullPointerException- if mavenProject, mavenSession or pluginManager are null
-
configuration
public static org.codehaus.plexus.util.xml.Xpp3Dom configuration(PluginExecutor.Element... elements)
Builds the configuration for the goal using Elements- Parameters:
elements- A list of elements for the configuration section- Returns:
- The elements transformed into the Maven-native XML format
-
plugin
public static org.apache.maven.model.Plugin plugin(java.lang.String groupId, java.lang.String artifactId)Defines the plugin without its version or dependencies.- Parameters:
groupId- The group idartifactId- The artifact id- Returns:
- The plugin instance
-
plugin
public static org.apache.maven.model.Plugin plugin(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)Defines a plugin without dependencies.- Parameters:
groupId- The group idartifactId- The artifact idversion- The plugin version- Returns:
- The plugin instance
-
groupId
public static java.lang.String groupId(java.lang.String groupId)
Wraps the group id string in a more readable format- Parameters:
groupId- The value- Returns:
- The value
-
artifactId
public static java.lang.String artifactId(java.lang.String artifactId)
Wraps the artifact id string in a more readable format- Parameters:
artifactId- The value- Returns:
- The value
-
version
public static java.lang.String version(java.lang.String version)
Wraps the version string in a more readable format- Parameters:
version- The value- Returns:
- The value
-
dependencies
public static java.util.List<org.apache.maven.model.Dependency> dependencies(org.apache.maven.model.Dependency... dependencies)
Creates a list of dependencies.- Parameters:
dependencies- the dependencies- Returns:
- A list of dependencies
-
dependency
public static org.apache.maven.model.Dependency dependency(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)Defines a dependency- Parameters:
groupId- The group idartifactId- The artifact idversion- The plugin version- Returns:
- the dependency instance
-
goal
public static java.lang.String goal(java.lang.String goal)
Wraps the goal string in a more readable format- Parameters:
goal- The value- Returns:
- The value
-
name
public static java.lang.String name(java.lang.String name)
Wraps the element name string in a more readable format- Parameters:
name- The value- Returns:
- The value
-
element
public static PluginExecutor.Element element(java.lang.String name, java.lang.String value)
Constructs the element with a textual body- Parameters:
name- The element namevalue- The element text value- Returns:
- The element object
-
element
public static PluginExecutor.Element element(java.lang.String name, java.lang.String value, PluginExecutor.Attributes attributes)
Constructs the element with a textual body and attributes- Parameters:
name- The element namevalue- The element text valueattributes- The element attributes- Returns:
- The element object
-
element
public static PluginExecutor.Element element(java.lang.String name, java.lang.String value, PluginExecutor.Attribute attribute)
Constructs the element with a textual body and only attribute- Parameters:
name- The element namevalue- The element text valueattribute- The element attribute- Returns:
- The element object
-
element
public static PluginExecutor.Element element(java.lang.String name, PluginExecutor.Element... elements)
Constructs the element containing child elements- Parameters:
name- The element nameelements- The child elements- Returns:
- The Element object
-
element
public static PluginExecutor.Element element(java.lang.String name, PluginExecutor.Attributes attributes, PluginExecutor.Element... elements)
Constructs the element containing child elements and attributes- Parameters:
name- The element nameattributes- The element attributeselements- The child elements- Returns:
- The Element object
-
element
public static PluginExecutor.Element element(java.lang.String name, PluginExecutor.Attribute attribute, PluginExecutor.Element... elements)
Constructs the element containing child elements and only attribute- Parameters:
name- The element nameattribute- The element attributeelements- The child elements- Returns:
- The Element object
-
attributes
public static PluginExecutor.Attributes attributes(PluginExecutor.Attribute... attributes)
Constructs the attributes wrapper- Parameters:
attributes- The attributes- Returns:
- The Attributes object
-
attribute
public static PluginExecutor.Attribute attribute(java.lang.String name, java.lang.String value)
Constructs the attribute- Parameters:
name- The attribute namevalue- The attribute value- Returns:
- The Attribute object
-
setLogger
public static void setLogger(Logger logger)
-
-