Package com.igormaznitsa.jcp.maven
Class PreprocessorMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.igormaznitsa.jcp.maven.PreprocessorMojo
-
- All Implemented Interfaces:
PreprocessorLogger,org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
PreprocessTestsMojo
@Mojo(name="preprocess", defaultPhase=GENERATE_SOURCES, threadSafe=true, requiresProject=true) public class PreprocessorMojo extends org.apache.maven.plugin.AbstractMojo implements PreprocessorLoggerThe Mojo makes preprocessing of defined or project root source folders and place result in defined or predefined folder, also it can replace the source folder for a maven project to use the preprocessed sources.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanallowWhitespaceManage mode to allow whitespace between the // and the #.private booleancareForLastNextLineBe precise in processing of the last next line char in files, it will not be added if it is not presented if to turn on the mode..private java.io.File[]cfgFilesList of external configuration files.private booleanclearClear the destination folder before preprocessing (if it exists).private booleancompareDestinationFlag to compare generated content with existing file and if it is the same then to not override the file, it brings overheadprivate java.util.List<java.lang.String>compileSourceRootsThe Project source roots for non-test mode.private booleancopyFileAttributesCopy file attributes for copied and generated files.private java.io.FiledestinationThe Destination folder where generated sources will be placed in non-test mode.private booleandisableOutMake dry run of the preprocessor without any saving of result.private java.lang.StringexcludedList of file extensions to be excluded from the preprocessing process.private java.lang.String[]excludedFoldersList of sub-folders in source folders to be excluded from preprocessing, ANT path pattern format allowed.private java.util.PropertiesglobalVarsList of global preprocessing variables.private booleanignoreMissingSourcesFlag to ignore missing source folders, if false then mojo fail for any missing source folder, if true then missing folder will be ignored.private java.lang.StringinEncodingThe Input text encoding to be used for preprocessing, by default it uses defined in project properties.private booleankeepLinesDisable removing lines from preprocessed files, it allows to keep line numeration similar to original sources.private booleankeepSrcRootDisable overriding of the source root folders for maven project after preprocessing.private java.lang.StringoutEncodingThe Encoding for preprocessed text output, by default it uses defined in project properties.private booleanpreserveIndentPreserve indents in lines marked by '//$' and '//$$' directives.private java.lang.StringprocessingList of file extensions to be preprocessed.private org.apache.maven.project.MavenProjectprojectThe Maven Project to be preprocessed.private booleanremoveCommentsRemove all Java like commentaries from preprocessed sources.private booleanskipSkip preprocessing.private java.lang.StringsourceThe Directly defined source directory, it will make plugin to preprocess the folder instead of project and maven defined ones.private java.util.List<java.lang.String>testCompileSourceRootsThe Project source roots for test mode.private java.io.FiletestDestinationDestination folder where generated sources will be placed in test-mode.private booleanunknownVarAsFalseFlag to interpret unknown variable as FALSE.private booleanuseTestSourcesAllow usage of the preprocessor for test sources (since 5.3.4 version).private booleanverboseTurn on the verbose mode for preprocessing process.
-
Constructor Summary
Constructors Constructor Description PreprocessorMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(java.lang.String message)Log a debug messagevoiderror(java.lang.String message)Log an error messagevoidexecute()booleangetAllowWhitespace()booleangetCarForLastNextLine()java.io.File[]getCfgFiles()booleangetClear()booleangetCopyFileAttributes()java.io.FilegetDestination()booleangetDisableOut()java.lang.StringgetExcluded()java.lang.String[]getExcludedFolders()java.util.PropertiesgetGlobalVars()java.lang.StringgetInEncoding()booleangetKeepLines()booleangetKeepSrcRoot()java.lang.StringgetOutEncoding()booleangetPreserveIndent()java.lang.StringgetProcessing()booleangetRemoveComments()java.lang.StringgetSource()java.io.FilegetTestDestination()booleangetUnknownVarAsFalse()booleangetUseTestSources()booleangetVerbose()voidinfo(java.lang.String message)Log an information messagebooleanisCompareDestination()booleanisIgnoreMissingSources()booleanisSkip()(package private) PreprocessorContextmakePreprocessorContext(java.lang.String sourceFoldersInPreprocessorFormat)private java.lang.StringmakeSourceRootList()private voidreplaceSourceRootByPreprocessingDestinationFolder(PreprocessorContext context)voidsetAllowWhitespace(boolean flag)voidsetCareForLastNextLine(boolean flag)voidsetCfgFiles(java.io.File[] files)voidsetClear(boolean flag)voidsetCompareDestination(boolean flag)voidsetCopyFileAttributes(boolean flag)voidsetDestination(java.io.File destination)voidsetDisableOut(boolean value)voidsetExcluded(java.lang.String excluded)voidsetExcludedFolders(java.lang.String... antPatterns)voidsetGlobalVars(java.util.Properties vars)voidsetIgnoreMissingSources(boolean flag)voidsetInEncoding(java.lang.String value)voidsetKeepLines(boolean keepLines)voidsetKeepSrcRoot(boolean flag)voidsetOutEncoding(java.lang.String value)voidsetPreserveIndent(boolean flag)voidsetProcessing(java.lang.String processing)voidsetRemoveComments(boolean value)voidsetSkip(boolean flag)voidsetSource(java.lang.String source)voidsetTestDestination(java.io.File destination)voidsetUnknownVarAsFalse(boolean flag)voidsetUseTestSources(boolean flag)voidsetVerbose(boolean verbose)voidwarning(java.lang.String message)Log a warning message
-
-
-
Field Detail
-
compileSourceRoots
@Parameter(alias="compileSourceRoots", defaultValue="${project.compileSourceRoots}", required=true, readonly=true) private java.util.List<java.lang.String> compileSourceRootsThe Project source roots for non-test mode.
-
testCompileSourceRoots
@Parameter(alias="testCompileSourceRoots", defaultValue="${project.testCompileSourceRoots}", required=true, readonly=true) private java.util.List<java.lang.String> testCompileSourceRootsThe Project source roots for test mode.
-
project
@Parameter(defaultValue="${project}", required=true, readonly=true) private org.apache.maven.project.MavenProject projectThe Maven Project to be preprocessed.
-
source
@Parameter(alias="source", defaultValue="") private java.lang.String sourceThe Directly defined source directory, it will make plugin to preprocess the folder instead of project and maven defined ones. By default it is empty and is not used.
-
copyFileAttributes
@Parameter(alias="copyFileAttributes", defaultValue="false") private boolean copyFileAttributesCopy file attributes for copied and generated files.- Since:
- 6.1.2
-
destination
@Parameter(alias="destination", defaultValue="${project.build.directory}/generated-sources/preprocessed") private java.io.File destinationThe Destination folder where generated sources will be placed in non-test mode.
-
testDestination
@Parameter(alias="testDestination", defaultValue="${project.build.directory}/generated-test-sources/preprocessed") private java.io.File testDestinationDestination folder where generated sources will be placed in test-mode.
-
inEncoding
@Parameter(alias="inEncoding", defaultValue="${project.build.sourceEncoding}") private java.lang.String inEncodingThe Input text encoding to be used for preprocessing, by default it uses defined in project properties.
-
outEncoding
@Parameter(alias="outEncoding", defaultValue="${project.build.sourceEncoding}") private java.lang.String outEncodingThe Encoding for preprocessed text output, by default it uses defined in project properties.
-
ignoreMissingSources
@Parameter(alias="ignoreMissingSources", defaultValue="false") private boolean ignoreMissingSourcesFlag to ignore missing source folders, if false then mojo fail for any missing source folder, if true then missing folder will be ignored.- Since:
- 6.1.1
-
excluded
@Parameter(alias="excluded") private java.lang.String excluded
List of file extensions to be excluded from the preprocessing process. By default excluded XML files.
-
processing
@Parameter(alias="processing") private java.lang.String processing
List of file extensions to be preprocessed. By default java,txt,htm,html
-
unknownVarAsFalse
@Parameter(alias="unknownVarAsFalse", defaultValue="false") private boolean unknownVarAsFalseFlag to interpret unknown variable as FALSE.
-
disableOut
@Parameter(alias="disableOut", defaultValue="false") private boolean disableOutMake dry run of the preprocessor without any saving of result.
-
verbose
@Parameter(alias="verbose", defaultValue="false") private boolean verboseTurn on the verbose mode for preprocessing process.
-
clear
@Parameter(alias="clear", defaultValue="false") private boolean clearClear the destination folder before preprocessing (if it exists).
-
careForLastNextLine
@Parameter(alias="careForLastNextLine", defaultValue="false") private boolean careForLastNextLineBe precise in processing of the last next line char in files, it will not be added if it is not presented if to turn on the mode..
-
keepSrcRoot
@Parameter(alias="keepSrcRoot", defaultValue="false") private boolean keepSrcRootDisable overriding of the source root folders for maven project after preprocessing.
-
removeComments
@Parameter(alias="removeComments", defaultValue="false") private boolean removeCommentsRemove all Java like commentaries from preprocessed sources.
-
globalVars
@Parameter(alias="globalVars") private java.util.Properties globalVars
List of global preprocessing variables.
-
excludedFolders
@Parameter(alias="excludedFolders") private java.lang.String[] excludedFolders
List of sub-folders in source folders to be excluded from preprocessing, ANT path pattern format allowed.
-
cfgFiles
@Parameter(alias="cfgFiles") private java.io.File[] cfgFiles
List of external configuration files.
-
keepLines
@Parameter(alias="keepLines", defaultValue="true") private boolean keepLinesDisable removing lines from preprocessed files, it allows to keep line numeration similar to original sources.
-
allowWhitespace
@Parameter(alias="allowWhitespace", defaultValue="false") private boolean allowWhitespaceManage mode to allow whitespace between the // and the #.
-
preserveIndent
@Parameter(alias="preserveIndent", defaultValue="false") private boolean preserveIndentPreserve indents in lines marked by '//$' and '//$$' directives. The Directives will be replaced by white spaces chars.
-
useTestSources
@Parameter(alias="useTestSources", defaultValue="false") private boolean useTestSourcesAllow usage of the preprocessor for test sources (since 5.3.4 version).
-
skip
@Parameter(alias="skip", property="jcp.preprocess.skip", defaultValue="false") private boolean skipSkip preprocessing.- Since:
- 6.1.1
-
compareDestination
@Parameter(alias="compareDestination", defaultValue="false") private boolean compareDestinationFlag to compare generated content with existing file and if it is the same then to not override the file, it brings overhead
-
-
Method Detail
-
setExcludedFolders
public void setExcludedFolders(@MustNotContainNull java.lang.String... antPatterns)
-
getExcludedFolders
@MustNotContainNull public java.lang.String[] getExcludedFolders()
-
setIgnoreMissingSources
public void setIgnoreMissingSources(boolean flag)
-
isIgnoreMissingSources
public boolean isIgnoreMissingSources()
-
setSkip
public void setSkip(boolean flag)
-
isSkip
public boolean isSkip()
-
setPreserveIndent
public void setPreserveIndent(boolean flag)
-
getPreserveIndent
public boolean getPreserveIndent()
-
setCopyFileAttributes
public void setCopyFileAttributes(boolean flag)
-
getCopyFileAttributes
public boolean getCopyFileAttributes()
-
setUseTestSources
public void setUseTestSources(boolean flag)
-
getUseTestSources
public boolean getUseTestSources()
-
setClear
public void setClear(boolean flag)
-
getClear
public boolean getClear()
-
setCareForLastNextLine
public void setCareForLastNextLine(boolean flag)
-
getCarForLastNextLine
public boolean getCarForLastNextLine()
-
setKeepSrcRoot
public void setKeepSrcRoot(boolean flag)
-
getKeepSrcRoot
public boolean getKeepSrcRoot()
-
setGlobalVars
public void setGlobalVars(java.util.Properties vars)
-
getGlobalVars
public java.util.Properties getGlobalVars()
-
setCfgFiles
public void setCfgFiles(@MustNotContainNull java.io.File[] files)
-
getCfgFiles
@MustNotContainNull public java.io.File[] getCfgFiles()
-
setCompareDestination
public void setCompareDestination(boolean flag)
-
isCompareDestination
public boolean isCompareDestination()
-
setSource
public void setSource(java.lang.String source)
-
getSource
public java.lang.String getSource()
-
setDestination
public void setDestination(java.io.File destination)
-
getDestination
public java.io.File getDestination()
-
setTestDestination
public void setTestDestination(java.io.File destination)
-
getTestDestination
public java.io.File getTestDestination()
-
setInEncoding
public void setInEncoding(java.lang.String value)
-
getInEncoding
public java.lang.String getInEncoding()
-
setOutEncoding
public void setOutEncoding(java.lang.String value)
-
getOutEncoding
public java.lang.String getOutEncoding()
-
setExcluded
public void setExcluded(java.lang.String excluded)
-
getExcluded
public java.lang.String getExcluded()
-
setUnknownVarAsFalse
public void setUnknownVarAsFalse(boolean flag)
-
getUnknownVarAsFalse
public boolean getUnknownVarAsFalse()
-
setProcessing
public void setProcessing(java.lang.String processing)
-
getProcessing
public java.lang.String getProcessing()
-
setDisableOut
public void setDisableOut(boolean value)
-
getDisableOut
public boolean getDisableOut()
-
setVerbose
public void setVerbose(boolean verbose)
-
getVerbose
public boolean getVerbose()
-
setKeepLines
public void setKeepLines(boolean keepLines)
-
getKeepLines
public boolean getKeepLines()
-
setAllowWhitespace
public void setAllowWhitespace(boolean flag)
-
getAllowWhitespace
public boolean getAllowWhitespace()
-
setRemoveComments
public void setRemoveComments(boolean value)
-
getRemoveComments
public boolean getRemoveComments()
-
makeSourceRootList
private java.lang.String makeSourceRootList()
-
replaceSourceRootByPreprocessingDestinationFolder
private void replaceSourceRootByPreprocessingDestinationFolder(PreprocessorContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
makePreprocessorContext
PreprocessorContext makePreprocessorContext(java.lang.String sourceFoldersInPreprocessorFormat) throws java.io.IOException
- Throws:
java.io.IOException
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
error
public void error(java.lang.String message)
Description copied from interface:PreprocessorLoggerLog an error message- Specified by:
errorin interfacePreprocessorLogger- Parameters:
message- the text to be output into the error log
-
info
public void info(java.lang.String message)
Description copied from interface:PreprocessorLoggerLog an information message- Specified by:
infoin interfacePreprocessorLogger- Parameters:
message- the text to be output into the information log
-
warning
public void warning(java.lang.String message)
Description copied from interface:PreprocessorLoggerLog a warning message- Specified by:
warningin interfacePreprocessorLogger- Parameters:
message- the text to be output into the warning log
-
debug
public void debug(java.lang.String message)
Description copied from interface:PreprocessorLoggerLog a debug message- Specified by:
debugin interfacePreprocessorLogger- Parameters:
message- the text to be output into the information log
-
-