Class TestSchemaGenerationMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.jaxb2.AbstractJaxbMojo
org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo
org.codehaus.mojo.jaxb2.schemageneration.TestSchemaGenerationMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="testSchemagen",
defaultPhase=GENERATE_TEST_RESOURCES,
requiresDependencyResolution=TEST,
threadSafe=true)
public class TestSchemaGenerationMojo
extends AbstractXsdGeneratorMojo
Mojo that creates XML schema(s) from test-scope Java testSources or binaries by invoking the JAXB SchemaGenerator. This implementation is tailored to use the JAXB Reference Implementation from project Kenai.
Note that the TestSchemaGenerationMojo was completely re-implemented for the 2.x versions. Its configuration semantics and parameter set is not 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe last part of the stale fileName for this TestSchemaGenerationMojo.Default exclude file name suffixes for testSources, used unless overridden by an explicit configuration in thetestSchemaSourceExcludeFiltersparameter.Fields inherited from class org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo
CLASS_INCLUDE_FILTERS, clearOutputDir, createJavaDocAnnotations, episodeFileName, generateEpisode, javaDocRenderer, SCHEMAGEN_EMITTED_FILENAME, STANDARD_BYTECODE_EXCLUDE_FILTERS, STANDARD_JAVADOC_RENDERER, SYSTEM_TOOLS_CLASSLOADER_PACKAGESFields inherited from class org.codehaus.mojo.jaxb2.AbstractJaxbMojo
CONTAINS_WHITESPACE, extraFacets, locale, NEWLINE, PACKAGE_INFO_FILENAME, staleFileDirectory, STANDARD_EPISODE_FILENAME, STANDARD_EXCLUDE_FILTERSFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGeneratedSourcesToProjectSourceRoot(String canonicalPathToOutputDirectory) Adds any directories containing the generated XJC classes to the appropriate Project compilation sources; eitherTestCompileSourceRootorCompileSourceRootdepending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.protected voidaddResource(org.apache.maven.model.Resource resource) Adds the supplied Resource to the project using the appropriate scope (i.e.Retrieves the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read bytecode classes.Finds a List containing URLs to compiled bytecode files within this Compilation Unit.protected FileRetrieves the directory where the generated files should be written to.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 StringRetrieves the last name part of the stale file.protected FileMethods inherited from class org.codehaus.mojo.jaxb2.schemageneration.AbstractXsdGeneratorMojo
isReGenerationRequired, performExecution, shouldExecutionBeSkippedMethods inherited from class org.codehaus.mojo.jaxb2.AbstractJaxbMojo
execute, getBuildContext, getEncoding, getEpisodeFile, getExecution, getProject, getStaleFile, logAndReturnToolArguments, logSystemPropertiesAndBasedir, warnAboutIncorrectPluginConfigurationMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
STALE_FILENAME
The last part of the stale fileName for this TestSchemaGenerationMojo.- See Also:
-
STANDARD_TEST_SOURCE_EXCLUDE_FILTERS
Default exclude file name suffixes for testSources, used unless overridden by an explicit configuration in the
testSchemaSourceExcludeFiltersparameter. The default values are found as follows:final List<Filter<File>> testSrcTemp = new ArrayList<Filter<File>>(); testSrcTemp.addAll(AbstractJaxbMojo.STANDARD_EXCLUDE_FILTERS); testSrcTemp.add(new PatternFileFilter(Arrays.asList("\\.xjb", "\\.xsd", "\\.properties"), true)); STANDARD_TEST_SOURCE_EXCLUDE_FILTERS = Collections.unmodifiableList(testSrcTemp);- See Also:
-
-
Constructor Details
-
TestSchemaGenerationMojo
public TestSchemaGenerationMojo()
-
-
Method Details
-
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.- Specified by:
getCompiledClassNamesin classAbstractXsdGeneratorMojo- 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.
-
getClasspath
Retrieves the configured List of paths from which this AbstractJaxbMojo and its internal toolset (XJC or SchemaGen) should read bytecode classes.- Specified by:
getClasspathin 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
Adds any directories containing the generated XJC classes to the appropriate Project compilation sources; eitherTestCompileSourceRootorCompileSourceRootdepending on the exact Mojo implementation of this AbstractJavaGeneratorMojo.- Specified by:
addGeneratedSourcesToProjectSourceRootin classAbstractJaxbMojo
-
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:
getSourcesin classAbstractXsdGeneratorMojo- Returns:
- A non-null List holding URLs to sources for the XSD generation.
-
getOutputDirectory
Retrieves the directory where the generated files should be written to.- Specified by:
getOutputDirectoryin classAbstractJaxbMojo- Returns:
- the directory where the generated files should be written to.
-
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:
getStaleFileNamein classAbstractJaxbMojo- Returns:
- The name of the stale file used by this AbstractJavaGeneratorMojo to detect staleness amongst its generated files.
-
getWorkDirectory
- Specified by:
getWorkDirectoryin classAbstractXsdGeneratorMojo- Returns:
- The working directory to which the SchemaGenerator should initially copy all its generated files, including bytecode files, compiled from java sources.
-
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:
addResourcein classAbstractJaxbMojo- Parameters:
resource- The resource to add.
-