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
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
FieldsModifier and TypeFieldDescriptionArguments to be passed to the compiler.
(see maven-compiler-plugin)protected StringSets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin)protected StringSource file encode.protected List<org.apache.maven.shared.model.fileset.FileSet>The list of file sets.
If set the source directory is ignored.protected List<AbstractTentackleProcessor>Annotation processors.protected booleanShow compile output.Fields inherited from class org.tentackle.maven.AbstractTentackleMojo
charset, JDK_TOOLCHAIN, minLogLevel, verbosity, verbosityLevelFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddProcessor(AbstractTentackleProcessor processor) Adds an annotation processor.protected voidcleanupProcessors(File srcDir) Cleans up the processors.protected voidCreates any missing directories.voidImplements 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.Gets the compiler error log.Gets a classloader that searches also in the classpath elements of the project.intGets the number of compile errors.intGets 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
createFileSetManager, createPackageMap, determineEncoding, determineJavaToolVersion, determineVerbosity, execute, finishExecute, getCanonicalPath, getHostName, getIncludedFiles, getJavaHome, getMajorVersion, getMavenProject, getMavenSession, getMojoExecution, getPathRelativeToBasedir, getResourceDir, getResourceDirs, getSettings, getSettingsDecrypter, getToolchain, getToolchain, getToolchain, getToolchainManager, getToolFinder, installJavaLoggingHandler, isExecutionRecursive, isSkippedByDefault, loadResourceFileIntoString, prepareExecute, toDescriptorNameMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
showCompileOutput
@Parameter(defaultValue="${tentackle.showCompileOutput}") protected boolean showCompileOutputShow compile output. -
encoding
Source file encode. -
compilerArgs
Arguments to be passed to the compiler.
(see maven-compiler-plugin) -
compilerArgument
Sets the unformatted single argument string to be passed to the compiler.
(see maven-compiler-plugin) -
filesets
The list of file sets.
If set the source directory is ignored. -
processors
Annotation processors.
-
-
Constructor Details
-
AbstractTentackleAnnotationProcessingMojo
public AbstractTentackleAnnotationProcessingMojo()
-
-
Method Details
-
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
Gets a classloader that searches also in the classpath elements of the project.- Returns:
- the classloader
-
addProcessor
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
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:
-
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
Cleans up the processors.- Parameters:
srcDir- the current file set directory- Throws:
org.apache.maven.plugin.MojoFailureException- if cleanup failed
-
filterFileNames
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
-