Package org.tentackle.maven
Class AbstractTentackleAnnotationProcessingMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.tentackle.maven.AbstractTentackleMojo
-
- org.tentackle.maven.AbstractTentackleAnnotationProcessingMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
public abstract class AbstractTentackleAnnotationProcessingMojo extends AbstractTentackleMojo
Generates code and meta-information prior to wurbeling and compiling the sources.Picks up all annotations annotated with
org.tentackle.common.Analyze.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>compilerArgsArguments to be passed to the compiler.
(see maven-compiler-plugin)protected java.lang.StringcompilerArgumentSets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin)protected java.lang.StringencodingSource file encode.protected java.util.List<org.apache.maven.shared.model.fileset.FileSet>filesetsThe list of file sets.
If set the source directory is ignored.protected java.util.List<org.tentackle.buildsupport.AbstractTentackleProcessor>processorsAnnotation processors.protected booleanshowCompileOutputShow compile output.-
Fields inherited from class org.tentackle.maven.AbstractTentackleMojo
charset, JDK_TOOLCHAIN, resourceDirs, verbosity, verbosityLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractTentackleAnnotationProcessingMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProcessor(org.tentackle.buildsupport.AbstractTentackleProcessor processor)Adds an annotation processor.protected voidcleanupProcessors(java.io.File srcDir)Cleans up the processors.protected voidcreateMissingDirs()Creates any missing directories.voidexecuteImpl()Implements the execution.
TT-mojos must override this method instead ofAbstractTentackleMojo.execute().protected java.lang.String[]filterFileNames(java.lang.String dirName, java.lang.String[] fileNames)Filters the files to be processed.
If overridden, allows to skip the annotation processing.java.lang.StringgetCompileErrorLog()Gets the compiler error log.java.lang.ClassLoadergetProcessingClassloader()Gets a classloader that searches also in the classpath elements of the project.intgetTotalCompileErrors()Gets the number of compile errors.intgetTotalErrors()Gets the number of analyze errors.protected voidinitializeProcessor(org.tentackle.buildsupport.AbstractTentackleProcessor processor, java.io.File srcDir)Initializes a processor.protected voidinitializeProcessors(java.io.File srcDir)Initializes all processors.voidsetMojoParameters(java.io.File sourceDir, java.util.List<java.lang.String> classpathElements)Sets the mojo parameters.protected booleanvalidate()Checks the configuration.-
Methods inherited from class org.tentackle.maven.AbstractTentackleMojo
determineEncoding, determineJavaToolVersion, determineVerbosity, execute, findResourceDirs, finishExecute, getCanonicalPath, getMajorVersion, getMavenProject, getMavenSession, getMojoExecution, getPathRelativeToBasedir, getResourceDirName, getSettings, getSettingsDecrypter, getToolchain, getToolchain, getToolchain, getToolchainManager, getToolFinder, isExecutionRecursive, isSkippedByDefault, loadResourceFileIntoString, prepareExecute
-
-
-
-
Field Detail
-
showCompileOutput
@Parameter(defaultValue="${tentackle.showCompileOutput}") protected boolean showCompileOutputShow compile output.
-
encoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected java.lang.String encodingSource file encode.
-
compilerArgs
@Parameter protected java.util.List<java.lang.String> compilerArgs
Arguments to be passed to the compiler.
(see maven-compiler-plugin)
-
compilerArgument
@Parameter protected java.lang.String compilerArgument
Sets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin)
-
filesets
@Parameter protected java.util.List<org.apache.maven.shared.model.fileset.FileSet> filesets
The list of file sets.
If set the source directory is ignored.
-
processors
protected java.util.List<org.tentackle.buildsupport.AbstractTentackleProcessor> processors
Annotation processors.
-
-
Method Detail
-
setMojoParameters
public void setMojoParameters(java.io.File sourceDir, java.util.List<java.lang.String> classpathElements) throws org.apache.maven.plugin.MojoFailureExceptionSets the mojo parameters.- Parameters:
sourceDir- the directory holding the sources to be processedclasspathElements- the mavenProject classpath- Throws:
org.apache.maven.plugin.MojoFailureException- if classloader could not be created
-
getProcessingClassloader
public java.lang.ClassLoader getProcessingClassloader()
Gets a classloader that searches also in the classpath elements of the project.- Returns:
- the classloader
-
addProcessor
public void addProcessor(org.tentackle.buildsupport.AbstractTentackleProcessor processor)
Adds an annotation processor.- Parameters:
processor- the annotation processor
-
createMissingDirs
protected void createMissingDirs()
Creates any missing directories.
-
getTotalCompileErrors
public int getTotalCompileErrors()
Gets the number of compile errors.- Returns:
- 0 if analyze phase completed, > 0 if analyze info may be incomplete due to errors
-
getCompileErrorLog
public java.lang.String getCompileErrorLog()
Gets the compiler error log.- Returns:
- the log, empty if no errors
-
getTotalErrors
public int getTotalErrors()
Gets the number of analyze errors.- Returns:
- the error count
-
executeImpl
public void executeImpl() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionDescription copied from class:AbstractTentackleMojoImplements the execution.
TT-mojos must override this method instead ofAbstractTentackleMojo.execute(). This method is only invoked if validation succeeds.- Specified by:
executeImplin classAbstractTentackleMojo- Throws:
org.apache.maven.plugin.MojoExecutionException- if an unexpected problem occursorg.apache.maven.plugin.MojoFailureException- if an expected problem (such as a compilation failure) occurs- See Also:
AbstractTentackleMojo.prepareExecute()
-
validate
protected boolean validate() throws org.apache.maven.plugin.MojoExecutionExceptionDescription copied from class:AbstractTentackleMojoChecks the configuration.- Overrides:
validatein classAbstractTentackleMojo- Returns:
- true if continue with execution, false to skip
- Throws:
org.apache.maven.plugin.MojoExecutionException- if validation failed
-
initializeProcessor
protected void initializeProcessor(org.tentackle.buildsupport.AbstractTentackleProcessor processor, java.io.File srcDir) throws org.apache.maven.plugin.MojoFailureExceptionInitializes a processor.- Parameters:
processor- the annotation processorsrcDir- the source dir- Throws:
org.apache.maven.plugin.MojoFailureException- if initialization failed
-
initializeProcessors
protected void initializeProcessors(java.io.File srcDir) throws org.apache.maven.plugin.MojoFailureExceptionInitializes all processors.- Parameters:
srcDir- the current file set directory- Throws:
org.apache.maven.plugin.MojoFailureException- if initialization failed
-
cleanupProcessors
protected void cleanupProcessors(java.io.File srcDir) throws org.apache.maven.plugin.MojoFailureExceptionCleans up the processors.- Parameters:
srcDir- the current file set directory- Throws:
org.apache.maven.plugin.MojoFailureException- if cleanup failed
-
filterFileNames
protected java.lang.String[] filterFileNames(java.lang.String dirName, java.lang.String[] fileNames)Filters the files to be processed.
If overridden, allows to skip the annotation processing.- Parameters:
dirName- the base directoryfileNames- the file names relative to the directory- Returns:
- the filtered file names
-
-