-
Notifications
You must be signed in to change notification settings - Fork 99
Specifying What To Compile
Paulo Eduardo Neves edited this page Apr 25, 2017
·
10 revisions
TBD
<plugin>
...
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<!-- By default, nothing is excluded. -->
<schemaExcludes>
<exclude>*.xs</exclude>
</schemaExcludes>
</configuration>
</plugin>
<schemas>
<schema>
<!-- Specifies a schema from the Maven artifact. -->
<dependencyResource>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-tests-po</artifactId>
<!-- Version of the artifact. May be omitted.
The plugin will then try to find the version using
the dependencyManagement and dependencies of the project. -->
<version>${project.version}</version>
<!-- Path of the resource within the artifact. -->
<resource>purchaseorder.xsd</resource>
</dependencyResource>
</schema>
<schema>
<url>http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd</url>
</schema>
<schema>
<!-- Specifies a schema in the Maven artifact. -->
<url>maven:org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-tests-po!/po.xsd</url>
</schema>
<schema>
<fileset>
<!-- Defaults to schemaDirectory. -->
<directory>${basedir}/src/main/schemas</directory>
<!-- Defaults to schemaIncludes. -->
<includes>
<include>*.xsd</include>
</includes>
<!-- Defaults to schemaIncludes -->
<excludes>
<exclude>*.xs</exclude>
</excludes>
</fileset>
</schema>
</schemas>
<!-- DTD, XMLSCHEMA, RELAXNG, RELAXNG_COMPACT, WSDL, AUTODETECT. -->
<schemaLanguage>AUTODETECT</schemaLanguage>
- Basic usage, from directory:
-
schemaDirectory
- Specifies the schema directory,src/main/resources
by default. -
schemaIncludes/include
- Specifies file patterns to include as schemas. By default all*.xsd
files will be included. -
schemaExcludes/exclude
- Specifies file patterns of schemas to exclude. By default, nothing is excluded.
-
- Extended usage:
-
schemas/schema
- Specifies schemas as filesets, URLs or Maven artifact resources.-
dependencyResource
- Specifies a schema from the Maven artifact.-
groupId
- Group id of the artifact, required. -
artifactId
- Artifact id of the artifact, required. -
version
- Version of the artifact. May be omitted. The plugin will then try to find the version using thedependencyManagement
anddependencies
of the project. -
resource
- Path of the resource within the artifact, for instanceorg/foo/bar/schema.xsd
. Required. Do not include a leading/
. -
type
- Type of the dependency, optional. Defaults tojar
. -
classifier
- Classifier of the dependency, optional. Defaults to none.
-
-
-
url
- Specifies a schema URL to compile. -
fileset
- Specifies a fileset to compile.-
directory
- Base directory of the fileset. Optional, defaults toschemaDirectory
(see above). -
includes/include
- File patterns to include. Optional, defaults toschemaIncludes
(see above). -
excludes/exclude
- File patterns to exclude. Optional, defaults toschemaExcludes
(see above).
-
-
- Specifying schema language:
-
schemaLanguage
- Type of input schema language. One of:DTD
,XMLSCHEMA
,RELAXNG
,RELAXNG_COMPACT
,WSDL
,AUTODETECT
. If unspecified, it is assumedAUTODETECT
.
-
<!-- Default to the schemaDirectory -->
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>**/*.xjb</include>
</bindingIncludes>
<!-- By default, nothing is excluded. -->
<bindingExcludes>
<exclude>**/*.xj</exclude>
</bindingExcludes>
<bindings>
<binding>
<dependencyResource>...</dependencyResource>
</binding>
<binding>
<url>...</url>
</binding>
<binding>
<fileset>
<!-- Defaults to bindingDirectory. -->
<directory>${basedir}/src/main/bindings</directory>
<!-- Defaults to bindingIncludes. -->
<includes>
<include>*.xjb</include>
</includes>
<!-- Defaults to bindingExcludes. -->
<excludes>
<exclude>*.xj</exclude>
</excludes>
</fileset>
</binding>
</bindings>
<scanDependenciesForBindings>false</scanDependenciesForBindings>
- Basic usage, from directory:
-
bindingDirectory
- Specifies the binding directory, default to theschemaDirectory
. -
bindingIncludes/include
- Specifies file patterns to include as bindings. By default all*.xjb
files will be included. -
bindingExcludes/exclude
- Specifies file patterns of bindings to exclude. By default, nothing is excluded.
-
- Extended usage:
-
bindings/binding
- Specifies bindings as filesets, URLs or Maven artifact resources.-
dependencyResource
- Specifies a binding from the Maven artifact.-
groupId
- Group id of the artifact, required. -
artifactId
- Artifact id of the artifact, required. -
version
- Version of the artifact. May be omitted. The plugin will then try to find the version using thedependencyManagement
anddependencies
of the project. -
resource
- Path of the resource within the artifact, for instanceorg/foo/bar/binding.xjb
. Required. Do not include a leading/
. -
type
- Type of the dependency, optional. Defaults tojar
. -
classifier
- Classifier of the dependency, optional. Defaults to none.
-
-
-
url
- Specifies an URL of the binding to use. -
fileset
- Specifies a fileset of bindings to use.-
directory
- Base directory of the fileset. Optional, defaults tobindingDirectory
(see above). -
includes/include
- File patterns to include. Optional, defaults tobindingIncludes
(see above). -
excludes/exclude
- File patterns to exclude. Optional, defaults tobindingExcludes
(see above).
-
-
Below is an example of a non-standard directory layout configuration:
<configuration>
<!-- Changes the default schema directory -->
<schemaDirectory>src/main/schema</schemaDirectory>
<schemaIncludes>
<include>one/*/*.xsd</include>
</schemaIncludes>
<schemaExcludes>
<exclude>one/two/*.xsd</exclude>
</schemaExcludes>
<bindingDirectory>src/main/binding</bindingDirectory>
<bindingIncludes>
<include>one/*/*.xjb</include>
</bindingIncludes>
<bindingExcludes>
<exclude>one/two/*.xjb</exclude>
</bindingExcludes>
</configuration>
Since
0.8.0
.
You can specify schemas and bindings as URLs, filesets and Maven artifact resources using schemas/schema
and bindings/binding
configuration elements:
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemas>
<!--
Compiles a schema from the URL.
It is highly recommended to make local copies
and use a catalog file to "rewrite" absolute URLs
to the local files.
-->
<schema>
<url>http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd</url>
</schema>
<!--
Compiles a schema which resides
in another Maven artifact.
-->
<schema>
<dependencyResource>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-tests-po</artifactId>
<!-- Can be defined in project dependencies or dependency management -->
<version>${project.version}</version>
<resource>purchaseorder.xsd</resource>
</dependencyResource>
</schema>
<!--
Compiles a fileset.
-->
<schema>
<fileset>
<!-- Defaults to schemaDirectory -->
<directory>${basedir}/src/main/schemas</directory>
<!-- Defaults to schemaIncludes -->
<includes>
<include>*.*</include>
</includes>
<!-- Defaults to schemaExcludes -->
<excludes>
<exclude>*.xs</exclude>
</excludes>
</fileset>
</schema>
</schemas>
</configuration>
The same works for bindings
and catalogs
(see Using Catalogs).
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<dependencyResource>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-tests-po</artifactId>
<!-- Can be defined in project dependencies or dependency management -->
<version>${project.version}</version>
<resource>purchaseorder.xsd</resource>
</dependencyResource>
</schema>
</schemas>
</configuration>
See also the Modular Schema Compilation guide.
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<url>http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd</url>
</schema>
</schemas>
</configuration>
It is highly recommended to make a local copy of the external schema and use a catalog file to rewrite the absolute URL (or a namespace) to the local copy. Otherwise your will depend on external resources during the build, which is definitely not a good idea.
You also have to use forceRegenerate' 'true
in this case, since the plugin can't generally detect if external
resources were changed or not.
- Home
- Migration guide
-
JAXB Maven Plugin
- Quick Start
-
User Guide
- Basic Usage
- Specifying What To Compile
- Referencing Resources in Maven Artifacts
- Using Catalogs
- Using Episodes
- Modular Schema Compilation
- Controlling the Output
- Using JAXB Plugins
- Using a Specific JAXB Version
- Configuring Extension, Validation and XML Security
- IDE Integration
- Miscellaneous
- Configuring Proxies
- Maven Documentation
- Configuration Cheat Sheet
- Common Pitfalls and Problems
-
JAXB2 Basics Plugins
- Using JAXB2 Basics Plugins
- JSR-305 Support
-
JAXB2 Basics Plugins List
- SimpleEquals Plugin
- SimpleHashCode Plugin
- Equals Plugin
- HashCode Plugin
- ToString Plugin
- Copyable Plugin
- Mergeable Plugin
- Inheritance Plugin
- AutoInheritance Plugin
- Wildcard Plugin
- Setters Plugin
- Simplify Plugin
- EnumValue Plugin
- JAXBIndex Plugin
- FixJAXB1058 Plugin
- Commons Lang Plugin
- Default Value Plugin
- Fluent API Plugin
- Namespace Prefix Plugin
- Value Constructor Plugin
- Boolean Getter Plugin
- CamelCase Plugin
- XML ElementWrapper Plugin
- Parent Pointer Plugin
- Property Listener Injector Plugin
- Annox
- JAXB Annotate Plugin
-
HyperJAXB3
- Build System Support
- Customization Guide
- Databases
- Development guide
- Extension guide
- FAQ
- IDE Support
- Java Persistence
- JAXB
- JDK Support
- Project Templates
-
Reference
- Adding vendor-specific annotations
- Features
- Integrating Hyperjaxb3 in builds
- Introduction
- Making schema-derived classes ready for JPA
- Adding required properties
- Applying workarounds for JAXB vs. JPA conflicts
- Enforcing top-level classes
- Generating equals and hashCode methods
- Generating ORM metadata
- Generating persistence unit descriptor
- JPA 2 Support
- Making classes serializable
- Testing generated mappings
- Reference - single page
- Related Projects
- Sample projects
- Solutions
- Target Scenarios
- Test Projects
- Tutorials
- Best Practices
- FAQ
- Sample Projects
- Support
- License
- Distribution