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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected final class
class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]
A set of exclusion patterns used to prevent certain files from being processed.protected String[]
A set of inclusion patterns used to select which Metaschema modules are to be processed.protected File
The directory where the staleFile is found.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
createStaleFile
(File staleFile) void
execute()
Perform the generation operation.protected final org.sonatype.plexus.build.incremental.BuildContext
The BuildContext is used to identify which files or directories were modified since last build.protected List<IConstraintSet>
Get the configured collection of constraints.protected final String
Gets the file encoding to use for generated classes.protected final org.apache.maven.project.MavenProject
Retrieve the Maven project context.Retrieve a stream of Module file sources.getModulesToGenerateFor
(IBindingContext bindingContext, IModuleLoader.IModulePostProcessor modulePostProcessor) org.apache.maven.plugin.MojoExecution
Retrieve the mojo execution context.protected File
Retrieve the directory where generated classes will be stored.protected final List<org.apache.maven.artifact.Artifact>
protected final File
Gets the staleFile for this execution.protected abstract String
Get the name of the file that is used to detect staleness.protected boolean
Determine if code generation is required.protected IBindingContext
newBindingContext
(IModuleLoader.IModulePostProcessor modulePostProcessor) protected void
setOutputDirectory
(File outputDirectory) Set the directory where generated classes will be stored.protected boolean
Determine if the execution of this mojo should be skipped.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
staleFileDirectory
@Parameter(defaultValue="${project.build.directory}/metaschema", readonly=true, required=true) protected File staleFileDirectoryThe 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
A set of inclusion patterns used to select which Metaschema modules are to be processed. By default, all files are processed. -
excludes
A set of exclusion patterns used to prevent certain files from being processed. By default, this set is empty such that no files are excluded.
-
-
Constructor Details
-
AbstractMetaschemaMojo
public AbstractMetaschemaMojo()
-
-
Method Details
-
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
Retrieve the Maven project context.- Returns:
- The active MavenProject.
-
getPluginArtifacts
-
getMojoExecution
Retrieve the mojo execution context.- Returns:
- The active MojoExecution.
-
getOutputDirectory
Retrieve the directory where generated classes will be stored.- Returns:
- the directory
-
setOutputDirectory
Set the directory where generated classes will be stored.- Parameters:
outputDirectory
- the directory to use
-
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.
-
getModuleSources
Retrieve a stream of Module file sources.- Returns:
- the stream
-
newBindingContext
@NonNull protected IBindingContext newBindingContext(@NonNull IModuleLoader.IModulePostProcessor modulePostProcessor) throws IOException, MetaschemaException - Throws:
IOException
MetaschemaException
-
getConstraints
@NonNull protected List<IConstraintSet> getConstraints() throws org.apache.maven.plugin.MojoExecutionExceptionGet the configured collection of constraints.- Returns:
- the loaded constraints
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if an error occurred while loading the constraints
-
shouldExecutionBeSkipped
Determine if the execution of this mojo should be skipped.- Returns:
true
if the mojo execution should be skipped, orfalse
otherwise
-
getStaleFileName
Get the name of the file that is used to detect staleness.- Returns:
- the name
-
getStaleFile
Gets the staleFile for this execution.- Returns:
- the staleFile
-
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
-
getClassPath
protected Set<String> getClassPath() throws org.apache.maven.artifact.DependencyResolutionRequiredException- Throws:
org.apache.maven.artifact.DependencyResolutionRequiredException
-
getModulesToGenerateFor
@NonNull protected Set<IModule> getModulesToGenerateFor(@NonNull IBindingContext bindingContext, @NonNull IModuleLoader.IModulePostProcessor modulePostProcessor) throws MetaschemaException, IOException - Throws:
MetaschemaException
IOException
-
createStaleFile
protected void createStaleFile(@NonNull File staleFile) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
execute
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
generate
@NonNull protected abstract List<File> generate(@NonNull Set<IModule> modules) throws org.apache.maven.plugin.MojoExecutionException Perform the generation operation.- Parameters:
modules
- the modules to generate resources/sources for- Returns:
- the files generated during the operation
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if an error occurred while performing the generation operation
-