@Mojo(name="testXjc", defaultPhase=GENERATE_TEST_SOURCES, requiresDependencyResolution=TEST, threadSafe=false) public class TestXjcMojo extends AbstractJavaGeneratorMojo
Mojo that creates test-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 TestXjcMojo 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 TestXjcMojo.
|
static String |
STANDARD_TEST_SOURCE_DIRECTORY
Standard directory path (relative to basedir) searched recursively for test
source files (typically XSDs), unless overridden by an
testSources configuration element. |
static List<Filter<File>> |
STANDARD_TEST_SOURCE_EXCLUDE_FILTERS
Default exclude Filters for test sources, used unless overridden by an
explicit configuration in the
testSourceExcludeFilters parameter. |
static String |
STANDARD_TEST_XJB_DIRECTORY
Standard directory path (relative to basedir) searched recursively for XJB
files, unless overridden by an
testXjbSources configuration element. |
static List<Filter<File>> |
STANDARD_TEST_XJB_EXCLUDE_FILTERS
Default List of exclude Filters for XJB files, unless overridden by providing
an explicit configuration in the
testXjbExcludeFilters 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 |
---|
TestXjcMojo() |
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_TEST_SOURCE_DIRECTORY
testSources
configuration element.public static final List<Filter<File>> STANDARD_TEST_SOURCE_EXCLUDE_FILTERS
testSourceExcludeFilters
parameter.public static final String STANDARD_TEST_XJB_DIRECTORY
Standard directory path (relative to basedir) searched recursively for XJB
files, unless overridden by an testXjbSources
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.