diff --git a/hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml b/hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml index af59a2da0..4ae263264 100644 --- a/hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml +++ b/hyperjaxb/ejb/samples/po-customized-toplink/project-pom.xml @@ -1,5 +1,5 @@ - 4.0.0 org.jvnet.jaxb @@ -59,6 +59,7 @@ org.jvnet.jaxb hyperjaxb3-maven-plugin + ${project.version} diff --git a/jaxb-annotate-parent/tests/base-dependent/pom.xml b/jaxb-annotate-parent/tests/base-dependent/pom.xml new file mode 100644 index 000000000..d5ed99934 --- /dev/null +++ b/jaxb-annotate-parent/tests/base-dependent/pom.xml @@ -0,0 +1,120 @@ + + 4.0.0 + + org.jvnet.jaxb + jaxb-annotate-plugin-tests + 2.0.10-SNAPSHOT + + jaxb-annotate-plugin-test-base-dependent + jar + JAXB Tools :: Annotate :: Test [base-dependent] + + + org.glassfish.jaxb + jaxb-runtime + + + org.glassfish.jaxb + jaxb-xjc + + + org.jvnet.jaxb + jaxb-maven-plugin-testing + test + + + org.jvnet.jaxb + jaxb-basics-annotate + + + javax.validation + validation-api + 2.0.1.Final + + + + test + + + org.jvnet.jaxb + jaxb-maven-plugin + + + base + + generate + + + false + ${basedir}/src/main/resources/xsd + + base.xsd + + org.test.base + UTF-8 + true + true + ${basedir}/target/generated-sources/xjc/META-INF/base.xjb + + -Xannotate + + + + javax.validation + validation-api + + + org.jvnet.jaxb + jaxb-basics-annotate + + + + + + + dependent + + generate + + + ${basedir}/src/main/resources/xsd + + dependent.xsd + + org.test.dependent + UTF-8 + + + + ${basedir}/target/generated-sources/xjc/META-INF + + *.xjb + + + + + true + true + ${basedir}/target/generated-sources/xjc/META-INF/dependent.xjb + + -Xannotate + + + + javax.validation + validation-api + + + org.jvnet.jaxb + jaxb-basics-annotate + + + + + + + + + diff --git a/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/base.xsd b/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/base.xsd new file mode 100644 index 000000000..26293abf0 --- /dev/null +++ b/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/base.xsd @@ -0,0 +1,26 @@ + + + + + + + + + @javax.validation.constraints.NotNull + + + + + + + diff --git a/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/dependent.xsd b/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/dependent.xsd new file mode 100644 index 000000000..6f9b86069 --- /dev/null +++ b/jaxb-annotate-parent/tests/base-dependent/src/main/resources/xsd/dependent.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + @javax.validation.constraints.NotNull + + + + + + + diff --git a/jaxb-annotate-parent/tests/pom.xml b/jaxb-annotate-parent/tests/pom.xml index 872cdb49f..6c1e0dbbd 100644 --- a/jaxb-annotate-parent/tests/pom.xml +++ b/jaxb-annotate-parent/tests/pom.xml @@ -45,6 +45,7 @@ annotations annox annotate + issues one diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java index 2117cb54d..4ed14588f 100644 --- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java +++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/AbstractXJC2Mojo.java @@ -41,6 +41,14 @@ public abstract class AbstractXJC2Mojo 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; @@ -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() { @@ -939,9 +950,13 @@ public void setEpisode(boolean episode) { * (via scd="x-schema::...") 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; diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java index de2dbe3bd..4d1c965e8 100644 --- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java +++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/RawXJC2Mojo.java @@ -95,13 +95,23 @@ public abstract class RawXJC2Mojo extends AbstractXJC2Mojo { 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 xjcPluginArtifacts; private Collection xjcPluginFiles; private List xjcPluginURLs; - public Collection getXjcPluginArtifacts() { + public RawXJC2Mojo(XJCVersion version) { + this.version = version; + } + + public XJCVersion getVersion() { + return version; + } + + public Collection getXjcPluginArtifacts() { return xjcPluginArtifacts; } @@ -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; } } @@ -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; } diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/XJCVersion.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/XJCVersion.java new file mode 100644 index 000000000..16199df63 --- /dev/null +++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/XJCVersion.java @@ -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); + } +} diff --git a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/resolver/tools/ReResolvingEntityResolverWrapper.java b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/resolver/tools/ReResolvingEntityResolverWrapper.java index c868779c6..64a304056 100644 --- a/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/resolver/tools/ReResolvingEntityResolverWrapper.java +++ b/maven-plugin/plugin-core/src/main/java/org/jvnet/jaxb/maven/resolver/tools/ReResolvingEntityResolverWrapper.java @@ -5,6 +5,7 @@ import java.util.Optional; import org.apache.maven.plugin.logging.Log; +import org.jvnet.jaxb.maven.XJCVersion; import org.jvnet.jaxb.maven.plugin.logging.NullLog; import org.jvnet.jaxb.maven.util.StringUtils; import org.xml.sax.EntityResolver; @@ -17,21 +18,41 @@ public class ReResolvingEntityResolverWrapper implements EntityResolver { private final Log log; private final boolean disableSystemIdResolution; - public ReResolvingEntityResolverWrapper(EntityResolver entityResolver, Log log, boolean disableSystemIdResolution) { + public ReResolvingEntityResolverWrapper(EntityResolver entityResolver, Log log, boolean disableSystemIdResolution, XJCVersion version) { if (entityResolver == null) { throw new IllegalArgumentException("Provided entity resolver must not be null."); } this.entityResolver = entityResolver; this.log = Optional.ofNullable(log).orElse(NullLog.INSTANCE); - this.disableSystemIdResolution = disableSystemIdResolution; - if (disableSystemIdResolution) { - log.warn("ReResolvingEntityResolverWrapper : systemIdResolution fix is disable, you may have problems with schema resolution."); + this.disableSystemIdResolution = computeDisableSystemIdResolution(disableSystemIdResolution, version); + } + + private boolean computeDisableSystemIdResolution(boolean disableSystemIdResolution, XJCVersion version) { + boolean finalDisableSystemIdResolution = disableSystemIdResolution; + boolean versionCheck = false; + if (version.isKnown()) { + versionCheck = true; + if (version.gte(2, 3, 9) && !disableSystemIdResolution) { + log.info("ReResolvingEntityResolverWrapper : systemIdResolution fix has been auto-disabled (current running XJC is " + version.getRaw() + ")."); + finalDisableSystemIdResolution = true; + } else if (version.gte(2, 3, 4) && version.lt(2, 3, 9) && disableSystemIdResolution) { + log.info("ReResolvingEntityResolverWrapper : systemIdResolution fix has been auto-enabled (current running XJC is " + version.getRaw() + ")."); + finalDisableSystemIdResolution = false; + } + } + if (finalDisableSystemIdResolution) { + if (!versionCheck) { + log.warn("ReResolvingEntityResolverWrapper : systemIdResolution fix is disable, you may have problems with schema resolution."); + } else { + log.debug("ReResolvingEntityResolverWrapper : systemIdResolution fix is disabled"); + } } else { log.debug("ReResolvingEntityResolverWrapper : systemIdResolution fix is enabled"); } - } + return finalDisableSystemIdResolution; + } - @Override + @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { log.debug(MessageFormat.format("ReResolvingEntityResolverWrapper : Resolving publicId [{0}], systemId [{1}].", publicId, systemId)); diff --git a/maven-plugin/plugin-core/src/test/java/org/jvnet/jaxb/maven/RawXJC2MojoTest.java b/maven-plugin/plugin-core/src/test/java/org/jvnet/jaxb/maven/RawXJC2MojoTest.java index 828ddda65..b23d2c385 100644 --- a/maven-plugin/plugin-core/src/test/java/org/jvnet/jaxb/maven/RawXJC2MojoTest.java +++ b/maven-plugin/plugin-core/src/test/java/org/jvnet/jaxb/maven/RawXJC2MojoTest.java @@ -50,7 +50,7 @@ public void createJarFile() throws Exception { public void collectBindingUrisFromDependencies() throws Exception { List bindings = new ArrayList<>(); - final RawXJC2Mojo mojo = new RawXJC2Mojo() { + final RawXJC2Mojo mojo = new RawXJC2Mojo(XJCVersion.UNDEFINED) { @Override public MavenProject getProject() { @@ -106,7 +106,7 @@ public void doExecute(Void options) throws MojoExecutionException { public void collectsBindingUrisFromArtifact() throws Exception { List bindings = new ArrayList<>(); - final RawXJC2Mojo mojo = new RawXJC2Mojo() { + final RawXJC2Mojo mojo = new RawXJC2Mojo(XJCVersion.UNDEFINED) { @Override protected IOptionsFactory getOptionsFactory() { diff --git a/maven-plugin/plugin/src/main/java/org/jvnet/jaxb/maven/XJC2Mojo.java b/maven-plugin/plugin/src/main/java/org/jvnet/jaxb/maven/XJC2Mojo.java index 1464bab4a..22df92e45 100644 --- a/maven-plugin/plugin/src/main/java/org/jvnet/jaxb/maven/XJC2Mojo.java +++ b/maven-plugin/plugin/src/main/java/org/jvnet/jaxb/maven/XJC2Mojo.java @@ -5,6 +5,7 @@ import java.text.MessageFormat; import java.util.Iterator; +import com.sun.tools.xjc.Messages; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; @@ -29,7 +30,15 @@ public class XJC2Mojo extends RawXJC2Mojo { private final IOptionsFactory optionsFactory = new OptionsFactory(); - @Override + public XJC2Mojo() { + super(parseXJCVersion()); + } + + private static XJCVersion parseXJCVersion() { + return new XJCVersion(Messages.format("Driver.BuildID")); + } + + @Override protected IOptionsFactory getOptionsFactory() { return optionsFactory; } diff --git a/maven-plugin/tests/javadoc/pom.xml b/maven-plugin/tests/javadoc/pom.xml new file mode 100644 index 000000000..1aef20fa7 --- /dev/null +++ b/maven-plugin/tests/javadoc/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + jaxb-maven-plugin-tests-javadoc + + org.jvnet.jaxb + jaxb-maven-plugin-tests + 2.0.10-SNAPSHOT + ../pom.xml + + jar + JAXB Tools :: Maven Plugin :: Test [javadoc] + + + jakarta.xml.bind + jakarta.xml.bind-api + + + org.glassfish.jaxb + jaxb-runtime + + + + + + org.jvnet.jaxb + jaxb-maven-plugin + + + + diff --git a/maven-plugin/tests/javadoc/src/main/resources/schema.xsd b/maven-plugin/tests/javadoc/src/main/resources/schema.xsd new file mode 100644 index 000000000..3d101d928 --- /dev/null +++ b/maven-plugin/tests/javadoc/src/main/resources/schema.xsd @@ -0,0 +1,16 @@ + + + + + + My awesome complex type comment. + + + + + My awesome element comment. + + + + + diff --git a/maven-plugin/tests/javadoc/src/test/resources/log4j.properties b/maven-plugin/tests/javadoc/src/test/resources/log4j.properties new file mode 100644 index 000000000..19d0433be --- /dev/null +++ b/maven-plugin/tests/javadoc/src/test/resources/log4j.properties @@ -0,0 +1,8 @@ +log4j.rootCategory=DEBUG, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.target=system.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%m%n %c%n%n +log4j.logger.org.apache.commons.digester=INFO +log4j.logger.org.jvnet.hyperjaxb3=DEBUG +log4j.logger.org.hibernate=WARN diff --git a/maven-plugin/tests/pom.xml b/maven-plugin/tests/pom.xml index 290a24054..546d7ef65 100644 --- a/maven-plugin/tests/pom.xml +++ b/maven-plugin/tests/pom.xml @@ -31,6 +31,7 @@ catalog-xml episodes issues + javadoc p_o po-2.3 po-scd diff --git a/pom.xml b/pom.xml index 5c66b538c..4ced3b946 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ 1.10.12 1.4.5 - 2.3.8 + 2.3.9 3.0.12 1.9.4