Package adams.flow.maven
Class AbstractAdamsMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- adams.flow.maven.AbstractAdamsMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractJavaGeneratorMojo
,ClassListerJsonMojo
,ClassListerMojo
,OptionListerMojo
public abstract class AbstractAdamsMojo extends org.apache.maven.plugin.AbstractMojo
Abstract Mojo which collects common infrastructure, required and needed by all subclass Mojos in the adams maven plugin codebase. Based on jaxb2-maven-plugin code.- Author:
- Lennart Jörelid, FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description AbstractAdamsMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addResource(org.apache.maven.model.Resource resource)
Adds the supplied Resource to the project using the appropriate scope (i.e.void
execute()
protected void
execute(List<String> cmd)
Executes the command.protected org.sonatype.plexus.build.incremental.BuildContext
getBuildContext()
The Plexus BuildContext is used to identify files or directories modified since last build, implying functionality used to define if java generation must be performed again.protected List<String>
getClasspath()
Returns the classpath parts that can be used for launching a Java process.org.apache.maven.plugin.MojoExecution
getExecution()
protected abstract File
getOutputDirectory()
Retrieves the directory where the generated files should be written to.protected org.apache.maven.project.MavenProject
getProject()
protected abstract boolean
isReGenerationRequired()
protected void
logSystemPropertiesAndBasedir()
Prints out the system properties to the Maven Log at Debug level.protected abstract boolean
performExecution()
Implement this method to perform this Mojo's execution.protected abstract boolean
shouldExecutionBeSkipped()
Implement this method to check if this AbstractAdamsMojo should skip executing altogether.protected void
warnAboutIncorrectPluginConfiguration(String propertyName, String description)
Convenience method to invoke when some plugin configuration is incorrect.
-
-
-
Field Detail
-
NEWLINE
public static final String NEWLINE
Platform-independent newline control string.
-
-
Method Detail
-
addResource
protected abstract void addResource(org.apache.maven.model.Resource resource)
Adds the supplied Resource to the project using the appropriate scope (i.e. resource or testResource) depending on the exact implementation of this AbstractAdamsMojo.- Parameters:
resource
- The resource to add.
-
getBuildContext
protected final org.sonatype.plexus.build.incremental.BuildContext getBuildContext()
The Plexus BuildContext is used to identify files or directories modified since last build, implying functionality used to define if java generation must be performed again.- Returns:
- the active Plexus BuildContext.
-
getProject
protected final org.apache.maven.project.MavenProject getProject()
- Returns:
- The active MavenProject.
-
getExecution
public org.apache.maven.plugin.MojoExecution getExecution()
- Returns:
- The active MojoExecution.
-
execute
public final void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
- Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
-
shouldExecutionBeSkipped
protected abstract boolean shouldExecutionBeSkipped()
Implement this method to check if this AbstractAdamsMojo should skip executing altogether.- Returns:
true
to indicate that this AbstractAdamsMojo should bail out of its execute method.
-
isReGenerationRequired
protected abstract boolean isReGenerationRequired()
- Returns:
true
to indicate that this AbstractAdamsMojo should be run since its generated files were either stale or not present, andfalse
otherwise.
-
performExecution
protected abstract 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()
.- 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.
-
getOutputDirectory
protected abstract File getOutputDirectory()
Retrieves the directory where the generated files should be written to.- Returns:
- the directory where the generated files should be written to.
-
getClasspath
protected List<String> getClasspath() throws org.apache.maven.plugin.MojoExecutionException
Returns the classpath parts that can be used for launching a Java process.- Returns:
- the classpath parts
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
warnAboutIncorrectPluginConfiguration
protected void warnAboutIncorrectPluginConfiguration(String propertyName, String description)
Convenience method to invoke when some plugin configuration is incorrect. Will output the problem as a warning with some degree of log formatting.- Parameters:
propertyName
- The name of the problematic property.description
- The problem description.
-
logSystemPropertiesAndBasedir
protected void logSystemPropertiesAndBasedir()
Prints out the system properties to the Maven Log at Debug level.
-
-