jaxb2:generate

JAXB 2.x Mojo. @author Aleksei Valikov (valikov@gmx.net)

Mojo Attributes:

  • Requires a Maven 2.0 project to execute.
  • Automatically executes within the lifecycle phase: generate-sources

Required Parameters

Name Type Description
schemaDirectory File Specifies the schema directory. Default value is src/main/resources.
generateDirectory File Target directory for the generated code. Default value is ${project.build.directory}/generated-sources/xjc.
localRepository ArtifactRepository Internal use.
pluginArtifacts Artifact> Internal use.

Optional Parameters

Name Type Description
schemaLanguage String Type of input schema language. One of: DTD, XMLSCHEMA, RELAXNG, RELAXNG_COMPACT, WSDL, AUTODETECT. If unspecified, it is assumed AUTODETECT.
schemaIncludes String[] Specifies file patterns to include as schemas. Default value is *.xsd.
schemaExcludes String[] Specifies file patterns of schemas to exclude. By default, nothing is excluded.
bindingDirectory File Specifies the binding directory, defaults to the schema directory.
bindingIncludes String[] Specifies file patterns to include as bindings. Default value is *.xjb.
bindingExcludes String[] Specifies file patterns of bindings to exclude. By default, nothing is excluded.
disableDefaultExcludes boolean If set to true, Maven default exludes are NOT added to all the excludes lists. Default value is false.
catalog File Specify the catalog file to resolve external entity references (XJC -catalog option).
catalogResolver String Class name of the catalog resolver. Default value is com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver.
generatePackage String The generated classes will all be placed under this Java package, unless otherwise specified in the schemas. If left unspecified, the package will be derived from the schemas only.
addCompileSourceRoot boolean If set to true (default), adds target directory as a compile source root of this Maven project. Default value is true.
addTestCompileSourceRoot boolean If set to true, adds target directory as a test compile source root of this Maven project. Default value is false. Default value is false.
readOnly boolean If true, the generated Java source files are set as read-only (XJC's -readOnly option). Default value is false.
extension boolean If true, the XJC binding compiler will run in the extension mode (XJC's -extension option). Otherwise, it will run in the strict conformance mode. Please note that you must enable the extension mode if you use vendor extensions in your bindings. Default value is false.
strict boolean If true, XJC will perform strict validation of the input schema. If strict is set to false XJC will be run with -nv, this disables strict validation of schemas. Default value is true.
writeCode boolean If set to false, the plugin will not write the generated code to disk. Default value is true.
verbose boolean If true, the plugin and the XJC compiler are both set to verbose mode (XJC's -verbose option). It is automatically set to true when Maven is run in debug mode (mvn's -X option). Default value is false.
debug boolean If true, the XJC compiler is set to debug mode (XJC's -debug option). Default value is false.
args String> A list of extra XJC's command-line arguments (items must include the dash "-"). Use this argument to enable the JAXB2 plugins you want to use.
forceRegenerate boolean If true, no up-to-date check is performed and the XJC always re-generates the sources. Otherwise schemas will only be recompiled if anything has changed. Default value is false.
removeOldOutput boolean If true, the generateDirectory will be deleted before the XJC binding compiler recompiles the source files. Default is false. Default value is false.
produces String[] Specifies patters of files produced by this plugin. This is used to check if produced files are up-to-date. Default value is **/*.*, **/*.java, **/bgm.ser, **/jaxb.properties.
otherDepends File[] A list of of input files or URLs to consider during the up-to-date. By default it always considers: 1. schema files, 2. binding files, 3. catalog file, and 4. the pom.xml file of the project executing this plugin.
episodeFile File Target location of the episode file. By default it is target/generated-sources/xjc/META-INF/sun-jaxb.episode so that the episode file will appear as META-INF/sun-jaxb.episode in the JAR - just as XJC wants it.
episode boolean If true, the episode file (describing mapping of elements and types to classes for the compiled schema) will be generated. Default value is true.
plugins Dependency[] Configures artifacts of the custom JAXB2 plugins you want to use.
episodes Dependency[] If you want to use existing artifacts as episodes for separate compilation, configure them as episodes/episode elements. It is assumed that episode artifacts contain an appropriate META-INF/sun-jaxb.episode resource.
specVersion String Version of the JAXB specification (ex. 2.0, 2.1 or 2.2). Default value is 2.1.
artifactResolver ArtifactResolver No description.
artifactMetadataSource ArtifactMetadataSource No description.
artifactFactory ArtifactFactory No description.
mavenProjectBuilder MavenProjectBuilder No description.

Parameter Details

schemaLanguage

Type of input schema language. One of: DTD, XMLSCHEMA, RELAXNG, RELAXNG_COMPACT, WSDL, AUTODETECT. If unspecified, it is assumed AUTODETECT.

  • Type: java.lang.String
  • Required: No
  • Expression: ${maven.xjc2.schemaLanguage}

schemaDirectory

Specifies the schema directory.

  • Type: java.io.File
  • Required: Yes
  • Expression: ${maven.xjc2.schemaDirectory}
  • Default: src/main/resources

schemaIncludes

Specifies file patterns to include as schemas. Default value is *.xsd.

  • Type: java.lang.String[]
  • Required: No

schemaExcludes

Specifies file patterns of schemas to exclude. By default, nothing is excluded.

  • Type: java.lang.String[]
  • Required: No

bindingDirectory

Specifies the binding directory, defaults to the schema directory.

  • Type: java.io.File
  • Required: No
  • Expression: ${maven.xjc2.bindingDirectory}

bindingIncludes

Specifies file patterns to include as bindings. Default value is *.xjb.

  • Type: java.lang.String[]
  • Required: No

bindingExcludes

Specifies file patterns of bindings to exclude. By default, nothing is excluded.

  • Type: java.lang.String[]
  • Required: No

disableDefaultExcludes

If set to true, Maven default exludes are NOT added to all the excludes lists.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.disableDefaultExcludes}
  • Default: false

catalog

Specify the catalog file to resolve external entity references (XJC -catalog option).

  • Type: java.io.File
  • Required: No
  • Expression: ${maven.xjc2.catalog}

catalogResolver

Class name of the catalog resolver.

  • Type: java.lang.String
  • Required: No
  • Expression: ${maven.xjc2.catalogResolver}
  • Default: com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver

generatePackage

The generated classes will all be placed under this Java package, unless otherwise specified in the schemas. If left unspecified, the package will be derived from the schemas only.

  • Type: java.lang.String
  • Required: No
  • Expression: ${maven.xjc2.generatePackage}

generateDirectory

Target directory for the generated code.

  • Type: java.io.File
  • Required: Yes
  • Expression: ${maven.xjc2.generateDirectory}
  • Default: ${project.build.directory}/generated-sources/xjc

addCompileSourceRoot

If set to true (default), adds target directory as a compile source root of this Maven project.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.addCompileSourceRoot}
  • Default: true

addTestCompileSourceRoot

If set to true, adds target directory as a test compile source root of this Maven project. Default value is false.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.addTestCompileSourceRoot}
  • Default: false

