Class PreprocessorMojo

  • All Implemented Interfaces:
    PreprocessorLogger, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="preprocess",
          defaultPhase=GENERATE_SOURCES,
          threadSafe=true,
          requiresProject=true)
    public class PreprocessorMojo
    extends org.apache.maven.plugin.AbstractMojo
    implements PreprocessorLogger
    The 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 boolean careForLastNextLine
      Be 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[] cfgFiles
      List of external configuration files.
      private boolean clear
      Clear the destination folder before preprocessing (if it exists).
      private boolean compareDestination
      Flag to compare generated content with existing file and if it is the same then to not override the file, it brings overhead
      private java.util.List<java.lang.String> compileSourceRoots
      The Project source roots for non-test mode.
      private java.io.File destination
      The Destination folder where generated sources will be placed in non-test mode.
      private boolean disableOut
      Make dry run of the preprocessor without any saving of result.
      private java.lang.String excluded
      List of file extensions to be excluded from the preprocessing process.
      private java.util.Properties globalVars
      List of global preprocessing variables.
      private java.lang.String inEncoding
      The Input text encoding to be used for preprocessing, by default it uses defined in project properties.
      private boolean keepLines
      Disable removing lines from preprocessed files, it allows to keep line numeration similar to original sources.
      private boolean keepSrcRoot
      Disable overriding of the source root folders for maven project after preprocessing.
      private java.lang.String outEncoding
      The Encoding for preprocessed text output, by default it uses defined in project properties.
      private java.lang.String processing
      List of file extensions to be preprocessed.
      private org.apache.maven.project.MavenProject project
      The Maven Project to be preprocessed.
      private boolean removeComments
      Remove all Java like commentaries from preprocessed sources.
      private java.lang.String source
      The 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> testCompileSourceRoots
      The Project source roots for test mode.
      private java.io.File testDestination
      Destination folder where generated sources will be placed in test-mode.
      private boolean useTestSources
      Allow usage of the preprocessor for test sources (since 5.3.4 version).
      private boolean verbose
      Turn on the verbose mode for preprocessing process.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Field Detail

      • compileSourceRoots

        @Parameter(name="compileSourceRoots",
                   defaultValue="${project.compileSourceRoots}",
                   required=true,
                   readonly=true)
        private java.util.List<java.lang.String> compileSourceRoots
        The Project source roots for non-test mode.
      • testCompileSourceRoots

        @Parameter(name="testCompileSourceRoots",
                   defaultValue="${project.testCompileSourceRoots}",
                   required=true,
                   readonly=true)
        private java.util.List<java.lang.String> testCompileSourceRoots
        The Project source roots for test mode.
      • project

        @Parameter(defaultValue="${project}",
                   required=true,
                   readonly=true)
        private org.apache.maven.project.MavenProject project
        The Maven Project to be preprocessed.
      • source

        @Parameter(name="source",
                   defaultValue="")
        private java.lang.String source
        The 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.
      • destination

        @Parameter(name="destination",
                   defaultValue="${project.build.directory}/generated-sources/preprocessed")
        private java.io.File destination
        The Destination folder where generated sources will be placed in non-test mode.
      • testDestination

        @Parameter(name="testDestination",
                   defaultValue="${project.build.directory}/generated-test-sources/preprocessed")
        private java.io.File testDestination
        Destination folder where generated sources will be placed in test-mode.
      • inEncoding

        @Parameter(name="inEncoding",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String inEncoding
        The Input text encoding to be used for preprocessing, by default it uses defined in project properties.
      • outEncoding

        @Parameter(name="outEncoding",
                   defaultValue="${project.build.sourceEncoding}")
        private java.lang.String outEncoding
        The Encoding for preprocessed text output, by default it uses defined in project properties.
      • excluded

        @Parameter(name="excluded")
        private java.lang.String excluded
        List of file extensions to be excluded from the preprocessing process. By default excluded XML files.
      • processing

        @Parameter(name="processing")
        private java.lang.String processing
        List of file extensions to be preprocessed. By default java,txt,htm,html
      • disableOut

        @Parameter(name="disableOut",
                   defaultValue="false")
        private boolean disableOut
        Make dry run of the preprocessor without any saving of result.
      • verbose

        @Parameter(name="verbose",
                   defaultValue="false")
        private boolean verbose
        Turn on the verbose mode for preprocessing process.
      • clear

        @Parameter(name="clear",
                   defaultValue="false")
        private boolean clear
        Clear the destination folder before preprocessing (if it exists).
      • careForLastNextLine

        @Parameter(name="careForLastNextLine",
                   defaultValue="false")
        private boolean careForLastNextLine
        Be 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(name="keepSrcRoot",
                   defaultValue="false")
        private boolean keepSrcRoot
        Disable overriding of the source root folders for maven project after preprocessing.
      • removeComments

        @Parameter(name="removeComments",
                   defaultValue="false")
        private boolean removeComments
        Remove all Java like commentaries from preprocessed sources.
      • globalVars

        @Parameter(name="globalVars")
        private java.util.Properties globalVars
        List of global preprocessing variables.
      • cfgFiles

        @Parameter(name="cfgFiles")
        private java.io.File[] cfgFiles
        List of external configuration files.
      • keepLines

        @Parameter(name="keepLines",
                   defaultValue="true")
        private boolean keepLines
        Disable removing lines from preprocessed files, it allows to keep line numeration similar to original sources.
      • useTestSources

        @Parameter(name="useTestSources",
                   defaultValue="false")
        private boolean useTestSources
        Allow usage of the preprocessor for test sources (since 5.3.4 version).
      • compareDestination

        @Parameter(name="compareDestination",
                   defaultValue="false")
        private boolean compareDestination
        Flag to compare generated content with existing file and if it is the same then to not override the file, it brings overhead
    • Constructor Detail

      • PreprocessorMojo

        public PreprocessorMojo()
    • Method Detail

      • 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​(java.io.File[] files)
      • getCfgFiles

        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()
      • 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()
      • 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()
                                             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:
        execute in interface org.apache.maven.plugin.Mojo
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • error

        public void error​(java.lang.String message)
        Description copied from interface: PreprocessorLogger
        Log an error message
        Specified by:
        error in interface PreprocessorLogger
        Parameters:
        message - the text to be output into the error log
      • info

        public void info​(java.lang.String message)
        Description copied from interface: PreprocessorLogger
        Log an information message
        Specified by:
        info in interface PreprocessorLogger
        Parameters:
        message - the text to be output into the information log
      • warning

        public void warning​(java.lang.String message)
        Description copied from interface: PreprocessorLogger
        Log a warning message
        Specified by:
        warning in interface PreprocessorLogger
        Parameters:
        message - the text to be output into the warning log
      • debug

        public void debug​(java.lang.String message)
        Description copied from interface: PreprocessorLogger
        Log a debug message
        Specified by:
        debug in interface PreprocessorLogger
        Parameters:
        message - the text to be output into the information log