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,CheckProjectLicenseMojo,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
FieldsModifier and TypeFieldDescriptionprotected final org.apache.maven.project.MavenProjectHelperFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractLicenseMojo(org.apache.maven.project.MavenProjectHelper projectHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanacceptPackaging(String... packages) Accept the project's packaging between some given.protected voidaddResourceDir(File dir, String... includes) Add a new resource location to the maven project (in not already present).protected voidA call back to execute after theexecute()is done.protected voidMethod to be invoked in init phase to check sanity ofgetEncoding().protected booleanCheck if the project packaging is acceptable for the mojo.protected abstract voiddoAction()Do plugin action.final voidexecute()final Stringfinal org.apache.maven.project.MavenProjectprotected booleanprotected abstract voidinit()Method to initialize the mojo before doing any concrete actions.abstract booleanisSkip()When is sets totrue, will skip execution.final booleanprotected booleanrejectPackaging(String... packages) Accept the project's packaging if not in given one.final voidsetEncoding(String encoding) Sets new encoding used to read and write files.final voidsetVerbose(boolean verbose) Sets new value toverboseflag.protected booleanChecks if the mojo execution should be skipped.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
projectHelper
protected final org.apache.maven.project.MavenProjectHelper projectHelper
-
-
Constructor Details
-
AbstractLicenseMojo
protected AbstractLicenseMojo(org.apache.maven.project.MavenProjectHelper projectHelper)
-
-
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:
trueif 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.MojoExecutionExceptionorg.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:
trueif verbose flag is on,falseotherwise
-
setVerbose
public final void setVerbose(boolean verbose) Sets new value toverboseflag.- 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:
trueif can execute the goal for the packaging of the project,falseotherwise.
-
shouldSkip
protected boolean shouldSkip()Checks if the mojo execution should be skipped.- Returns:
trueif the mojo should not be executed.
-
acceptPackaging
Accept the project's packaging between some given.- Parameters:
packages- the accepted packaging- Returns:
trueif 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:
trueif 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.encodingenvironement 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:
trueif project is not a pom,falseotherwise.
-