Class TestXjcMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.jaxb2.AbstractJaxbMojo
-
- org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo
-
- org.codehaus.mojo.jaxb2.javageneration.TestXjcMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@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.
- Author:
- Lennart Jörelid
- See Also:
- The JAXB Reference Implementation
-
-
Field Summary
Fields Modifier and Type Field 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 atestSources
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 thetestSourceExcludeFilters
parameter.static String
STANDARD_TEST_XJB_DIRECTORY
Standard directory path (relative to basedir) searched recursively for XJB files, unless overridden by antestXjbSources
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 thetestXjbExcludeFilters
parameter.-
Fields inherited from class org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo
addGeneratedAnnotation, arguments, catalog, clearOutputDir, episodeFileName, extension, externalEntityProcessing, failOnNoSchemas, generateEpisode, laxSchemaValidation, noGeneratedHeaderComments, noPackageLevelAnnotations, packageName, quiet, readOnly, settings, sourceType, target, verbose, xsdPathWithinArtifact
-
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 TestXjcMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addGeneratedSourcesToProjectSourceRoot()
Adds any directories containing the generated XJC classes to the appropriate Project compilation sources; eitherTestCompileSourceRoot
orCompileSourceRoot
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.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.-
Methods inherited from class org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo
isReGenerationRequired, performExecution
-
Methods inherited from class org.codehaus.mojo.jaxb2.AbstractJaxbMojo
execute, getBuildContext, getEncoding, getEpisodeFile, getExecution, getProject, getStaleFile, logAndReturnToolArguments, logSystemPropertiesAndBasedir, warnAboutIncorrectPluginConfiguration
-
-
-
-
Field Detail
-
STALE_FILENAME
public static final String STALE_FILENAME
The last part of the stale fileName for this TestXjcMojo.- See Also:
- Constant Field Values
-
STANDARD_TEST_SOURCE_DIRECTORY
public static final String STANDARD_TEST_SOURCE_DIRECTORY
Standard directory path (relative to basedir) searched recursively for test source files (typically XSDs), unless overridden by atestSources
configuration element.- See Also:
- Constant Field Values
-
STANDARD_TEST_SOURCE_EXCLUDE_FILTERS
public static final 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. The default values are found as follows:final List<Filter<File>> xjbTemp = new ArrayList<Filter<File>>(); xjbTemp.addAll(AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS); xsdTemp.add(new PatternFileFilter(Arrays.asList("\\.xjb"), true)); STANDARD_TEST_SOURCE_EXCLUDE_FILTERS = Collections.unmodifiableList(xsdTemp);
-
STANDARD_TEST_XJB_DIRECTORY
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.- See Also:
- Constant Field Values
-
STANDARD_TEST_XJB_EXCLUDE_FILTERS
public static final 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. The default values are found as follows:final List<Filter<File>> xjbTemp = new ArrayList<Filter<File>>(); xjbTemp.addAll(AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS); xjbTemp.add(new PatternFileFilter(Arrays.asList("\\.xsd"), true)); STANDARD_TEST_XJB_EXCLUDE_FILTERS = Collections.unmodifiableList(xjbTemp);
-
-
Method Detail
-
shouldExecutionBeSkipped
protected boolean shouldExecutionBeSkipped()
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.
-
getSources
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. Sources are assumed to be in the form given by thesourceType
value.- Specified by:
getSources
in classAbstractJavaGeneratorMojo
- Returns:
- A non-null List holding URLs to sources for the XJC generation.
- See Also:
AbstractJavaGeneratorMojo.sourceType
-
getSourceXJBs
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.- Specified by:
getSourceXJBs
in classAbstractJavaGeneratorMojo
- Returns:
- A non-null List holding binding files.
-
getStaleFileName
protected String getStaleFileName()
Retrieves the last name part of the stale file. The full name of the stale file will be generated by pre-pending"." + getExecution().getExecutionId()
before this staleFileName.- Specified by:
getStaleFileName
in classAbstractJaxbMojo
- Returns:
- The name of the stale file used by this AbstractJavaGeneratorMojo to detect staleness amongst its generated files.
-
getOutputDirectory
protected File getOutputDirectory()
Retrieves the directory where the generated files should be written to.- Specified by:
getOutputDirectory
in classAbstractJaxbMojo
- Returns:
- the directory where the generated files should be written to.
-
getClasspath
protected List<String> getClasspath() throws org.apache.maven.plugin.MojoExecutionException
Retrieves the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read bytecode classes.- Specified by:
getClasspath
in classAbstractJaxbMojo
- Returns:
- the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read classes.
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the classpath could not be retrieved.
-
addGeneratedSourcesToProjectSourceRoot
protected void addGeneratedSourcesToProjectSourceRoot()
Adds any directories containing the generated XJC classes to the appropriate Project compilation sources; eitherTestCompileSourceRoot
orCompileSourceRoot
depending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.- Specified by:
addGeneratedSourcesToProjectSourceRoot
in classAbstractJavaGeneratorMojo
-
addResource
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 AbstractJaxbMojo.- Specified by:
addResource
in classAbstractJaxbMojo
- Parameters:
resource
- The resource to add.
-
-