-
Notifications
You must be signed in to change notification settings - Fork 99
Use Separate Target Directories for Separate Executions
You may want to configure several executions of the maven-jaxb2-plugin
in your pom.xml
:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>a</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/a</schemaDirectory>
<generatePackage>a</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/xjc-a</generateDirectory>
</configuration>
</execution>
<execution>
<id>b</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/b</schemaDirectory>
<generatePackage>b</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/xjc-b</generateDirectory>
</configuration>
</execution>
</executions>
</plugin>
If you do this, you'll have to configure separate generateDirectory
for each of the executions.
The reason behind this are the up-to-date-checks. The plugin creates a list of the "source" and "destination" files and if "source" files were not changed later than the "destination" files, no new generation will be performed.
Now, if both executions are configured with the same target directory, the second execution will not be performed. The plugin will think that "destination" files (actually from the first execution) are newer that the "source" files of the second execution.
Unfortunatelly, there is no better reliable way to check earliest timestamps of the "destination" files. If several executions are generated in the same directory, there is no way for the plugin to tell files from each of the executions apart.
Therefore, if you decide to configure several executions, make sure you configure different generateDirectory
s as well.
Next, multiple executions are often used to generate different package per schema via the generatePackage
element. This is normally a bad practice. Consider configuring target packages in binding files instead.
See the following issues for more information and discussion:
- 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