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 List<String>compilerArgsArguments to be passed to the compiler.
(see maven-compiler-plugin)protected StringcompilerArgumentSets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin)protected StringencodingSource file encode.protected List<org.apache.maven.shared.model.fileset.FileSet>filesetsThe list of file sets.
If set the source directory is ignored.protected List<AbstractTentackleProcessor>processorsAnnotation processors.protected booleanshowCompileOutputShow compile output.-
Fields inherited from class org.tentackle.maven.AbstractTentackleMojo
charset, JDK_TOOLCHAIN, minLogLevel, resourceDirs, verbosity, verbosityLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractTentackleAnnotationProcessingMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProcessor(AbstractTentackleProcessor processor)Adds an annotation processor.protected voidcleanupProcessors(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 String[]filterFileNames(String dirName, String[] fileNames)Filters the files to be processed.
If overridden, allows to skip the annotation processing.StringgetCompileErrorLog()Gets the compiler error log.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(AbstractTentackleProcessor processor, File srcDir)Initializes a processor.protected voidinitializeProcessors(File srcDir)Initializes all processors.voidsetMojoParameters(File sourceDir, List<String> classpathElements)Sets the mojo parameters.protected booleanvalidate()Checks the configuration.-
Methods inherited from class org.tentackle.maven.AbstractTentackleMojo
createPackageMap, determineEncoding, determineJavaToolVersion, determineVerbosity, execute, findResourceDirs, finishExecute, getCanonicalPath, getHostName, getMajorVersion, getMavenProject, getMavenSession, getMojoExecution, getPathRelativeToBasedir, getResourceDirName, getSettings, getSettingsDecrypter, getToolchain, getToolchain, getToolchain, getToolchainManager, getToolFinder, installJavaLoggingHandler, isExecutionRecursive, isSkippedByDefault, loadResourceFileIntoString, prepareExecute
-
-
-
-
Field Detail
-
showCompileOutput
@Parameter(defaultValue="${tentackle.showCompileOutput}") protected boolean showCompileOutputShow compile output.
-
encoding
@Parameter(defaultValue="${project.build.sourceEncoding}") protected String encodingSource file encode.
-
compilerArgs
@Parameter protected List<String> compilerArgs
Arguments to be passed to the compiler.
(see maven-compiler-plugin)
-
compilerArgument
@Parameter protected String compilerArgument
Sets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin)
-
filesets
@Parameter protected List<org.apache.maven.shared.model.fileset.FileSet> filesets
The list of file sets.
If set the source directory is ignored.
-
processors
protected List<AbstractTentackleProcessor> processors
Annotation processors.
-
-
Method Detail
-
setMojoParameters
public void setMojoParameters(File sourceDir, List<String> classpathElements) throws org.apache.maven.plugin.MojoFailureException
Sets 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 ClassLoader getProcessingClassloader()
Gets a classloader that searches also in the classpath elements of the project.- Returns:
- the classloader
-
addProcessor
public void addProcessor(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 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(AbstractTentackleProcessor processor, File srcDir) throws org.apache.maven.plugin.MojoFailureException
Initializes a processor.- Parameters:
processor- the annotation processorsrcDir- the source dir- Throws:
org.apache.maven.plugin.MojoFailureException- if initialization failed
-
initializeProcessors
protected void initializeProcessors(File srcDir) throws org.apache.maven.plugin.MojoFailureException
Initializes all processors.- Parameters:
srcDir- the current file set directory- Throws:
org.apache.maven.plugin.MojoFailureException- if initialization failed
-
cleanupProcessors
protected void cleanupProcessors(File srcDir) throws org.apache.maven.plugin.MojoFailureException
Cleans up the processors.- Parameters:
srcDir- the current file set directory- Throws:
org.apache.maven.plugin.MojoFailureException- if cleanup failed
-
filterFileNames
protected String[] filterFileNames(String dirName, 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
-
-