org.nuiton.license.plugin
Class AbstractLicenseWithDescriptorMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.nuiton.plugin.AbstractPlugin
          extended by org.nuiton.license.plugin.AbstractLicenseMojo
              extended by org.nuiton.license.plugin.AbstractLicenseWithDescriptorMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding
Direct Known Subclasses:
UpdateFileHeaderMojo, UpdateProjectLicenseMojo

public abstract class AbstractLicenseWithDescriptorMojo
extends AbstractLicenseMojo
implements org.nuiton.plugin.PluginWithEncoding

Abstract mojo which using descriptor file and owns a licenseStore.

Since:
2.1
Author:
tchemit

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin
org.nuiton.plugin.Plugin.InitState, org.nuiton.plugin.Plugin.Packaging
 
Field Summary
protected  String[] excludes
          Specific files to excludes, separated by a comma.
protected  String[] includes
          Specific files to includes, separated by a comma.
protected  String licenseName
          Name of the license to use for files.
protected  String[] roots
          To specify the base dir from which we apply the license.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractLicenseWithDescriptorMojo()
           
 
Method Summary
protected  FileHeader buildDefaultFileHeader(License license, String projectName, String inceptionYear, String copyrightHolder, boolean addSvnKeyWords, String encoding)
          Build a default header given the parameters.
protected  boolean checkSkip()
           
protected  String getCommentStyle(String extension)
           
 File getDescriptor()
           
 String getEncoding()
           
 String[] getExcludes()
           
 String[] getIncludes()
           
 License getLicense(String licenseName)
           
 String getLicenseName()
           
 LicenseProjectDescriptor getLicenseProjectDescriptor()
           
 String getLicenseResolver()
           
 LicenseStore getLicenseStore()
           
 License getMainLicense()
           
 String[] getRoots()
           
 FileHeaderTransformer getTransformer(String transformerName)
           
 Map<String,FileHeaderTransformer> getTransformers()
           
 Map<String,List<File>> getUniverse()
           
protected  void init()
           
 boolean isKeepBackup()
           
abstract  boolean isSkip()
          When is sets to true, will skip execution.
 void setDescriptor(File descriptor)
           
 void setEncoding(String encoding)
           
 void setExcludes(String excludes)
           
 void setExcludes(String[] excludes)
           
 void setIncludes(String includes)
           
 void setIncludes(String[] includes)
           
 void setKeepBackup(boolean keepBackup)
           
 void setLicenseName(String licenseName)
           
 void setLicenseProjectDescriptor(LicenseProjectDescriptor licenseProjectDescriptor)
           
 void setLicenseResolver(String licenseResolver)
           
 void setLicenseStore(LicenseStore licenseStore)
           
 void setRoots(String roots)
           
 void setRoots(String[] roots)
           
abstract  void setSkip(boolean skip)
          Changes internal state skip to execute (or not) goal.
 void setTransformers(Map<String,FileHeaderTransformer> transformers)
           
 void setUniverse(Map<String,List<File>> universe)
           
protected  void treatFilesByCommentStyle(Map<File,String[]> filesToTreat, LicenseStore licenseStore, Map<String,FileHeaderTransformer> transformers)
           
protected  void validateLicenseProjectDescriptor(LicenseProjectDescriptor licenseProjectDescriptor, LicenseStore licenseStore, Map<String,FileHeaderTransformer> transformers)
           
 
Methods inherited from class org.nuiton.license.plugin.AbstractLicenseMojo
createLicenseStore, getBuildTimestamp, getProject, getSession, isVerbose, setProject, setSession, setVerbose
 
Methods inherited from class org.nuiton.plugin.AbstractPlugin
acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, backupFile, checkEncoding, checkPackaging, checkResource, checkRunOnceDone, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, doAction, execute, getBackupFile, getFileFromBasedir, getFilesToTreate, getFilesToTreateForRoots, getRootProject, getTemplate, hasClassPath, initClassLoader, isExecutionRoot, isFileNewerThanPomFile, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile
 
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
 
Methods inherited from interface org.nuiton.plugin.Plugin
getProject, isVerbose, setProject, setVerbose
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute, getLog, setLog
 

Field Detail

licenseName

protected String licenseName
Name of the license to use for files.

Since:
2.4
Is defined by:
expression:
${licenseName}

roots

protected String[] roots
To specify the base dir from which we apply the license. Should be on form "root1,root2,rootn". By default, the main root is "src".

Since:
2.4
Is defined by:
expression:
${license.roots}

includes

