Package adams.flow.maven
Class AbstractJavaGeneratorMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- adams.flow.maven.AbstractAdamsMojo
-
- adams.flow.maven.AbstractJavaGeneratorMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
ActorExecutionMojo,ApplyActorMojo
public abstract class AbstractJavaGeneratorMojo extends AbstractAdamsMojo
Abstract superclass for Mojos generating Java source
Based on jaxb2-maven-plugin code.- Author:
- Lennart Jörelid, FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected StringenvironmentClassThe ADAMS environment class to use.protected StringpackageNameThe package under which the source files will be generated.-
Fields inherited from class adams.flow.maven.AbstractAdamsMojo
NEWLINE
-
-
Constructor Summary
Constructors Constructor Description AbstractJavaGeneratorMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddGeneratedSourcesToProjectSourceRoot()Adds any directories containing the generated classes to the appropriate Project compilation sources; eitherTestCompileSourceRootorCompileSourceRootdepending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.protected abstract booleangenerateCode()Generates the actual code.protected abstract List<URL>getSources()Override this method to acquire a List holding all URLs to the sources for which this AbstractJavaGeneratorMojo should generate Java files.protected booleanisReGenerationRequired()Java generation is required if any of the file products is outdated/stale.protected booleanperformExecution()Implement this method to perform this Mojo's execution.-
Methods inherited from class adams.flow.maven.AbstractAdamsMojo
addResource, execute, execute, getBuildContext, getClasspath, getExecution, getOutputDirectory, getProject, logSystemPropertiesAndBasedir, shouldExecutionBeSkipped, warnAboutIncorrectPluginConfiguration
-
-
-
-
Method Detail
-
isReGenerationRequired
protected boolean isReGenerationRequired()
Java generation is required if any of the file products is outdated/stale.
- Specified by:
isReGenerationRequiredin classAbstractAdamsMojo- Returns:
trueto indicate that this AbstractAdamsMojo should be run since its generated files were either stale or not present, andfalseotherwise.
-
generateCode
protected abstract boolean generateCode() throws org.apache.maven.plugin.MojoExecutionExceptionGenerates the actual code.- Returns:
- true if successfully generated
- Throws:
org.apache.maven.plugin.MojoExecutionException- if code generation fails
-
performExecution
protected boolean performExecution() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionImplement this method to perform this Mojo's execution. This method will only be called if
!shouldExecutionBeSkipped() && isReGenerationRequired().- Specified by:
performExecutionin classAbstractAdamsMojo- Returns:
trueif the timestamp of the stale file should be updated.- Throws:
org.apache.maven.plugin.MojoExecutionException- if an unexpected problem occurs. Throwing this exception causes a "BUILD ERROR" message to be displayed.org.apache.maven.plugin.MojoFailureException- if an expected problem (such as a compilation failure) occurs. Throwing this exception causes a "BUILD FAILURE" message to be displayed.
-
getSources
protected abstract List<URL> getSources()
Override this method to acquire a List holding all URLs to the sources for which this AbstractJavaGeneratorMojo should generate Java files. Sources are assumed to be in the form given by thesourceTypevalue.- Returns:
- A non-null List holding URLs to sources for the code generation.
-
addGeneratedSourcesToProjectSourceRoot
protected abstract void addGeneratedSourcesToProjectSourceRoot()
Adds any directories containing the generated classes to the appropriate Project compilation sources; eitherTestCompileSourceRootorCompileSourceRootdepending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.
-
-