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 String
environmentClass
The ADAMS environment class to use.protected String
packageName
The 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 void
addGeneratedSourcesToProjectSourceRoot()
Adds any directories containing the generated classes to the appropriate Project compilation sources; eitherTestCompileSourceRoot
orCompileSourceRoot
depending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.protected abstract boolean
generateCode()
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 boolean
isReGenerationRequired()
Java generation is required if any of the file products is outdated/stale.protected boolean
performExecution()
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:
isReGenerationRequired
in classAbstractAdamsMojo
- Returns:
true
to indicate that this AbstractAdamsMojo should be run since its generated files were either stale or not present, andfalse
otherwise.
-
generateCode
protected abstract boolean generateCode() throws org.apache.maven.plugin.MojoExecutionException
Generates 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.MojoFailureException
Implement this method to perform this Mojo's execution. This method will only be called if
!shouldExecutionBeSkipped() && isReGenerationRequired()
.- Specified by:
performExecution
in classAbstractAdamsMojo
- Returns:
true
if 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 thesourceType
value.- 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; eitherTestCompileSourceRoot
orCompileSourceRoot
depending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.
-
-