org.codehaus.groovy.maven.plugin
Class MojoSupport

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.groovy.maven.plugin.MojoSupport
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
ProviderMojoSupport

public abstract class MojoSupport
extends org.apache.maven.plugin.AbstractMojo

Support for Mojo implementations.

Version:
$Id: MojoSupport.java 13181 2008-08-10 14:05:55Z user57 $
Author:
Jason Dillon

Field Summary
protected  org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
           
protected  org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource
           
protected  org.apache.maven.artifact.repository.ArtifactRepository artifactRepository
           
protected  org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver
           
protected  org.slf4j.Logger log
           
protected  org.apache.maven.project.MavenProject project
           
protected  java.util.List remoteRepositories
           
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
MojoSupport()
           
 
Method Summary
protected  org.apache.maven.artifact.Artifact createArtifact(ArtifactItem item)
          Create a new artifact.
protected  java.net.URL[] createClassPath()
           
protected abstract  void doExecute()
           
 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  java.util.List getProjectClasspathElements()
           
protected  ArtifactItem[] getUserClassspathElements()
           
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

log

protected final org.slf4j.Logger log

project

protected org.apache.maven.project.MavenProject project

artifactFactory

protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory

artifactResolver

protected org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver

artifactMetadataSource

protected org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource

artifactRepository

protected org.apache.maven.artifact.repository.ArtifactRepository artifactRepository

remoteRepositories

protected java.util.List remoteRepositories
Constructor Detail

MojoSupport

public MojoSupport()
Method Detail

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.

Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

doExecute

protected abstract void doExecute()
                           throws java.lang.Exception
Throws:
java.lang.Exception

getProjectClasspathElements

protected java.util.List getProjectClasspathElements()
                                              throws org.apache.maven.artifact.DependencyResolutionRequiredException
Throws:
org.apache.maven.artifact.DependencyResolutionRequiredException

getUserClassspathElements

protected ArtifactItem[] getUserClassspathElements()

createClassPath

protected java.net.URL[] createClassPath()
                                  throws java.lang.Exception
Throws:
java.lang.Exception

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


Copyright © 2006-2009 Codehaus. All Rights Reserved.