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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    A call back to execute after the execute() is done.
    protected void
    Method to be invoked in init phase to check sanity of getEncoding().
    protected boolean
    Check if the project packaging is acceptable for the mojo.
    protected abstract void
    Do plugin action.
    final void
    final String
     
    final org.apache.maven.project.MavenProject
     
    protected boolean
     
    protected abstract void
    Method to initialize the mojo before doing any concrete actions.
    abstract boolean
    When is sets to true, 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 to verbose flag.
    protected boolean
    Checks if the mojo execution should be skipped.

    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 Details

    • AbstractLicenseMojo

      public AbstractLicenseMojo()
  • Method Details

    • isSkip

      public abstract boolean isSkip()
      When is sets to true, will skip execution. This will take effect in at the very begin of the execute() before any initialisation of goal.
      Returns:
      true if goal will not be executed
    • 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
    • getEncoding

      public final String getEncoding()
      Returns:
      the enconding used to read and write files.
    • setEncoding

      public final void setEncoding(String encoding)
      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 to verbose flag.
      Parameters:
      verbose - new value to set
    • 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.
    • shouldSkip

      protected boolean shouldSkip()
      Checks if the mojo execution should be skipped.
      Returns:
      true 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).
    • 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.