From 83e6e85786b3c0d8aad4007749587fd61f11cbd1 Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Tue, 17 Dec 2024 08:00:47 -0300 Subject: [PATCH] Convert jaxb to use @ConfigMapping --- extensions/jaxb/deployment/pom.xml | 3 --- .../io/quarkus/jaxb/deployment/JaxbProcessor.java | 6 +++--- extensions/jaxb/runtime/pom.xml | 3 --- .../java/io/quarkus/jaxb/runtime/JaxbConfig.java | 15 ++++++++------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/extensions/jaxb/deployment/pom.xml b/extensions/jaxb/deployment/pom.xml index 15589c3c49e5b..53d532adc436b 100644 --- a/extensions/jaxb/deployment/pom.xml +++ b/extensions/jaxb/deployment/pom.xml @@ -56,9 +56,6 @@ ${project.version} - - -AlegacyConfigRoot=true - 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 b08e753e7b3fa..aaf0c32bc958f 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 @@ -342,8 +342,8 @@ FilteredJaxbClassesToBeBoundBuildItem filterBoundClasses( .forEach(builder::classNames); // remove classes that have been excluded by users - if (config.excludeClasses.isPresent()) { - builder.classNameExcludes(config.excludeClasses.get()); + if (config.excludeClasses().isPresent()) { + builder.classNameExcludes(config.excludeClasses().get()); } return builder.build(); } @@ -362,7 +362,7 @@ void bindClassesToJaxbContext( .resolveBeans(Type.create(DotName.createSimple(JAXBContext.class), org.jboss.jandex.Type.Kind.CLASS)); if (!beans.isEmpty()) { jaxbContextConfig.addClassesToBeBound(filteredClassesToBeBound.getClasses()); - if (config.validateJaxbContext) { + if (config.validateJaxbContext()) { validateJaxbContext(filteredClassesToBeBound, beanResolver, beans); } } diff --git a/extensions/jaxb/runtime/pom.xml b/extensions/jaxb/runtime/pom.xml index 3c6144fcbb637..17ad6ef0aede2 100644 --- a/extensions/jaxb/runtime/pom.xml +++ b/extensions/jaxb/runtime/pom.xml @@ -71,9 +71,6 @@ ${project.version} - - -AlegacyConfigRoot=true - 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 10aee70162135..dc456f329460b 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 @@ -3,24 +3,25 @@ import java.util.List; import java.util.Optional; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; -@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED, name = "jaxb") -public class JaxbConfig { +@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) +@ConfigMapping(prefix = "quarkus.jaxb") +public interface JaxbConfig { /** * If enabled, it will validate the default JAXB context at build time. */ - @ConfigItem(defaultValue = "false") - public boolean validateJaxbContext; + @WithDefault("false") + boolean validateJaxbContext(); /** * Exclude classes to automatically be bound to the default JAXB context. * Values with suffix {@code .*}, i.e. {@code org.acme.*}, are considered packages and exclude all classes that are members * of these packages */ - @ConfigItem - public Optional> excludeClasses; + Optional> excludeClasses(); }