Package org.codehaus.mojo.license
Class AbstractLicenseMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
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 dev@tchemit.fr
-
Field Summary
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
A call back to execute after theexecute()
is done.protected void
Method to be invoked in init phase to check sanity ofgetEncoding()
.protected boolean
Check if the project packaging is acceptable for the mojo.protected abstract void
doAction()
Do plugin action.final void
execute()
final String
final org.apache.maven.project.MavenProject
protected boolean
protected abstract void
init()
Method to initialize the mojo before doing any concrete actions.abstract boolean
isSkip()
When is sets totrue
, will skip execution.final boolean
protected boolean
rejectPackaging
(String... packages) Accept the project's packaging if not in given one.final void
setEncoding
(String encoding) Sets new encoding used to read and write files.final void
setVerbose
(boolean verbose) Sets new value toverbose
flag.protected boolean
Checks if the mojo execution should be skipped.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
AbstractLicenseMojo
public AbstractLicenseMojo()
-
-
Method Details
-
isSkip
public abstract boolean isSkip()When is sets totrue
, will skip execution. This will take effect in at the very begin of theexecute()
before any initialisation of goal.- Returns:
true
if goal will not be executed
-
init
Method to initialize the mojo before doing any concrete actions. Note: The method is invoked before thedoAction()
method.- Throws:
Exception
- if any
-
doAction
Do plugin action. The methodexecute()
invoke this method only and only if :checkPackaging()
returnstrue
.- method
init()
returnstrue
.
- 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
-
getEncoding
- Returns:
- the enconding used to read and write files.
-
setEncoding
Sets new encoding used to read and write files.- Parameters:
encoding
- new encodnignt ing to use
-
getProject
public final org.apache.maven.project.MavenProject getProject()- Returns:
- the current maven project
-
isVerbose
public final boolean isVerbose()- Returns:
true
if verbose flag is on,false
otherwise
-
setVerbose
public final void setVerbose(boolean verbose) Sets new value toverbose
flag.- Parameters:
verbose
- new value to set
-
afterExecute
protected void afterExecute()A call back to execute after theexecute()
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 theexecute()
. Tip: There is two method to simplify the packaging check :acceptPackaging(String...)
andrejectPackaging(String...)
- Returns:
true
if can execute the goal for the packaging of the project,false
otherwise.
-
shouldSkip
protected boolean shouldSkip()Checks if the mojo execution should be skipped.- Returns:
true
if the mojo should not be executed.
-
acceptPackaging
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
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 ofgetEncoding()
. If no encoding was filled, then use the default for system (viafile.encoding
environement property). -
addResourceDir
Add a new resource location to the maven project (in not already present).- Parameters:
dir
- the new resource location to addincludes
- files to include
-
hasClassPath
protected boolean hasClassPath()- Returns:
true
if project is not a pom,false
otherwise.
-