Class AbstractMetaschemaMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- gov.nist.secauto.metaschema.maven.plugin.AbstractMetaschemaMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
GenerateSchemaMojo
,GenerateSourcesMojo
public abstract class AbstractMetaschemaMojo extends org.apache.maven.plugin.AbstractMojo
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]
excludes
A set of exclusion patterns used to prevent certain files from being processed.protected String[]
includes
A set of inclusion patterns used to select which metaschema are to be processed.protected File
staleFileDirectory
The directory where the staleFile is found.
-
Constructor Summary
Constructors Constructor Description AbstractMetaschemaMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.sonatype.plexus.build.incremental.BuildContext
getBuildContext()
The BuildContext is used to identify which files or directories were modified since last build.protected String
getEncoding()
Gets the file encoding to use for generated classes.protected org.apache.maven.project.MavenProject
getMavenProject()
Retrieve the Maven project context.org.apache.maven.plugin.MojoExecution
getMojoExecution()
Retrieve the mojo execution context.protected File
getOutputDirectory()
Retrieve the directory where generated classes will be stored.protected Stream<File>
getSources()
Retrieve a stream of Module file sources.protected File
getStaleFile()
Gets the staleFile for this execution.protected abstract String
getStaleFileName()
Get the name of the file that is used to detect staleness.protected boolean
isGenerationRequired()
Determine if code generation is required.protected void
setOutputDirectory(File outputDirectory)
Set the directory where generated classes will be stored.protected boolean
shouldExecutionBeSkipped()
Determine if the execution of this mojo should be skipped.-
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
-
-
-
Field Detail
-
staleFileDirectory
@Parameter(defaultValue="${project.build.directory}/metaschema", readonly=true, required=true) protected File staleFileDirectory
The directory where the staleFile is found. The staleFile is used to determine if re-generation of generated Java classes is needed, by recording when the last build occurred.
This directory is expected to be located within the
${project.build.directory}
, to ensure that code (re)generation occurs after cleaning the project.
-
includes
@Parameter protected String[] includes
A set of inclusion patterns used to select which metaschema are to be processed. By default, all files are processed.
-
-
Constructor Detail
-
AbstractMetaschemaMojo
public AbstractMetaschemaMojo()
-
-
Method Detail
-
getBuildContext
protected final org.sonatype.plexus.build.incremental.BuildContext getBuildContext()
The BuildContext is used to identify which files or directories were modified since last build. This is used to determine if Module-based generation must be performed again.- Returns:
- the active Plexus BuildContext.
-
getMavenProject
protected final org.apache.maven.project.MavenProject getMavenProject()
Retrieve the Maven project context.- Returns:
- The active MavenProject.
-
getMojoExecution
public org.apache.maven.plugin.MojoExecution getMojoExecution()
Retrieve the mojo execution context.- Returns:
- The active MojoExecution.
-
getOutputDirectory
protected File getOutputDirectory()
Retrieve the directory where generated classes will be stored.- Returns:
- the directory
-
setOutputDirectory
protected void setOutputDirectory(File outputDirectory)
Set the directory where generated classes will be stored.- Parameters:
outputDirectory
- the directory to use
-
getEncoding
protected final String getEncoding()
Gets the file encoding to use for generated classes.The algorithm for finding the encoding to use is as follows (where the first non-null value found is used for encoding):
- If the configuration property is explicitly given within the plugin's configuration, use that value.
- If the Maven property
project.build.sourceEncoding
is defined, use its value. - Otherwise use the value from the system property
file.encoding
.
- Returns:
- The encoding to be used by this AbstractJaxbMojo and its tools.
-
getSources
protected Stream<File> getSources()
Retrieve a stream of Module file sources.- Returns:
- the stream
-
shouldExecutionBeSkipped
protected boolean shouldExecutionBeSkipped()
Determine if the execution of this mojo should be skipped.- Returns:
true
if the mojo execution should be skipped, orfalse
otherwise
-
getStaleFileName
protected abstract String getStaleFileName()
Get the name of the file that is used to detect staleness.- Returns:
- the name
-
getStaleFile
protected final File getStaleFile()
Gets the staleFile for this execution.- Returns:
- the staleFile
-
isGenerationRequired
protected boolean isGenerationRequired()
Determine if code generation is required. This is done by comparing the last modified time of each Module source file against the stale file managed by this plugin.- Returns:
true
if the code generation is needed, orfalse
otherwise
-
-