I use the xjc goal of the jaxb2-maven-plugin to generate Java classes from a set of xsd files.
A minimal, complete and verifiable example would be a Maven project with the following pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jaxb2-maven-episode-test</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/</source>
</sources>
<generateEpisode>false</generateEpisode>
</configuration>
</plugin>
</plugins>
</build>
</project>
And a file called example.xsd (any valid xsd file will do) in the src/main/resources/ folder:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xsd"
targetNamespace="http://tempuri.org/PurchaseOrderSchema.xsd"
elementFormDefault="qualified">
<xsd:element name="PurchaseOrder" type="tns:PurchaseOrderType"/>
<xsd:complexType name="PurchaseOrderType">
<xsd:sequence>
<xsd:element name="ShipTo" type="tns:USAddress" maxOccurs="2"/>
<xsd:element name="BillTo" type="tns:USAddress"/>
</xsd:sequence>
<xsd:attribute name="OrderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:complexType name="USAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="street" type="xsd:string"/>
<xsd:element name="city" type="xsd:string"/>
<xsd:element name="state" type="xsd:string"/>
<xsd:element name="zip" type="xsd:integer"/>
</xsd:sequence>
<xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
</xsd:complexType>
</xsd:schema>
<generateEpisode>false</generateEpisode>
makes sure that the code is generated without an episode file.
I need to upgrade the version of the plugin to 2.5.0. In this version, generateEpisode
has been deprecated:
From plugin version 2.4, this parameter will not be used. Instead, episode files are generated by default with all JAXB operations.
Starting with plugin version 2.4, use the parameter episodeFileName to provide a custom name of the generated episode File (or rely on the standard file name STANDARD_EPISODE_FILENAME).
Simply changing the version
to 2.5.0 gives the following build-time error:
Caused by: java.io.FileNotFoundException: C:\path-to-the-project\target\generated-sources\jaxb\META-INF\JAXB\episode_xjc.xjb
By switching generateEpisode
to true
the build is successful, but the code is generated with an episode file, which I want to avoid. (As a side note, this proves that generateEpisode
in fact is not ignored, despite what the documentation says).
How do I disable the generation of an episode file with version 2.5.0 of the plugin, if at all possible?