From 42a81a60a3e831f1e80f2b7ec59b0787471b5a5e Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 1 Mar 2023 06:35:37 +0100 Subject: [PATCH] Fix maven BuildIT failures The dependency `stax-api` is not compatible with the dependency `quarkus-jaxb` because both add the same type `javax.xml.namespace.QName`. This was done on purpose to validate the `parent-first-artifacts` property when building projects with conflicts with Maven, so we need to skip the JaxbContext validation at build time. This pull request should fix all the CI failures in the latest pull requests. --- .../java/io/quarkus/jaxb/deployment/JaxbProcessor.java | 7 +++++-- .../src/main/java/io/quarkus/jaxb/runtime/JaxbConfig.java | 7 +++++++ .../src/main/resources/application.properties | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java index 9a9abbbe33632..4ab8f71950f88 100644 --- a/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java +++ b/extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java @@ -313,8 +313,11 @@ void setupJaxbContextConfig(JaxbConfig config, // parse class names to class Set> classes = getAllClassesFromClassNames(classNamesToBeBound); - // validate the context to fail at build time if it's not valid - validateContext(classes); + if (config.validateJaxbContext) { + // validate the context to fail at build time if it's not valid + validateContext(classes); + } + // register the classes to be used at runtime jaxbContextConfig.addClassesToBeBound(classes); } diff --git a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbConfig.java b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbConfig.java index e7465677c06a4..2c48016a10824 100644 --- a/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbConfig.java +++ b/extensions/jaxb/runtime/src/main/java/io/quarkus/jaxb/runtime/JaxbConfig.java @@ -9,6 +9,13 @@ @ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED, name = "jaxb") public class JaxbConfig { + + /** + * If enabled, it will validate the default JAXB context at build time. + */ + @ConfigItem(defaultValue = "true") + public boolean validateJaxbContext; + /** * Exclude classes to automatically be bound to the default JAXB context. */ diff --git a/integration-tests/maven/src/test/resources-filtered/projects/classloader-linkage-error/src/main/resources/application.properties b/integration-tests/maven/src/test/resources-filtered/projects/classloader-linkage-error/src/main/resources/application.properties index abd84162f5b9c..6db3bcc061c33 100644 --- a/integration-tests/maven/src/test/resources-filtered/projects/classloader-linkage-error/src/main/resources/application.properties +++ b/integration-tests/maven/src/test/resources-filtered/projects/classloader-linkage-error/src/main/resources/application.properties @@ -1 +1,5 @@ quarkus.class-loading.parent-first-artifacts=stax:stax-api +# The dependency `stax-api` is not compatible with the dependency `quarkus-jaxb` because both add the same +# type `javax.xml.namespace.QName`. This was done on purpose to validate the `parent-first-artifacts` property when building +# projects with conflicts with Maven, so we need to skip the JaxbContext validation at build time. +quarkus.jaxb.validate-jaxb-context=false