public abstract class AbstractXsdGeneratorMojo extends AbstractJaxbMojo
Abstract superclass for Mojos that generate XSD files from annotated Java Sources.
This Mojo delegates execution to the schemagen
tool to perform the XSD file
generation. Moreover, the AbstractXsdGeneratorMojo provides an augmented processing
pipeline by optionally letting a set of NodeProcessors improve the 'vanilla' XSD files.
Modifier and Type | Field and Description |
---|---|
static List<Filter<File>> |
CLASS_INCLUDE_FILTERS
Filter list containing a PatternFileFilter including ".class" files.
|
protected boolean |
clearOutputDir
Removes all files from the output directory before running SchemaGenerator.
|
protected boolean |
createJavaDocAnnotations
If
true , Elements or Attributes in the generated XSD files will be annotated with any
JavaDoc found for their respective properties. |
protected String |
episodeFileName
Corresponding SchemaGen parameter:
episode . |
protected boolean |
generateEpisode
Deprecated.
|
protected JavaDocRenderer |
javaDocRenderer
A renderer used to create XML annotation text from JavaDoc comments found within the source code.
|
static Pattern |
SCHEMAGEN_EMITTED_FILENAME
Pattern matching the names of files emitted by the JAXB/JDK SchemaGenerator.
|
static List<Filter<File>> |
STANDARD_BYTECODE_EXCLUDE_FILTERS
Default exclude file name suffixes for testSources, used unless overridden by an
explicit configuration in the
testSourceExcludeSuffixes parameter. |
static JavaDocRenderer |
STANDARD_JAVADOC_RENDERER
The default JavaDocRenderer used unless another JavaDocRenderer should be used.
|
static List<String> |
SYSTEM_TOOLS_CLASSLOADER_PACKAGES
Specification for packages which must be loaded using the SystemToolClassLoader (and not in the plugin's
ThreadContext ClassLoader).
|
CONTAINS_WHITESPACE, extraFacets, locale, NEWLINE, PACKAGE_INFO_FILENAME, staleFileDirectory, STANDARD_EPISODE_FILENAME, STANDARD_EXCLUDE_FILTERS
Constructor and Description |
---|
AbstractXsdGeneratorMojo() |
Modifier and Type | Method and Description |
---|---|
protected abstract List<URL> |
getCompiledClassNames()
Finds a List containing URLs to compiled bytecode files within this Compilation Unit.
|
protected abstract List<URL> |
getSources()
Override this method to acquire a List holding all URLs to the SchemaGen Java sources for which this
AbstractXsdGeneratorMojo should generate Xml Schema Descriptor files.
|
protected abstract File |
getWorkDirectory() |
protected boolean |
isReGenerationRequired() |
protected boolean |
performExecution()
Implement this method to perform this Mojo's execution.
|
protected boolean |
shouldExecutionBeSkipped()
XSD schema files are not generated from POM projects or if no includes have been supplied.
|
addResource, execute, getBuildContext, getClasspath, getEncoding, getEpisodeFile, getExecution, getOutputDirectory, getProject, getStaleFile, getStaleFileName, logAndReturnToolArguments, logSystemPropertiesAndBasedir, warnAboutIncorrectPluginConfiguration
public static final Pattern SCHEMAGEN_EMITTED_FILENAME
Pattern matching the names of files emitted by the JAXB/JDK SchemaGenerator. According to the JAXB Schema Generator documentation:
There is no way to control the name of the generated schema files at this time.
public static final JavaDocRenderer STANDARD_JAVADOC_RENDERER
The default JavaDocRenderer used unless another JavaDocRenderer should be used.
javaDocRenderer
public static final List<Filter<File>> STANDARD_BYTECODE_EXCLUDE_FILTERS
Default exclude file name suffixes for testSources, used unless overridden by an
explicit configuration in the testSourceExcludeSuffixes
parameter.
final List<Filter<File>> schemagenTmp = new ArrayList<Filter<File>>();
schemagenTmp.addAll(AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS);
schemagenTmp.add(new PatternFileFilter(Arrays.asList("\\.java", "\\.scala", "\\.mdo"), false));
STANDARD_BYTECODE_EXCLUDE_FILTERS = Collections.unmodifiableList(schemagenTmp);
public static final List<Filter<File>> CLASS_INCLUDE_FILTERS
public static final List<String> SYSTEM_TOOLS_CLASSLOADER_PACKAGES
tools.jar
archive, in particular its exception types used to signal JAXB annotation Exceptions.ToolProvider.getSystemToolClassLoader()
@Deprecated @Parameter(defaultValue="true") protected boolean generateEpisode
From plugin version 2.4, this parameter will not be used. Instead, episode files are generated by default with all JAXB operations.
Starting with plugin version 2.4, use the parameter episodeFileName
to provide a custom
name of the generated episode File (or rely on the standard file name AbstractJaxbMojo.STANDARD_EPISODE_FILENAME
).
@Parameter protected String episodeFileName
Corresponding SchemaGen parameter: episode
.
Generate an episode file with the supplied name from this XSD generation, so that other schemas that rely
on this schema can be compiled later and rely on classes that are generated from this compilation.
The generated episode file is simply a JAXB customization file (but with vendor extensions), normally known
as a binding file with the suffix .xjb
.
If the episodeFileName
parameter is not given, the episode file name is synthesized on the form
"episode_" + executionID + ".xjb"
- typically something like episode_schemagen.xjb, but
it depends on the actual ID given in the execution element:
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
</execution>
</executions>
AbstractJaxbMojo.STANDARD_EPISODE_FILENAME
@Parameter(defaultValue="true") protected boolean createJavaDocAnnotations
If true
, Elements or Attributes in the generated XSD files will be annotated with any
JavaDoc found for their respective properties. If false
, no XML documentation annotations will be
generated in post-processing any results from the JAXB SchemaGenerator.
@Parameter protected JavaDocRenderer javaDocRenderer
A renderer used to create XML annotation text from JavaDoc comments found within the source code. Unless another implementation is provided, the standard JavaDocRenderer used is DefaultJavaDocRenderer.
DefaultJavaDocRenderer
@Parameter(defaultValue="true") protected boolean clearOutputDir
Removes all files from the output directory before running SchemaGenerator.
protected boolean shouldExecutionBeSkipped()
XSD schema files are not generated from POM projects or if no includes have been supplied.
Implement this method to check if this AbstractJaxbMojo should skip executing altogether.shouldExecutionBeSkipped
in class AbstractJaxbMojo
true
to indicate that this AbstractJaxbMojo should bail out of its execute method.protected boolean isReGenerationRequired()
isReGenerationRequired
in class AbstractJaxbMojo
true
to indicate that this AbstractJaxbMojo should be run since its generated files were
either stale or not present, and false
otherwise.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()
.
performExecution
in class AbstractJaxbMojo
true
if the timestamp of the stale file should be updated.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.protected abstract File getWorkDirectory()
protected abstract List<URL> getCompiledClassNames()
protected abstract List<URL> getSources()
getSources
in class AbstractJaxbMojo
Copyright © 2005–2018 MojoHaus. All rights reserved.