public abstract class AbstractFileHeaderMojo extends AbstractLicenseNameMojo implements FileHeaderProcessorConfiguration
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractFileHeaderMojo.FileState
Defines state of a file after process.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
addJavaLicenseAfterPackage
A flag to add the license header in java files after the package statement.
|
protected boolean |
addSvnKeyWords
A flag to add svn:keywords on new header.
|
protected boolean |
canUpdateCopyright
A flag to authorize update of the copyright part of the header.
|
protected boolean |
canUpdateDescription
A flag to authorize update of the description part of the header.
|
protected boolean |
canUpdateLicense
A flag to authorize update of the license part of the header.
|
protected boolean |
clearAfterOperation
A flag to clear everything after execution.
|
static String[] |
DEFAULT_EXCLUDES |
static String[] |
DEFAULT_INCLUDES |
static String[] |
DEFAULT_ROOTS |
protected String |
descriptionTemplate
Template used to build the description section of the license header.
|
protected String[] |
excludes
Specific files to excludes, separated by a comma.
|
protected Map<String,String> |
extraExtensions
To associate extra extension files to an existing comment style.
|
protected String |
ignoreTag
A tag to place on files that will be ignored by the plugin.
|
protected String[] |
includes
Specific files to includes, separated by a comma.
|
protected String |
processEndTag
To overwrite the processEndTag used to build header model.
|
protected String |
processStartTag
To overwrite the processStartTag used to build header model.
|
protected String[] |
roots
To specify the base dir from which we apply the license.
|
protected String |
sectionDelimiter
To overwrite the sectionDelimiter used to build header model.
|
copyrightOwners, extraTemplateParameters, inceptionYear, organizationName, projectName| Constructor and Description |
|---|
AbstractFileHeaderMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected FileHeader |
buildDefaultFileHeader(License license,
String encoding)
Build a default header given the parameters.
|
protected void |
checkResults(EnumMap<AbstractFileHeaderMojo.FileState,Set<File>> result)
Checks the results of the mojo execution using the
isFailOnMissingHeader() and
isFailOnNotUptodateHeader(). |
protected String |
cleanHeaderConfiguration(String value,
String defaultValue)
Obtain for a given value, a trim version of it.
|
protected void |
clear()
Clear internal states of the mojo after execution.
|
void |
doAction()
Do plugin action.
|
protected void |
finalize() |
protected void |
finalizeFile(File file,
File processFile)
Finalize the process of a file.
|
FileHeader |
getFileHeader() |
protected Set<File> |
getFiles(AbstractFileHeaderMojo.FileState state)
Gets all files for the given
state. |
protected void |
getFilesToTreateForRoots(String[] includes,
String[] excludes,
List<String> roots,
Map<File,String[]> files)
Collects some file.
|
FileHeaderTransformer |
getTransformer() |
protected FileHeaderTransformer |
getTransformer(String transformerName)
Obtains the
FileHeaderTransformer given his name. |
void |
init()
Method to initialize the mojo before doing any concrete actions.
|
protected abstract boolean |
isDryRun() |
protected abstract boolean |
isFailOnMissingHeader() |
protected abstract boolean |
isFailOnNotUptodateHeader() |
protected Map<String,List<File>> |
obtainFilesToProcessByCommentStyle()
Gets all files to process indexed by their comment style.
|
protected void |
processCommentStyle(String commentStyle,
List<File> filesToTreat)
Process a given comment styl to all his detected files.
|
protected void |
processFile(File file)
Process the given file (will copy it, process the clone file and finally finalizeFile after process)...
|
protected boolean |
processFile(File file,
File processFile)
Process the given
file and save the result in the given
processFile. |
protected void |
reportType(AbstractFileHeaderMojo.FileState state,
StringBuilder buffer)
Reports into the given
buffer stats for the given state. |
protected void |
updateFileHeaderDescription(File file)
Update in file header the description parts given the current file.
|
getCopyright, getCopyrightOwners, getLicense, getLicense, getLicenseName, isKeepBackup, processLicenseContextacceptPackaging, addResourceDir, afterExecute, checkEncoding, checkPackaging, checkSkip, execute, getBuildTimestamp, getEncoding, getProject, getSession, hasClassPath, isSkip, isVerbose, rejectPackaging, setEncoding, setVerbosegetLog, getPluginContext, setLog, setPluginContextclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLogpublic static final String[] DEFAULT_INCLUDES
public static final String[] DEFAULT_EXCLUDES
public static final String[] DEFAULT_ROOTS
@Parameter(property="license.processStartTag") protected String processStartTag
@Parameter(property="license.processEndTag") protected String processEndTag
@Parameter(property="license.sectionDelimiter") protected String sectionDelimiter
@Parameter(property="license.addSvnKeyWords",
defaultValue="false")
protected boolean addSvnKeyWords
Id, HeadURLNote: This parameter is used by the
descriptionTemplate, so if you change this
template, the parameter could be no more used (depends what you put in your own template...).@Parameter(property="license.canUpdateDescription",
defaultValue="false")
protected boolean canUpdateDescription
@Parameter(property="license.canUpdateCopyright",
defaultValue="false")
protected boolean canUpdateCopyright
@Parameter(property="license.canUpdateLicense",
defaultValue="true")
protected boolean canUpdateLicense
@Parameter(property="license.ignoreTag") protected String ignoreTag
%% Ignore-License@Parameter(property="license.clearAfterOperation",
defaultValue="true")
protected boolean clearAfterOperation
@Parameter(property="license.addJavaLicenseAfterPackage",
defaultValue="true")
protected boolean addJavaLicenseAfterPackage
true since it is a good practice.@Parameter(property="license.roots") protected String[] roots
@Parameter(property="license.includes") protected String[] includes
@Parameter(property="license.excludes") protected String[] excludes
@Parameter protected Map<String,String> extraExtensions
java2 and jdata
as java files (says using the java comment style, declare this
in your plugin configuration :
<extraExtensions> <java2>java</java2> <jdata>java</jdata> </extraExtensions>Note: This parameter is not useable if you are still using a project file descriptor.
@Parameter(property="license.descriptionTemplate",
defaultValue="/org/codehaus/mojo/license/default-file-header-description.ftl")
protected String descriptionTemplate
protected abstract boolean isDryRun()
true if mojo must be a simple dry run (says do not modifiy any scanned files),
false otherise.protected abstract boolean isFailOnMissingHeader()
true if mojo should fails if dryRun and there is some missing license header, false otherwise.protected abstract boolean isFailOnNotUptodateHeader()
true if mojo should fails if dryRun and there is some obsolete license header, false otherwise.public void init()
throws Exception
AbstractLicenseMojo.doAction() method.init in class AbstractLicenseNameMojoException - if anypublic void doAction()
throws Exception
AbstractLicenseMojo.execute() invoke this method only and only if :
AbstractLicenseMojo.checkPackaging() returns true.AbstractLicenseMojo.init() returns true.doAction in class AbstractLicenseMojoException - if anypublic FileHeader getFileHeader()
getFileHeader in interface FileHeaderProcessorConfigurationpublic FileHeaderTransformer getTransformer()
getTransformer in interface FileHeaderProcessorConfigurationprotected Map<String,List<File>> obtainFilesToProcessByCommentStyle()
protected void checkResults(EnumMap<AbstractFileHeaderMojo.FileState,Set<File>> result) throws org.apache.maven.plugin.MojoFailureException
isFailOnMissingHeader() and
isFailOnNotUptodateHeader().result - processed files by their statusorg.apache.maven.plugin.MojoFailureException - if check is not ok (some file with no header or to update)protected void processCommentStyle(String commentStyle, List<File> filesToTreat) throws IOException
commentStyle - comment style to treatfilesToTreat - files using this comment style to treatIOException - if any IO error while processing filesprotected void processFile(File file) throws IOException
file - original file to processIOException - if any IO error while processing this fileprotected boolean processFile(File file, File processFile) throws IOException
file and save the result in the given
processFile.file - the file to processprocessFile - the ouput processed filetrue if prepareProcessFile can be finalize, otherwise need to be deleteIOException - if any pb while treatmentprotected void finalizeFile(File file, File processFile) throws IOException
file - the original fileprocessFile - the processed fileIOException - if any IO error while finalizing fileprotected void finalize()
throws Throwable
protected void clear()
clearAfterOperation if on).protected void reportType(AbstractFileHeaderMojo.FileState state, StringBuilder buffer)
buffer stats for the given state.state - state of file to reportbuffer - where to reportprotected FileHeader buildDefaultFileHeader(License license, String encoding) throws IOException
license - the license type ot use in headerencoding - encoding used to read or write filesIOException - if any problem while creating file headerprotected void updateFileHeaderDescription(File file) throws IOException
file - current file to treatIOException - if any problem while creating file headerprotected FileHeaderTransformer getTransformer(String transformerName)
FileHeaderTransformer given his name.transformerName - the name of the transformer to findprotected String cleanHeaderConfiguration(String value, String defaultValue)
value - the value to trim (if not empty)defaultValue - the default value to use if value is emptyprotected Set<File> getFiles(AbstractFileHeaderMojo.FileState state)
state.state - state of files to getprotected void getFilesToTreateForRoots(String[] includes, String[] excludes, List<String> roots, Map<File,String[]> files)
includes - includesexcludes - excludesroots - root directories to treatfiles - cache of file detected indexed by their root directoryCopyright © 2010–2014 Codehaus. All rights reserved.