Class AbstractXsdGeneratorMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.jaxb2.AbstractJaxbMojo
-
- org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
SchemaGenerationMojo
,TestSchemaGenerationMojo
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.- Author:
- Lennart Jörelid
- See Also:
- The JAXB Reference Implementation
-
-
Field Summary
Fields Modifier and Type Field 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
Iftrue
, 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 thetestSourceExcludeSuffixes
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).-
Fields inherited from class org.codehaus.mojo.jaxb2.AbstractJaxbMojo
CONTAINS_WHITESPACE, extraFacets, locale, NEWLINE, PACKAGE_INFO_FILENAME, staleFileDirectory, STANDARD_EPISODE_FILENAME, STANDARD_EXCLUDE_FILTERS
-
-
Constructor Summary
Constructors Constructor Description AbstractXsdGeneratorMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.codehaus.mojo.jaxb2.AbstractJaxbMojo
addResource, execute, getBuildContext, getClasspath, getEncoding, getEpisodeFile, getExecution, getOutputDirectory, getProject, getStaleFile, getStaleFileName, logAndReturnToolArguments, logSystemPropertiesAndBasedir, warnAboutIncorrectPluginConfiguration
-
-
-
-
Field Detail
-
SCHEMAGEN_EMITTED_FILENAME
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.
-
STANDARD_JAVADOC_RENDERER
public static final JavaDocRenderer STANDARD_JAVADOC_RENDERER
The default JavaDocRenderer used unless another JavaDocRenderer should be used.
- Since:
- 2.0
- See Also:
javaDocRenderer
-
STANDARD_BYTECODE_EXCLUDE_FILTERS
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);
-
CLASS_INCLUDE_FILTERS
public static final List<Filter<File>> CLASS_INCLUDE_FILTERS
Filter list containing a PatternFileFilter including ".class" files.
-
SYSTEM_TOOLS_CLASSLOADER_PACKAGES
public static final List<String> SYSTEM_TOOLS_CLASSLOADER_PACKAGES
Specification for packages which must be loaded using the SystemToolClassLoader (and not in the plugin's ThreadContext ClassLoader). The SystemToolClassLoader is used by SchemaGen to process some stuff from thetools.jar
archive, in particular its exception types used to signal JAXB annotation Exceptions.- See Also:
ToolProvider.getSystemToolClassLoader()
-
generateEpisode
@Deprecated @Parameter(defaultValue="true") protected boolean generateEpisode
Deprecated.Deprecated - will be removed in a future releaseFrom 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 nameAbstractJaxbMojo.STANDARD_EPISODE_FILENAME
).- Since:
- 2.0
-
episodeFileName
@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>
- Since:
- 2.4
- See Also:
AbstractJaxbMojo.STANDARD_EPISODE_FILENAME
-
createJavaDocAnnotations
@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. Iffalse
, no XML documentation annotations will be generated in post-processing any results from the JAXB SchemaGenerator.- Since:
- 2.0
-
javaDocRenderer
@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.
- Since:
- 2.0
- See Also:
DefaultJavaDocRenderer
-
clearOutputDir
@Parameter(defaultValue="true") protected boolean clearOutputDir
Removes all files from the output directory before running SchemaGenerator.
- Since:
- 2.0
-
-
Method Detail
-
shouldExecutionBeSkipped
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.- Specified by:
shouldExecutionBeSkipped
in classAbstractJaxbMojo
- Returns:
true
to indicate that this AbstractJaxbMojo should bail out of its execute method.
-
isReGenerationRequired
protected boolean isReGenerationRequired()
- Specified by:
isReGenerationRequired
in classAbstractJaxbMojo
- Returns:
true
to indicate that this AbstractJaxbMojo should be run since its generated files were either stale or not present, andfalse
otherwise.
-
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 classAbstractJaxbMojo
- 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.
-
getWorkDirectory
protected abstract File getWorkDirectory()
- Returns:
- The working directory to which the SchemaGenerator should initially copy all its generated files, including bytecode files, compiled from java sources.
-
getCompiledClassNames
protected abstract List<URL> getCompiledClassNames()
Finds a List containing URLs to compiled bytecode files within this Compilation Unit. Typically this equals the resolved files under the project's build directories, plus any JAR artifacts found on the classpath.- Returns:
- A non-null List containing URLs to bytecode files within this compilation unit. Typically this equals the resolved files under the project's build directories, plus any JAR artifacts found on the classpath.
-
getSources
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.- Specified by:
getSources
in classAbstractJaxbMojo
- Returns:
- A non-null List holding URLs to sources for the XSD generation.
-
-