org.universAAL.maven
Class MyMojoExecutorV15

Package class diagram package MyMojoExecutorV15
java.lang.Object
  extended by org.universAAL.maven.MyMojoExecutorV15

public final class MyMojoExecutorV15
extends Object

This class was extracted from mojo-executor-1.5 artifact and adopoted in uaal-maven-plugin for purpose of simultaneouse compliance with maven 2 and 3. Executes an arbitrary mojo using a fluent interface. This is meant to be executed within the context of a Maven 2 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
static class MyMojoExecutorV15.Element
          Element wrapper class for configuration elements.
static class MyMojoExecutorV15.ExecutionEnvironment
          Collects Maven execution information.
static class MyMojoExecutorV15.ExecutionEnvironmentM2
          Collects Maven 2 execution information.
static class MyMojoExecutorV15.ExecutionEnvironmentM3
          Collects Maven 3 execution information.
 
Method Summary
static String artifactId(String artifactId)
          Wraps the artifact id string in a more readable format.
static org.codehaus.plexus.util.xml.Xpp3Dom configuration(MyMojoExecutorV15.Element... elements)
          Builds the configuration for the goal using Elements.
static MyMojoExecutorV15.Element element(String name, MyMojoExecutorV15.Element... elements)
          Constructs the element containing child elements.
static MyMojoExecutorV15.Element element(String name, String value)
          Constructs the element with a textual body.
static void executeMojo(org.apache.maven.model.Plugin plugin, String goal, org.codehaus.plexus.util.xml.Xpp3Dom configuration, MyMojoExecutorV15.ExecutionEnvironment env)
          Entry point for executing a mojo.
static void executeMojoImpl(org.apache.maven.model.Plugin plugin, String goal, org.codehaus.plexus.util.xml.Xpp3Dom configuration, MyMojoExecutorV15.ExecutionEnvironmentM2 env)
          Entry point for executing a mojo
static void executeMojoImpl(org.apache.maven.model.Plugin plugin, String goal, org.codehaus.plexus.util.xml.Xpp3Dom configuration, MyMojoExecutorV15.ExecutionEnvironmentM3 env)
          Entry point for executing a mojo
static MyMojoExecutorV15.ExecutionEnvironment executionEnvironment(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.BuildPluginManager pluginManager)
          Constructs the MyMojoExecutorV15.ExecutionEnvironment instance fluently.
static MyMojoExecutorV15.ExecutionEnvironment executionEnvironment(org.apache.maven.project.MavenProject mavenProject, org.apache.maven.execution.MavenSession mavenSession, org.apache.maven.plugin.PluginManager pluginManager)
          Constructs the MyMojoExecutorV15.ExecutionEnvironment instance fluently.
static String goal(String goal)
          Wraps the goal string in a more readable format.
static String groupId(String groupId)
          Wraps the group id string in a more readable format.
static String name(String name)
          Wraps the element name string in a more readable format.
static org.apache.maven.model.Plugin plugin(String groupId, String artifactId)
          Defines the plugin without its version.
static org.apache.maven.model.Plugin plugin(String groupId, String artifactId, String version)
          Defines a plugin.
static String version(String version)
          Wraps the version string in a more readable format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

executeMojo

public static void executeMojo(org.apache.maven.model.Plugin plugin,
                               String goal,
                               org.codehaus.plexus.util.xml.Xpp3Dom configuration,
                               MyMojoExecutorV15.ExecutionEnvironment env)
                        throws org.apache.maven.plugin.MojoExecutionException
Entry point for executing a mojo.

Parameters:
plugin - The plugin to execute
goal - The goal to execute
configuration - The execution configuration
env - The execution environment
Throws:
org.apache.maven.plugin.MojoExecutionException - If there are any exceptions locating or executing the mojo

executeMojoImpl

public static void executeMojoImpl(org.apache.maven.model.Plugin plugin,
                                   String goal,
                                   org.codehaus.plexus.util.xml.Xpp3Dom configuration,
                                   MyMojoExecutorV15.ExecutionEnvironmentM2 env)
                            throws org.apache.maven.plugin.MojoExecutionException
Entry point for executing a mojo

Parameters:
plugin - The plugin to execute
goal - The goal to execute
configuration - The execution configuration
env - The execution environment
Throws:
org.apache.maven.plugin.MojoExecutionException - If there are any exceptions locating or executing the mojo

executeMojoImpl

public static void executeMojoImpl(org.apache.maven.model.Plugin plugin,
                                   String goal,
                                   org.codehaus.plexus.util.xml.Xpp3Dom configuration,
                                   MyMojoExecutorV15.ExecutionEnvironmentM3 env)
                            throws org.apache.maven.plugin.MojoExecutionException
Entry point for executing a mojo

Parameters:
plugin - The plugin to execute
goal - The goal to execute
configuration - The execution configuration
env - The execution environment
Throws:
org.apache.maven.plugin.MojoExecutionException - If there are any exceptions locating or executing the mojo

executionEnvironment

public static MyMojoExecutorV15.ExecutionEnvironment executionEnvironment(org.apache.maven.project.MavenProject mavenProject,
                                                                          org.apache.maven.execution.MavenSession mavenSession,
                                                                          org.apache.maven.plugin.PluginManager pluginManager)
Constructs the MyMojoExecutorV15.ExecutionEnvironment instance fluently.

Parameters:
mavenProject - The current Maven project
mavenSession - The current Maven session
pluginManager - The Maven plugin manager
Returns:
The execution environment

executionEnvironment

public static MyMojoExecutorV15.ExecutionEnvironment executionEnvironment(org.apache.maven.project.MavenProject mavenProject,
                                                                          org.apache.maven.execution.MavenSession mavenSession,
                                                                          org.apache.maven.plugin.BuildPluginManager pluginManager)
Constructs the MyMojoExecutorV15.ExecutionEnvironment instance fluently.

Parameters:
mavenProject - The current Maven project
mavenSession - The current Maven session
pluginManager - The Maven plugin manager
Returns:
The execution environment

configuration

public static org.codehaus.plexus.util.xml.Xpp3Dom configuration(MyMojoExecutorV15.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(String groupId,
                                                   String artifactId)
Defines the plugin without its version.

Parameters:
groupId - The group id
artifactId - The artifact id
Returns:
The plugin instance

plugin

public static org.apache.maven.model.Plugin plugin(String groupId,
                                                   String artifactId,
                                                   String version)
Defines a plugin.

Parameters:
groupId - The group id
artifactId - The artifact id
version - The plugin version
Returns:
The plugin instance

groupId

public static String groupId(String groupId)
Wraps the group id string in a more readable format.

Parameters:
groupId - The value
Returns:
The value

artifactId

public static String artifactId(String artifactId)
Wraps the artifact id string in a more readable format.

Parameters:
artifactId - The value
Returns:
The value

version

public static String version(String version)
Wraps the version string in a more readable format.

Parameters:
version - The value
Returns:
The value

goal

public static String goal(String goal)
Wraps the goal string in a more readable format.

Parameters:
goal - The value
Returns:
The value

name

public static String name(String name)
Wraps the element name string in a more readable format.

Parameters:
name - The value
Returns:
The value

element

public static MyMojoExecutorV15.Element element(String name,
                                                String value)
Constructs the element with a textual body.

Parameters:
name - The element name
value - The element text value
Returns:
The element object

element

public static MyMojoExecutorV15.Element element(String name,
                                                MyMojoExecutorV15.Element... elements)
Constructs the element containing child elements.

Parameters:
name - The element name
elements - The child elements
Returns:
The Element object


Copyright © 2014 universAAL Consortium. All Rights Reserved.