protected String[] includes
Specific files to includes, separated by a comma. By default, it is "** /*".

Since:
2.4
Is defined by:
expression:
${license.includes}

excludes

protected String[] excludes
Specific files to excludes, separated by a comma. By default, thoses file type are excluded:

Since:
2.4
Is defined by:
expression:
${license.excludes}
Constructor Detail

AbstractLicenseWithDescriptorMojo

public AbstractLicenseWithDescriptorMojo()
Method Detail

isSkip

public abstract boolean isSkip()
When is sets to true, will skip execution.

This will take effects in method checkSkip(). So the method AbstractPlugin.doAction() will never be invoked.

Returns:
true if goal will not be executed

setSkip

public abstract void setSkip(boolean skip)
Changes internal state skip to execute (or not) goal.

Parameters:
skip - new state value

checkSkip

protected boolean checkSkip()
Overrides:
checkSkip in class org.nuiton.plugin.AbstractPlugin

init

protected void init()
             throws Exception
Specified by:
init in class org.nuiton.plugin.AbstractPlugin
Throws:
Exception

getEncoding

public final String getEncoding()
Specified by:
getEncoding in interface org.nuiton.plugin.PluginWithEncoding

setEncoding

public final void setEncoding(String encoding)
Specified by:
setEncoding in interface org.nuiton.plugin.PluginWithEncoding

getDescriptor

public File getDescriptor()

isKeepBackup

public boolean isKeepBackup()

getTransformers

public Map<String,FileHeaderTransformer> getTransformers()

getLicenseName

public String getLicenseName()

getRoots

public String[] getRoots()

getIncludes

public String[] getIncludes()

getExcludes

public String[] getExcludes()

getLicenseResolver

public String getLicenseResolver()

getLicenseStore

public LicenseStore getLicenseStore()

getLicenseProjectDescriptor

public LicenseProjectDescriptor getLicenseProjectDescriptor()

getUniverse

public Map<String,List<File>> getUniverse()

setKeepBackup

public void setKeepBackup(boolean keepBackup)

setDescriptor

public void setDescriptor(File descriptor)

setLicenseResolver

public void setLicenseResolver(String licenseResolver)

setTransformers

public void setTransformers(Map<String,FileHeaderTransformer> transformers)

setLicenseName

public void setLicenseName(String licenseName)

setRoots

public void setRoots(String[] roots)

setRoots

public void setRoots(String roots)

setIncludes

public void setIncludes(String[] includes)

setIncludes

public void setIncludes(String includes)

setExcludes

public void setExcludes(String[] excludes)

setExcludes

public void setExcludes(String excludes)

setLicenseStore

public void setLicenseStore(LicenseStore licenseStore)

setLicenseProjectDescriptor

public void setLicenseProjectDescriptor(LicenseProjectDescriptor licenseProjectDescriptor)

setUniverse

public void setUniverse(Map<String,List<File>> universe)

getMainLicense

public License getMainLicense()
                       throws IllegalArgumentException,
                              IllegalStateException
Throws:
IllegalArgumentException
IllegalStateException

getLicense

public License getLicense(String licenseName)
                   throws IllegalArgumentException,
                          IllegalStateException
Throws:
IllegalArgumentException
IllegalStateException

getTransformer

public FileHeaderTransformer getTransformer(String transformerName)
                                     throws IllegalArgumentException,
                                            IllegalStateException
Throws:
IllegalArgumentException
IllegalStateException

buildDefaultFileHeader

protected FileHeader buildDefaultFileHeader(License license,
                                            String projectName,
                                            String inceptionYear,
                                            String copyrightHolder,
                                            boolean addSvnKeyWords,
                                            String encoding)
                                     throws IOException
Build a default header given the parameters.

Parameters:
license - the license type ot use in header
projectName - project name as header description
inceptionYear - first year of copyright
copyrightHolder - holder of copyright
encoding - encoding used to read or write files
addSvnKeyWords - a flag to add in description section svn keywords
Returns:
the new file header
Throws:
IOException - if any problem while creating file header

validateLicenseProjectDescriptor

protected void validateLicenseProjectDescriptor(LicenseProjectDescriptor licenseProjectDescriptor,
                                                LicenseStore licenseStore,
                                                Map<String,FileHeaderTransformer> transformers)
                                         throws org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoFailureException

treatFilesByCommentStyle

protected void treatFilesByCommentStyle(Map<File,String[]> filesToTreat,
                                        LicenseStore licenseStore,
                                        Map<String,FileHeaderTransformer> transformers)

getCommentStyle

protected String getCommentStyle(String extension)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.