Skip to content

Commit db7de56

Browse files
Merge pull request #500 from laurentschoelens/jt-437
[#437] upgrade to jaxb-ri 2.3.9
2 parents 4dc98bd + f574786 commit db7de56

File tree

16 files changed

+369
-19
lines changed

16 files changed

+369
-19
lines changed

hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.jvnet.jaxb</groupId>
@@ -59,6 +59,7 @@
5959
<plugin>
6060
<groupId>org.jvnet.jaxb</groupId>
6161
<artifactId>hyperjaxb3-maven-plugin</artifactId>
62+
<version>${project.version}</version>
6263
<executions>
6364
<execution>
6465
<goals>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.jvnet.jaxb</groupId>
7+
<artifactId>jaxb-annotate-plugin-tests</artifactId>
8+
<version>2.0.10-SNAPSHOT</version>
9+
</parent>
10+
<artifactId>jaxb-annotate-plugin-test-base-dependent</artifactId>
11+
<packaging>jar</packaging>
12+
<name>JAXB Tools :: Annotate :: Test [base-dependent]</name>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.glassfish.jaxb</groupId>
16+
<artifactId>jaxb-runtime</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.glassfish.jaxb</groupId>
20+
<artifactId>jaxb-xjc</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.jvnet.jaxb</groupId>
24+
<artifactId>jaxb-maven-plugin-testing</artifactId>
25+
<scope>test</scope>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.jvnet.jaxb</groupId>
29+
<artifactId>jaxb-basics-annotate</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>javax.validation</groupId>
33+
<artifactId>validation-api</artifactId>
34+
<version>2.0.1.Final</version>
35+
</dependency>
36+
</dependencies>
37+
<build>
38+
<defaultGoal>test</defaultGoal>
39+
<plugins>
40+
<plugin>
41+
<groupId>org.jvnet.jaxb</groupId>
42+
<artifactId>jaxb-maven-plugin</artifactId>
43+
<executions>
44+
<execution>
45+
<id>base</id>
46+
<goals>
47+
<goal>generate</goal>
48+
</goals>
49+
<configuration>
50+
<addIfExistsToEpisodeSchemaBindings>false</addIfExistsToEpisodeSchemaBindings>
51+
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
52+
<schemaIncludes>
53+
<include>base.xsd</include>
54+
</schemaIncludes>
55+
<generatePackage>org.test.base</generatePackage>
56+
<encoding>UTF-8</encoding>
57+
<extension>true</extension>
58+
<episode>true</episode>
59+
<episodeFile>${basedir}/target/generated-sources/xjc/META-INF/base.xjb</episodeFile>
60+
<args>
61+
<arg>-Xannotate</arg>
62+
</args>
63+
<plugins>
64+
<dependency>
65+
<groupId>javax.validation</groupId>
66+
<artifactId>validation-api</artifactId>
67+
</dependency>
68+
<plugin>
69+
<groupId>org.jvnet.jaxb</groupId>
70+
<artifactId>jaxb-basics-annotate</artifactId>
71+
</plugin>
72+
</plugins>
73+
</configuration>
74+
</execution>
75+
76+
<execution>
77+
<id>dependent</id>
78+
<goals>
79+
<goal>generate</goal>
80+
</goals>
81+
<configuration>
82+
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
83+
<schemaIncludes>
84+
<include>dependent.xsd</include>
85+
</schemaIncludes>
86+
<generatePackage>org.test.dependent</generatePackage>
87+
<encoding>UTF-8</encoding>
88+
<bindings>
89+
<binding>
90+
<fileset>
91+
<directory>${basedir}/target/generated-sources/xjc/META-INF</directory>
92+
<includes>
93+
<include>*.xjb</include>
94+
</includes>
95+
</fileset>
96+
</binding>
97+
</bindings>
98+
<extension>true</extension>
99+
<episode>true</episode>
100+
<episodeFile>${basedir}/target/generated-sources/xjc/META-INF/dependent.xjb</episodeFile>
101+
<args>
102+
<arg>-Xannotate</arg>
103+
</args>
104+
<plugins>
105+
<dependency>
106+
<groupId>javax.validation</groupId>
107+
<artifactId>validation-api</artifactId>
108+
</dependency>
109+
<plugin>
110+
<groupId>org.jvnet.jaxb</groupId>
111+
<artifactId>jaxb-basics-annotate</artifactId>
112+
</plugin>
113+
</plugins>
114+
</configuration>
115+
</execution>
116+
</executions>
117+
</plugin>
118+
</plugins>
119+
</build>
120+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:base="ns.base"
5+
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
6+
xmlns:annox="http://annox.dev.java.net"
7+
targetNamespace="ns.base"
8+
attributeFormDefault="unqualified"
9+
elementFormDefault="unqualified"
10+
jaxb:extensionBindingPrefixes="annox"
11+
jaxb:version="1.0"
12+
>
13+
14+
<xsd:complexType name="BaseType">
15+
<xsd:all>
16+
<xsd:element name="textField" type="xsd:string">
17+
<xsd:annotation>
18+
<xsd:appinfo>
19+
<annox:annotate target="field">@javax.validation.constraints.NotNull</annox:annotate>
20+
</xsd:appinfo>
21+
</xsd:annotation>
22+
</xsd:element>
23+
</xsd:all>
24+
</xsd:complexType>
25+
26+
</xsd:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsd:schema
3+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
4+
xmlns:dependent="ns.dependent"
5+
xmlns:base="ns.base"
6+
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
7+
xmlns:annox="http://annox.dev.java.net"
8+
targetNamespace="ns.dependent"
9+
attributeFormDefault="unqualified"
10+
elementFormDefault="unqualified"
11+
jaxb:extensionBindingPrefixes="annox"
12+
jaxb:version="1.0"
13+
>
14+
15+
<xsd:import schemaLocation="base.xsd" namespace="ns.base" />
16+
17+
<xsd:element name="baseElement" type="base:BaseType" />
18+
19+
<xsd:complexType name="DependentType">
20+
<xsd:all>
21+
<xsd:element ref="dependent:baseElement">
22+
<xsd:annotation>
23+
<xsd:appinfo>
24+
<annox:annotate target="field">@javax.validation.constraints.NotNull</annox:annotate>
25+
</xsd:appinfo>
26+
</xsd:annotation>
27+
</xsd:element>
28+
</xsd:all>
29+
</xsd:complexType>
30+
31+
</xsd:schema>

jaxb-annotate-parent/tests/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<module>annotations</module>
4646
<module>annox</module>
4747
<module>annotate</module>
48+
<!--<module>base-dependent</module>--> <!-- not fixed in 2.3.9 jaxb-ri -->
4849
<module>issues</module>
4950
<module>one</module>
5051
</modules>

maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
public abstract class AbstractXJC2Mojo<O> extends AbstractMojo implements
4242
DependencyResourceResolver {
4343

44+
/**
45+
* This method should be overriden in extending classes to get real value
46+
* @return currently running XJC version
47+
*/
48+
public XJCVersion getVersion() {
49+
return XJCVersion.UNDEFINED;
50+
}
51+
4452
@Parameter(defaultValue = "${settings}", readonly = true)
4553
private Settings settings;
4654

@@ -435,8 +443,11 @@ public void setCatalogResolver(String catalogResolver) {
435443

436444
/**
437445
* If 'true', the fix for issue #306 will no more be applied.
446+
*
447+
* @deprecated (forRemoval = true, since = "2.0.10")
438448
*/
439-
@Parameter(defaultValue = "false", property = "maven.xjc2.disableSystemIdResolution")
449+
@Parameter(defaultValue = "true", property = "maven.xjc2.disableSystemIdResolution")
450+
@Deprecated
440451
private boolean disableSystemIdResolution;
441452

442453
public boolean getDisableSystemIdResolution() {
@@ -939,9 +950,13 @@ public void setEpisode(boolean episode) {
939950
* (via <code>scd="x-schema::..."</code>) in the generated episode files.
940951
* This is necessary to avoid the annoying `SCD "x-schema::tns" didn't
941952
* match any schema component` errors.
953+
*
954+
* @deprecated since 2.0.10 - this is kept for retro-compatibility but will be removed since
955+
* original bug has been resolved in 2.3.9 JAXB-RI
942956
*/
943-
@Parameter(property = "maven.xjc2.addIfExistsToEpisodeSchemaBindings", defaultValue = "true")
944-
private boolean addIfExistsToEpisodeSchemaBindings = true;
957+
@Deprecated
958+
@Parameter(property = "maven.xjc2.addIfExistsToEpisodeSchemaBindings", defaultValue = "false")
959+
private boolean addIfExistsToEpisodeSchemaBindings = false;
945960

946961
public boolean isAddIfExistsToEpisodeSchemaBindings() {
947962
return this.addIfExistsToEpisodeSchemaBindings;

maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,23 @@ public abstract class RawXJC2Mojo<O> extends AbstractXJC2Mojo<O> {
9595
public static final String ADD_IF_EXISTS_TO_EPISODE_SCHEMA_BINDINGS_TRANSFORMATION_RESOURCE_NAME = "/"
9696
+ RawXJC2Mojo.class.getPackage().getName().replace('.', '/') + "/addIfExistsToEpisodeSchemaBindings.xslt";
9797

98+
private final XJCVersion version;
99+
98100
private Collection<Artifact> xjcPluginArtifacts;
99101

100102
private Collection<File> xjcPluginFiles;
101103

102104
private List<URL> xjcPluginURLs;
103105

104-
public Collection<Artifact> getXjcPluginArtifacts() {
106+
public RawXJC2Mojo(XJCVersion version) {
107+
this.version = version;
108+
}
109+
110+
public XJCVersion getVersion() {
111+
return version;
112+
}
113+
114+
public Collection<Artifact> getXjcPluginArtifacts() {
105115
return xjcPluginArtifacts;
106116
}
107117

@@ -469,9 +479,9 @@ protected void doExecute() throws MojoExecutionException {
469479
} else {
470480
final boolean isUpToDate = isUpToDate();
471481
if (!isUpToDate) {
472-
getLog().info("Sources are not up-to-date, XJC will be executed.");
482+
getLog().info("Sources are not up-to-date, XJC (version " + getVersion().getRaw() + ") will be executed.");
473483
} else {
474-
getLog().info("Sources are up-to-date, XJC will be skipped.");
484+
getLog().info("Sources are up-to-date, XJC (version " + getVersion().getRaw() + ") will be skipped.");
475485
return;
476486
}
477487
}
@@ -893,7 +903,7 @@ private void setupEntityResolver() {
893903
}
894904

895905
protected EntityResolver createEntityResolver(CatalogResolver catalogResolver) {
896-
final EntityResolver entityResolver = new ReResolvingEntityResolverWrapper(catalogResolver, getLog(), getDisableSystemIdResolution());
906+
final EntityResolver entityResolver = new ReResolvingEntityResolverWrapper(catalogResolver, getLog(), getDisableSystemIdResolution(), getVersion());
897907
return entityResolver;
898908
}
899909

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package org.jvnet.jaxb.maven;
2+
3+
public class XJCVersion {
4+
public static final XJCVersion UNDEFINED = new XJCVersion(null);
5+
private String raw = "UNDEFINED";
6+
private int major;
7+
private int minor;
8+
private int bugfix;
9+
10+
public XJCVersion(String version) {
11+
if (version != null) {
12+
this.raw = version;
13+
int indexOfSnapshot = version.indexOf("-SNAPSHOT");
14+
if (indexOfSnapshot >= 0) {
15+
version = version.substring(0, indexOfSnapshot);
16+
}
17+
String[] split = version.split("\\.");
18+
if (split.length >= 3) {
19+
major = Integer.valueOf(split[0]);
20+
minor = Integer.valueOf(split[1]);
21+
bugfix = Integer.valueOf(split[2]);
22+
}
23+
}
24+
}
25+
26+
public String getRaw() {
27+
return raw;
28+
}
29+
30+
public int getMajor() {
31+
return major;
32+
}
33+
34+
public int getMinor() {
35+
return minor;
36+
}
37+
38+
public int getBugfix() {
39+
return bugfix;
40+
}
41+
42+
public boolean isKnown() {
43+
return !(this.major == 0 && this.minor == 0 && this.bugfix == 0);
44+
}
45+
46+
public boolean gte(int major, int minor, int bugfix) {
47+
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix >= bugfix);
48+
}
49+
50+
public boolean gt(int major, int minor, int bugfix) {
51+
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix > bugfix);
52+
}
53+
54+
public boolean lte(int major, int minor, int bugfix) {
55+
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix <= bugfix);
56+
}
57+
58+
public boolean lt(int major, int minor, int bugfix) {
59+
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix < bugfix);
60+
}
61+
}

0 commit comments

Comments
 (0)