@Mojo(name="xjc", threadSafe=false, defaultPhase=GENERATE_SOURCES, requiresDependencyResolution=COMPILE) public class XjcMojo extends AbstractJavaGeneratorMojo
Mojo that creates compile-scope Java source or binaries from XML schema(s) by invoking the JAXB XJC binding compiler. This implementation is tailored to use the JAXB Reference Implementation from project Kenai.
Note that the XjcMojo was completely re-implemented for the 2.x versions. Its configuration semantics and parameter set is not necessarily backwards compatible with the 1.x plugin versions. If you are upgrading from version 1.x of the plugin, read the documentation carefully.
Modifier and Type | Field and Description |
---|---|
static String |
STALE_FILENAME
The last part of the stale fileName for this XjcMojo.
|
static String |
STANDARD_SOURCE_DIRECTORY
Standard directory path (relative to basedir) searched recursively for source
files (typically XSDs), unless overridden by an
sources configuration element. |
static List<Filter<File>> |
STANDARD_SOURCE_EXCLUDE_FILTERS
Default exclude Filters for sources, used unless overridden by an
explicit configuration in the
xjcSourceExcludeFilters parameter. |
static String |
STANDARD_XJB_DIRECTORY
Standard directory path (relative to basedir) searched recursively for XJB
files, unless overridden by an
xjbSources configuration element. |
static List<Filter<File>> |
STANDARD_XJB_EXCLUDE_FILTERS
Default List of exclude Filters for XJB files, unless overridden by providing
an explicit configuration in the
xjbExcludeSuffixes parameter. |
addGeneratedAnnotation, arguments, catalog, clearOutputDir, extension, failOnNoSchemas, generateEpisode, laxSchemaValidation, noGeneratedHeaderComments, noPackageLevelAnnotations, packageName, quiet, readOnly, settings, sourceType, target, verbose, xsdPathWithinArtifact
CONTAINS_WHITESPACE, extraFacets, locale, NEWLINE, PACKAGE_INFO_FILENAME, staleFileDirectory, STANDARD_EPISODE_FILENAME, STANDARD_EXCLUDE_FILTERS
Constructor and Description |
---|
XjcMojo() |
Modifier and Type | Method and Description |
---|---|
protected 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 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 List<String> |
getClasspath()
Retrieves the configured List of paths from which this AbstractJaxbMojo and its internal toolset
(XJC or SchemaGen) should read bytecode classes.
|
protected File |
getOutputDirectory()
Retrieves the directory where the generated files should be written to.
|
protected 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 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 String |
getStaleFileName()
Retrieves the last name part of the stale file.
|
protected boolean |
shouldExecutionBeSkipped()
Implement this method to check if this AbstractJaxbMojo should skip executing altogether.
|
isReGenerationRequired, performExecution
execute, getBuildContext, getEncoding, getEpisodeFile, getExecution, getProject, getStaleFile, logAndReturnToolArguments, logSystemPropertiesAndBasedir, warnAboutIncorrectPluginConfiguration
public static final String STALE_FILENAME
public static final String STANDARD_SOURCE_DIRECTORY
Standard directory path (relative to basedir) searched recursively for source
files (typically XSDs), unless overridden by an sources
configuration element.
public static final List<Filter<File>> STANDARD_SOURCE_EXCLUDE_FILTERS
xjcSourceExcludeFilters
parameter.public static final String STANDARD_XJB_DIRECTORY
Standard directory path (relative to basedir) searched recursively for XJB
files, unless overridden by an xjbSources
configuration element.
As explained in the JAXB specification, XJB files (JAXB Xml Binding files)
are used to configure parts of the Java source generation.
protected boolean shouldExecutionBeSkipped()
shouldExecutionBeSkipped
in class AbstractJaxbMojo
true
to indicate that this AbstractJaxbMojo should bail out of its execute method.protected List<URL> getSources()
sourceType
value.getSources
in class AbstractJavaGeneratorMojo
AbstractJavaGeneratorMojo.sourceType
protected List<File> getSourceXJBs()
getSourceXJBs
in class AbstractJavaGeneratorMojo
protected String getStaleFileName()
"." + getExecution().getExecutionId()
before this staleFileName.getStaleFileName
in class AbstractJaxbMojo
protected File getOutputDirectory()
getOutputDirectory
in class AbstractJaxbMojo
protected List<String> getClasspath() throws org.apache.maven.plugin.MojoExecutionException
getClasspath
in class AbstractJaxbMojo
org.apache.maven.plugin.MojoExecutionException
- if the classpath could not be retrieved.protected void addGeneratedSourcesToProjectSourceRoot()
TestCompileSourceRoot
or CompileSourceRoot
depending on the exact Mojo implementation
of this AbstractJavaGeneratorMojo.addGeneratedSourcesToProjectSourceRoot
in class AbstractJavaGeneratorMojo
protected void addResource(org.apache.maven.model.Resource resource)
addResource
in class AbstractJavaGeneratorMojo
resource
- The resource to add.Copyright © 2005–2015 MojoHaus. All rights reserved.