org.apache.geronimo.genesis
Class MojoSupport

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.geronimo.genesis.MojoSupport
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Direct Known Subclasses:
AntMojoSupport

public abstract class MojoSupport
extends org.apache.maven.plugin.AbstractMojo
implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable

Support for Mojo implementations.

Version:
$Rev: 470159 $ $Date: 2006-11-01 17:19:16 -0800 (Wed, 01 Nov 2006) $

Field Summary
protected  org.codehaus.plexus.PlexusContainer container
           
protected  org.apache.maven.plugin.logging.Log log
          Instance logger.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
protected MojoSupport()
           
 
Method Summary
 void contextualize(org.codehaus.plexus.context.Context context)
           
protected  org.apache.maven.artifact.Artifact createArtifact(ArtifactItem item)
          Create a new artifact.
protected  void doExecute()
          Sub-class should override to provide custom execution logic.
 void execute()
          Main Mojo execution hook.
protected  org.apache.maven.artifact.Artifact getArtifact(ArtifactItem item)
          Resolves the Artifact from the remote repository if nessessary.
protected  org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
          Get the artifact factory.
protected  org.apache.maven.artifact.repository.ArtifactRepository getArtifactRepository()
          Get the artifact repository.
protected  org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
          Get the artifact resolver.
protected  org.apache.maven.project.MavenProject getProject()
          Get the Maven project.
protected  Set getProjectArtifacts()
           
protected  Set getProjectArtifacts(boolean resolve)
           
protected  Set getProjectArtifacts(org.apache.maven.project.MavenProject project, boolean resolve)
           
protected  void init()
          Initializes logging.
protected  org.apache.maven.artifact.Artifact resolveArtifact(org.apache.maven.artifact.Artifact artifact)
          Resolves the Artifact from the remote repository non-transitivly.
protected  org.apache.maven.artifact.Artifact resolveArtifact(org.apache.maven.artifact.Artifact artifact, boolean transitive)
          Resolves the Artifact from the remote repository if nessessary.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected org.codehaus.plexus.PlexusContainer container

log

protected org.apache.maven.plugin.logging.Log log
Instance logger. This is initialized to the value of AbstractMojo.getLog() on execution.

Constructor Detail

MojoSupport

protected MojoSupport()
Method Detail

init

protected void init()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Initializes logging. Called by execute().

Throws:
org.apache.maven.plugin.MojoExecutionException - Initialization failed
org.apache.maven.plugin.MojoFailureException - Initialization failed

contextualize

public void contextualize(org.codehaus.plexus.context.Context context)
                   throws org.codehaus.plexus.context.ContextException
Specified by:
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
Throws:
org.codehaus.plexus.context.ContextException

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Main Mojo execution hook. Sub-class should use doExecute() instead.

Specified by:
execute in interface org.apache.maven.plugin.Mojo
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

doExecute

protected void doExecute()
                  throws Exception
Sub-class should override to provide custom execution logic.

Throws:
Exception - Execution failed

getProject

protected org.apache.maven.project.MavenProject getProject()
Get the Maven project.

Sub-class must overridde to provide access.

Returns:
The maven project; never null

getArtifactRepository

protected org.apache.maven.artifact.repository.ArtifactRepository getArtifactRepository()
Get the artifact repository.

Sub-class must overridde to provide access.

Returns:
An artifact repository; never null

getArtifactFactory

protected final org.apache.maven.artifact.factory.ArtifactFactory getArtifactFactory()
Get the artifact factory.

Returns:
An artifact factory; never null

getArtifactResolver

protected final org.apache.maven.artifact.resolver.ArtifactResolver getArtifactResolver()
Get the artifact resolver.

Returns:
An artifact resolver; never null

createArtifact

protected org.apache.maven.artifact.Artifact createArtifact(ArtifactItem item)
                                                     throws org.apache.maven.plugin.MojoExecutionException
Create a new artifact. If no version is specified, it will be retrieved from the dependency list or from the DependencyManagement section of the pom.

Parameters:
item - The item to create an artifact for
Returns:
An unresolved artifact for the given item.
Throws:
org.apache.maven.plugin.MojoExecutionException - Failed to create artifact

getArtifact

protected org.apache.maven.artifact.Artifact getArtifact(ArtifactItem item)
                                                  throws org.apache.maven.plugin.MojoExecutionException
Resolves the Artifact from the remote repository if nessessary. If no version is specified, it will be retrieved from the dependency list or from the DependencyManagement section of the pom.

Parameters:
item - The item to create an artifact for; must not be null
Returns:
The artifact for the given item
Throws:
org.apache.maven.plugin.MojoExecutionException - Failed to create artifact

resolveArtifact

protected org.apache.maven.artifact.Artifact resolveArtifact(org.apache.maven.artifact.Artifact artifact,
                                                             boolean transitive)
                                                      throws org.apache.maven.plugin.MojoExecutionException
Resolves the Artifact from the remote repository if nessessary. If no version is specified, it will be retrieved from the dependency list or from the DependencyManagement section of the pom.

Parameters:
artifact - The artifact to be resolved; must not be null
transitive - True to resolve the artifact transitivly
Returns:
The resolved artifact; never null
Throws:
org.apache.maven.plugin.MojoExecutionException - Failed to resolve artifact

resolveArtifact

protected org.apache.maven.artifact.Artifact resolveArtifact(org.apache.maven.artifact.Artifact artifact)
                                                      throws org.apache.maven.plugin.MojoExecutionException
Resolves the Artifact from the remote repository non-transitivly.

Parameters:
artifact - The artifact to be resolved; must not be null
Returns:
The resolved artifact; never null
Throws:
org.apache.maven.plugin.MojoExecutionException - Failed to resolve artifact
See Also:
resolveArtifact(Artifact,boolean)

getProjectArtifacts

protected Set getProjectArtifacts(org.apache.maven.project.MavenProject project,
                                  boolean resolve)
                           throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getProjectArtifacts

protected Set getProjectArtifacts(boolean resolve)
                           throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getProjectArtifacts

protected Set getProjectArtifacts()
                           throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.