readOnly

If true, the generated Java source files are set as read-only (XJC's -readOnly option).

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.readOnly}
  • Default: false

extension

If true, the XJC binding compiler will run in the extension mode (XJC's -extension option). Otherwise, it will run in the strict conformance mode. Please note that you must enable the extension mode if you use vendor extensions in your bindings.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.extension}
  • Default: false

strict

If true, XJC will perform strict validation of the input schema. If strict is set to false XJC will be run with -nv, this disables strict validation of schemas.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.strict}
  • Default: true

writeCode

If set to false, the plugin will not write the generated code to disk.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.writeCode}
  • Default: true

verbose

If true, the plugin and the XJC compiler are both set to verbose mode (XJC's -verbose option). It is automatically set to true when Maven is run in debug mode (mvn's -X option).

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.verbose}
  • Default: false

debug

If true, the XJC compiler is set to debug mode (XJC's -debug option).

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.debug}
  • Default: false

args

A list of extra XJC's command-line arguments (items must include the dash "-"). Use this argument to enable the JAXB2 plugins you want to use.

  • Type: java.util.List<java.lang.String>
  • Required: No

forceRegenerate

If true, no up-to-date check is performed and the XJC always re-generates the sources. Otherwise schemas will only be recompiled if anything has changed.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.forceRegenerate}
  • Default: false

removeOldOutput

If true, the generateDirectory will be deleted before the XJC binding compiler recompiles the source files. Default is false.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.removeOldOutput}
  • Default: false

produces

Specifies patters of files produced by this plugin. This is used to check if produced files are up-to-date. Default value is **/*.*, **/*.java, **/bgm.ser, **/jaxb.properties.

  • Type: java.lang.String[]
  • Required: No

otherDepends

A list of of input files or URLs to consider during the up-to-date. By default it always considers: 1. schema files, 2. binding files, 3. catalog file, and 4. the pom.xml file of the project executing this plugin.

  • Type: java.io.File[]
  • Required: No

episodeFile

Target location of the episode file. By default it is target/generated-sources/xjc/META-INF/sun-jaxb.episode so that the episode file will appear as META-INF/sun-jaxb.episode in the JAR - just as XJC wants it.

  • Type: java.io.File
  • Required: No
  • Expression: ${maven.xjc2.episodeFile}

episode

If true, the episode file (describing mapping of elements and types to classes for the compiled schema) will be generated.

  • Type: boolean
  • Required: No
  • Expression: ${maven.xjc2.episode}
  • Default: true

plugins

Configures artifacts of the custom JAXB2 plugins you want to use.

  • Type: org.apache.maven.model.Dependency[]
  • Required: No

episodes

If you want to use existing artifacts as episodes for separate compilation, configure them as episodes/episode elements. It is assumed that episode artifacts contain an appropriate META-INF/sun-jaxb.episode resource.

  • Type: org.apache.maven.model.Dependency[]
  • Required: No

specVersion

Version of the JAXB specification (ex. 2.0, 2.1 or 2.2).

  • Type: java.lang.String
  • Required: No
  • Default: 2.1

artifactResolver

No Description.

  • Type: org.apache.maven.artifact.resolver.ArtifactResolver
  • Required: No

artifactMetadataSource

No Description.

  • Type: org.apache.maven.artifact.metadata.ArtifactMetadataSource
  • Required: No

artifactFactory

No Description.

  • Type: org.apache.maven.artifact.factory.ArtifactFactory
  • Required: No

localRepository

Internal use.

  • Type: org.apache.maven.artifact.repository.ArtifactRepository
  • Required: Yes
  • Expression: ${localRepository}

mavenProjectBuilder

No Description.

  • Type: org.apache.maven.project.MavenProjectBuilder
  • Required: No

pluginArtifacts

Internal use.

  • Type: java.util.List<org.apache.maven.artifact.Artifact>
  • Required: Yes
  • Expression: ${plugin.artifacts}