Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#437] upgrade to jaxb-ri 2.3.9 #500

Merged
merged 5 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jvnet.jaxb</groupId>
Expand Down Expand Up @@ -59,6 +59,7 @@
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>hyperjaxb3-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
Expand Down
120 changes: 120 additions & 0 deletions jaxb-annotate-parent/tests/base-dependent/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-annotate-plugin-tests</artifactId>
<version>2.0.10-SNAPSHOT</version>
</parent>
<artifactId>jaxb-annotate-plugin-test-base-dependent</artifactId>
<packaging>jar</packaging>
<name>JAXB Tools :: Annotate :: Test [base-dependent]</name>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-annotate</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<build>
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<executions>
<execution>
<id>base</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<addIfExistsToEpisodeSchemaBindings>false</addIfExistsToEpisodeSchemaBindings>
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
<schemaIncludes>
<include>base.xsd</include>
</schemaIncludes>
<generatePackage>org.test.base</generatePackage>
<encoding>UTF-8</encoding>
<extension>true</extension>
<episode>true</episode>
<episodeFile>${basedir}/target/generated-sources/xjc/META-INF/base.xjb</episodeFile>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-annotate</artifactId>
</plugin>
</plugins>
</configuration>
</execution>

<execution>
<id>dependent</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/xsd</schemaDirectory>
<schemaIncludes>
<include>dependent.xsd</include>
</schemaIncludes>
<generatePackage>org.test.dependent</generatePackage>
<encoding>UTF-8</encoding>
<bindings>
<binding>
<fileset>
<directory>${basedir}/target/generated-sources/xjc/META-INF</directory>
<includes>
<include>*.xjb</include>
</includes>
</fileset>
</binding>
</bindings>
<extension>true</extension>
<episode>true</episode>
<episodeFile>${basedir}/target/generated-sources/xjc/META-INF/dependent.xjb</episodeFile>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<plugin>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-annotate</artifactId>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:base="ns.base"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:annox="http://annox.dev.java.net"
targetNamespace="ns.base"
attributeFormDefault="unqualified"
elementFormDefault="unqualified"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="1.0"
>

<xsd:complexType name="BaseType">
<xsd:all>
<xsd:element name="textField" type="xsd:string">
<xsd:annotation>
<xsd:appinfo>
<annox:annotate target="field">@javax.validation.constraints.NotNull</annox:annotate>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:all>
</xsd:complexType>

</xsd:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:dependent="ns.dependent"
xmlns:base="ns.base"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:annox="http://annox.dev.java.net"
targetNamespace="ns.dependent"
attributeFormDefault="unqualified"
elementFormDefault="unqualified"
jaxb:extensionBindingPrefixes="annox"
jaxb:version="1.0"
>

<xsd:import schemaLocation="base.xsd" namespace="ns.base" />

<xsd:element name="baseElement" type="base:BaseType" />

<xsd:complexType name="DependentType">
<xsd:all>
<xsd:element ref="dependent:baseElement">
<xsd:annotation>
<xsd:appinfo>
<annox:annotate target="field">@javax.validation.constraints.NotNull</annox:annotate>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:all>
</xsd:complexType>

