org.codehaus.mojo.license
Class AbstractLicenseMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.license.AbstractLicenseMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractAddThirdPartyMojo, AbstractLicenseNameMojo, CommentStyleListMojo, LicenseListMojo

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

Abstract license mojo.

Since:
1.0
Author:
tchemit

Field Summary
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractLicenseMojo()
           
 
Method Summary
protected  boolean acceptPackaging(String... packages)
          Accept the project's packaging between some given.
protected  void addResourceDir(File dir, String... includes)
          Add a new resource location to the maven project (in not already present).
protected  void afterExecute()
          A call back to execute after the execute() is done
protected  void checkEncoding()
          Method to be invoked in init phase to check sanity of getEncoding().
protected  boolean checkPackaging()
          Check if the project packaging is acceptable for the mojo.
protected  boolean checkSkip()
          Checks if the mojo execution should be skipped.
protected abstract  void doAction()
          Do plugin action.
 void execute()
           
 long getBuildTimestamp()
           
 String getEncoding()
           
 org.apache.maven.project.MavenProject getProject()
           
 org.apache.maven.execution.MavenSession getSession()
           
protected  boolean hasClassPath()
           
protected abstract  void init()
          Method to initialize the mojo before doing any concrete actions.
 boolean isVerbose()
           
protected  boolean rejectPackaging(String... packages)
          Accept the project's packaging if not in given one.
 void setEncoding(String encoding)
           
 void setProject(org.apache.maven.project.MavenProject project)
           
 void setSession(org.apache.maven.execution.MavenSession session)
           
 void setVerbose(boolean verbose)
           
 
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
 

Constructor Detail

AbstractLicenseMojo

public AbstractLicenseMojo()
Method Detail

getEncoding

public final String getEncoding()

setEncoding

public final void setEncoding(String encoding)

init

protected abstract void init()
                      throws Exception
Method to initialize the mojo before doing any concrete actions.

Note: The method is invoked before the doAction() method.

Throws:
Exception - if any

doAction

protected abstract void doAction()
                          throws Exception
Do plugin action.

The method execute() invoke this method only and only if :

Throws:
Exception - if any

execute

public final void execute()
                   throws org.apache.maven.plugin.MojoExecutionException,
                          org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

afterExecute

protected void afterExecute()
A call back to execute after the execute() is done


checkPackaging

protected boolean checkPackaging()
Check if the project packaging is acceptable for the mojo.

By default, accept all packaging types.

Note: This method is the first instruction to be executed in the execute().

Tip: There is two method to simplify the packaging check :

acceptPackaging(String...)

and

rejectPackaging(String...)

Returns:
true if can execute the goal for the packaging of the project, false otherwise.

checkSkip

protected boolean checkSkip()
Checks if the mojo execution should be skipped.

Returns:
false if the mojo should not be executed.

acceptPackaging

protected boolean acceptPackaging(String... packages)
Accept the project's packaging between some given.

Parameters:
packages - the accepted packaging
Returns:
true if the project's packaging is one of the given ones.

rejectPackaging

protected boolean rejectPackaging(String... packages)
Accept the project's packaging if not in given one.

Parameters:
packages - the rejecting packagings
Returns:
true if the project's packaging is not in the given ones.

checkEncoding

protected void checkEncoding()
Method to be invoked in init phase to check sanity of getEncoding().

If no encoding was filled, then use the default for system (via file.encoding environement property).


getProject

public final org.apache.maven.project.MavenProject getProject()

setProject

public final void setProject(org.apache.maven.project.MavenProject project)

isVerbose

public final boolean isVerbose()

setVerbose

public final void setVerbose(boolean verbose)

getSession

public final org.apache.maven.execution.MavenSession getSession()

setSession

public final void setSession(org.apache.maven.execution.MavenSession session)

getBuildTimestamp

public final long getBuildTimestamp()

addResourceDir

protected void addResourceDir(File dir,
                              String... includes)
Add a new resource location to the maven project (in not already present).

Parameters:
dir - the new resource location to add
includes - files to include

hasClassPath

protected boolean hasClassPath()
Returns:
true if project is not a pom, false otherwise.


Copyright © 2010-2012 The Kuali Foundation. All Rights Reserved.