public abstract class AbstractJavaGeneratorMojo extends AbstractJaxbMojo
Abstract superclass for Mojos generating Java source or binaries from XML schema(s) by invoking the JAXB XJC binding compiler. Most of the Configuration options for the AbstractJavaGeneratorMojo are set or copied to the XJC directly; refer to their documentation in the JAXB Reference Implementation site.
Modifier and Type | Field and Description |
---|---|
protected boolean |
addGeneratedAnnotation
Corresponding XJC parameter:
mark-generated . |
protected List<String> |
arguments
Deprecated.
This should be removed in the 2.0+ release, as all arguments should be handled by other parameters.
|
protected File |
catalog
Corresponding XJC parameter:
catalog . |
protected boolean |
clearOutputDir
Removes all files from the output directory before running XJC.
|
protected boolean |
extension
Corresponding XJC parameter:
extension . |
protected boolean |
failOnNoSchemas
Fails the Mojo execution if no XSDs/schemas are found.
|
protected boolean |
generateEpisode
Corresponding XJC parameter:
episode . |
protected boolean |
laxSchemaValidation
Corresponding XJC parameter:
nv . |
protected boolean |
noGeneratedHeaderComments
Corresponding XJC parameter:
no-header . |
protected boolean |
noPackageLevelAnnotations
Corresponding XJC parameter:
npa . |
protected String |
packageName
Corresponding XJC parameter:
p . |
protected boolean |
quiet
Corresponding XJC parameter:
quiet . |
protected boolean |
readOnly
Corresponding XJC parameter:
readOnly . |
protected org.apache.maven.settings.Settings |
settings
Sets the HTTP/HTTPS proxy to be used by the XJC, on the format
[user[:password]@]proxyHost[:proxyPort] . |
protected SourceContentType |
sourceType
Defines the content type of sources for the XJC.
|
protected String |
target
Corresponding XJC parameter:
target . |
protected boolean |
verbose
Corresponding XJC parameter:
verbose . |
protected String |
xsdPathWithinArtifact
If provided, this parameter indicates that the XSDs used by XJC to generate Java code should be
copied into the resulting artifact of this project (the JAR, WAR or whichever artifact type is generated).
|
CONTAINS_WHITESPACE, extraFacets, locale, NEWLINE, PACKAGE_INFO_FILENAME, staleFileDirectory, STANDARD_EPISODE_FILENAME, STANDARD_EXCLUDE_FILTERS
Constructor and Description |
---|
AbstractJavaGeneratorMojo() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addGeneratedSourcesToProjectSourceRoot()
Adds any directories containing the generated XJC classes to the appropriate Project compilation sources;
either
TestCompileSourceRoot or CompileSourceRoot depending on the exact Mojo implementation
of this AbstractJavaGeneratorMojo. |
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 AbstractJavaGeneratorMojo.
|
protected abstract List<URL> |
getSources()
Override this method to acquire a List holding all URLs to the JAXB sources for which this
AbstractJavaGeneratorMojo should generate Java files.
|
protected abstract List<File> |
getSourceXJBs()
Override this method to retrieve a list of Files to all XJB files for which this
AbstractJavaGeneratorMojo should generate Java files.
|
protected boolean |
isReGenerationRequired()
Java generation is required if any of the file products is outdated/stale.
|
protected boolean |
performExecution()
Implement this method to perform this Mojo's execution.
|
execute, getBuildContext, getClasspath, getEncoding, getEpisodeFile, getExecution, getOutputDirectory, getProject, getStaleFile, getStaleFileName, logAndReturnToolArguments, logSystemPropertiesAndBasedir, shouldExecutionBeSkipped, warnAboutIncorrectPluginConfiguration
@Parameter protected File catalog
Corresponding XJC parameter: catalog
.
Specify catalog files to resolve external entity references. Supports TR9401, XCatalog, and OASIS XML Catalog format.
@Parameter(defaultValue="true") protected boolean generateEpisode
Corresponding XJC parameter: episode
.
Generate an episode file from this compilation, 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 really just a JAXB customization file (but with vendor extensions.)
If this parameter is true
, the episode file generated is called META-INF/sun-jaxb.episode
,
and included in the artifact.
AbstractJaxbMojo.STANDARD_EPISODE_FILENAME
@Parameter(defaultValue="${settings}", readonly=true) protected org.apache.maven.settings.Settings settings
Sets the HTTP/HTTPS proxy to be used by the XJC, on the format
[user[:password]@]proxyHost[:proxyPort]
.
All information is retrieved from the active proxy within the standard maven settings file.
@Parameter(defaultValue="XmlSchema") protected SourceContentType sourceType
Defines the content type of sources for the XJC. To simplify usage of the JAXB2 maven plugin, all source files are assumed to have the same type of content.
This parameter replaces the previous multiple-choice boolean configuration options for the jaxb2-maven-plugin (i.e. dtd, xmlschema, relaxng, relaxng-compact, wsdl), and corresponds to setting one of those flags as an XJC argument.
@Parameter(defaultValue="false") protected boolean noPackageLevelAnnotations
Corresponding XJC parameter: npa
.
Suppress the generation of package level annotations into package-info.java
.
Using this switch causes the generated code to internalize those annotations into the other
generated classes.
@Parameter(defaultValue="false") protected boolean noGeneratedHeaderComments
Corresponding XJC parameter: no-header
.
Suppress the generation of a file header comment that includes some note and timestamp. Using this makes the generated code more diff-friendly.
@Parameter(defaultValue="false") protected boolean addGeneratedAnnotation
Corresponding XJC parameter: mark-generated
.
This feature causes all of the generated code to have @Generated
annotation.
@Parameter(defaultValue="false") protected boolean laxSchemaValidation
Corresponding XJC parameter: nv
.
By default, the XJC binding compiler performs strict validation of the source schema before processing it. Use this option to disable strict schema validation. This does not mean that the binding compiler will not perform any validation, it simply means that it will perform less-strict validation.
@Parameter(defaultValue="false") protected boolean quiet
Corresponding XJC parameter: quiet
.
Suppress compiler output, such as progress information and warnings.
@Parameter(property="xjc.verbose", defaultValue="false") protected boolean verbose
Corresponding XJC parameter: verbose
.
Tells XJC to be extra verbose, such as printing informational messages or displaying stack traces.
@Parameter(defaultValue="false") protected boolean extension
Corresponding XJC parameter: extension
.
By default, the XJC binding compiler strictly enforces the rules outlined in the Compatibility chapter of the JAXB Specification. Appendix E.2 defines a set of W3C XML Schema features that are not completely supported by JAXB v1.0. In some cases, you may be allowed to use them in the "-extension" mode enabled by this switch. In the default (strict) mode, you are also limited to using only the binding customizations defined in the specification.
@Parameter(defaultValue="true") protected boolean failOnNoSchemas
@Parameter(defaultValue="true") protected boolean clearOutputDir
Removes all files from the output directory before running XJC.
@Parameter(defaultValue="false") protected boolean readOnly
Corresponding XJC parameter: readOnly
.
By default, the XJC binding compiler does not write-protect the Java source files it generates. Use this option to force the XJC binding compiler to mark the generated Java sources read-only.
@Parameter(property="xjc.arguments") protected List<String> arguments
List of ordered extra arguments to the XJC command. Each extra argument is interpreted as a word, intended to be copied verbatim to the XJC argument list with spaces in between:
<configuration>
...
<arguments>
<argument>-Xfluent-api</argument>
<argument>somefile</argument>
</arguments>
</configuration>
The arguments configured above yields the following extra arguments to the XJC command:
-Xfluent-api -episode somefile
@Parameter protected String packageName
Corresponding XJC parameter: p
.
The package under which the source files will be generated. Quoting the XJC documentation: "Specifying a target package via this command-line option overrides any binding customization for package name and the default package name algorithm defined in the specification".
@Parameter protected String target
Corresponding XJC parameter: target
.
Permitted values: "2.0"
and "2.1"
. Avoid generating code that relies on JAXB newer than the
version given. This will allow the generated code to run with JAXB 2.0 runtime (such as JavaSE 6.)
@Parameter protected String xsdPathWithinArtifact
If provided, this parameter indicates that the XSDs used by XJC to generate Java code should be
copied into the resulting artifact of this project (the JAR, WAR or whichever artifact type is generated).
The value of the xsdPathWithinArtifact
parameter is the relative path within the artifact where
all source XSDs are copied to (hence the name "XSD Path Within Artifact").
The target directory is created within the artifact if it does not already exist.
If the xsdPathWithinArtifact
parameter is not given, the XSDs used to generate Java code are
not included within the project's artifact.
Example:Adding the sample configuration below would copy all source XSDs to the given directory
within the resulting JAR (and/or test-JAR). If the directory META-INF/jaxb/xsd
does not exist, it
will be created.
<configuration>
...
<xsdPathWithinArtifact>META-INF/jaxb/xsd</xsdPathWithinArtifact>
</configuration>
Note: This parameter was previously called includeSchemasOutputPath
in the 1.x versions of this plugin, but was renamed and re-documented for improved usability and clarity.
protected boolean isReGenerationRequired()
Java generation is required if any of the file products is outdated/stale.
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 List<URL> getSources()
sourceType
value.getSources
in class AbstractJaxbMojo
sourceType
protected abstract List<File> getSourceXJBs()
protected abstract void addGeneratedSourcesToProjectSourceRoot()
TestCompileSourceRoot
or CompileSourceRoot
depending on the exact Mojo implementation
of this AbstractJavaGeneratorMojo.protected abstract void addResource(org.apache.maven.model.Resource resource)
resource
- The resource to add.Copyright © 2005–2015 MojoHaus. All rights reserved.