</xsd:schema>
1 change: 1 addition & 0 deletions jaxb-annotate-parent/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<module>annotations</module>
<module>annox</module>
<module>annotate</module>
<!--<module>base-dependent</module>--> <!-- not fixed in 2.3.9 jaxb-ri -->
<module>issues</module>
<module>one</module>
</modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@
public abstract class AbstractXJC2Mojo<O> extends AbstractMojo implements
DependencyResourceResolver {

/**
* This method should be overriden in extending classes to get real value
* @return currently running XJC version
*/
public XJCVersion getVersion() {
return XJCVersion.UNDEFINED;
}

@Parameter(defaultValue = "${settings}", readonly = true)
private Settings settings;

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

/**
* If 'true', the fix for issue #306 will no more be applied.
*
* @deprecated (forRemoval = true, since = "2.0.10")
*/
@Parameter(defaultValue = "false", property = "maven.xjc2.disableSystemIdResolution")
@Parameter(defaultValue = "true", property = "maven.xjc2.disableSystemIdResolution")
@Deprecated
private boolean disableSystemIdResolution;

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

public boolean isAddIfExistsToEpisodeSchemaBindings() {
return this.addIfExistsToEpisodeSchemaBindings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,23 @@ public abstract class RawXJC2Mojo<O> extends AbstractXJC2Mojo<O> {
public static final String ADD_IF_EXISTS_TO_EPISODE_SCHEMA_BINDINGS_TRANSFORMATION_RESOURCE_NAME = "/"
+ RawXJC2Mojo.class.getPackage().getName().replace('.', '/') + "/addIfExistsToEpisodeSchemaBindings.xslt";

private final XJCVersion version;

private Collection<Artifact> xjcPluginArtifacts;

private Collection<File> xjcPluginFiles;

private List<URL> xjcPluginURLs;

public Collection<Artifact> getXjcPluginArtifacts() {
public RawXJC2Mojo(XJCVersion version) {
this.version = version;
}

public XJCVersion getVersion() {
return version;
}

public Collection<Artifact> getXjcPluginArtifacts() {
return xjcPluginArtifacts;
}

Expand Down Expand Up @@ -469,9 +479,9 @@ protected void doExecute() throws MojoExecutionException {
} else {
final boolean isUpToDate = isUpToDate();
if (!isUpToDate) {
getLog().info("Sources are not up-to-date, XJC will be executed.");
getLog().info("Sources are not up-to-date, XJC (version " + getVersion().getRaw() + ") will be executed.");
} else {
getLog().info("Sources are up-to-date, XJC will be skipped.");
getLog().info("Sources are up-to-date, XJC (version " + getVersion().getRaw() + ") will be skipped.");
return;
}
}
Expand Down Expand Up @@ -893,7 +903,7 @@ private void setupEntityResolver() {
}

protected EntityResolver createEntityResolver(CatalogResolver catalogResolver) {
final EntityResolver entityResolver = new ReResolvingEntityResolverWrapper(catalogResolver, getLog(), getDisableSystemIdResolution());
final EntityResolver entityResolver = new ReResolvingEntityResolverWrapper(catalogResolver, getLog(), getDisableSystemIdResolution(), getVersion());
return entityResolver;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.jvnet.jaxb.maven;

public class XJCVersion {
public static final XJCVersion UNDEFINED = new XJCVersion(null);
private String raw = "UNDEFINED";
private int major;
private int minor;
private int bugfix;

public XJCVersion(String version) {
if (version != null) {
this.raw = version;
int indexOfSnapshot = version.indexOf("-SNAPSHOT");
if (indexOfSnapshot >= 0) {
version = version.substring(0, indexOfSnapshot);
}
String[] split = version.split("\\.");
if (split.length >= 3) {
major = Integer.valueOf(split[0]);
minor = Integer.valueOf(split[1]);
bugfix = Integer.valueOf(split[2]);
}
}
}

public String getRaw() {
return raw;
}

public int getMajor() {
return major;
}

public int getMinor() {
return minor;
}

public int getBugfix() {
return bugfix;
}

public boolean isKnown() {
return !(this.major == 0 && this.minor == 0 && this.bugfix == 0);
}

public boolean gte(int major, int minor, int bugfix) {
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix >= bugfix);
}

public boolean gt(int major, int minor, int bugfix) {
return this.major > major || (this.major == major && this.minor > minor) || (this.major == major && this.minor == minor && this.bugfix > bugfix);
}

public boolean lte(int major, int minor, int bugfix) {
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix <= bugfix);
}

public boolean lt(int major, int minor, int bugfix) {
return this.major < major || (this.major == major && this.minor < minor) || (this.major == major && this.minor == minor && this.bugfix < bugfix);
}
}
Loading
Loading