diff --git a/deployment/src/main/java/org/neo4j/ogm/quarkus/deployment/Neo4jOgmProcessor.java b/deployment/src/main/java/org/neo4j/ogm/quarkus/deployment/Neo4jOgmProcessor.java index 9980c65..704335d 100644 --- a/deployment/src/main/java/org/neo4j/ogm/quarkus/deployment/Neo4jOgmProcessor.java +++ b/deployment/src/main/java/org/neo4j/ogm/quarkus/deployment/Neo4jOgmProcessor.java @@ -69,7 +69,7 @@ EntitiesBuildItem findAnnotatedClasses(CombinedIndexBuildItem indexBuildItem, var classes = new TreeSet>(Comparator.comparing(Class::getName)); var ccl = Thread.currentThread().getContextClassLoader(); - Predicate packageFilter = buildTimeProperties.basePackages + Predicate packageFilter = buildTimeProperties.basePackages() .map(packages -> (Predicate) (DotName n) -> packages.contains(n.packagePrefix())) .orElseGet(() -> (DotName n) -> true); @@ -170,8 +170,8 @@ Neo4jOgmSessionFactoryBuildItem createSessionFactory(Neo4jOgmRecorder recorder, var allPackages = allClasses.getValue().stream().map(Class::getPackageName) .distinct().toArray(String[]::new); - if (allPackages.length == 0 && buildTimeProperties.basePackages.isPresent()) { - allPackages = buildTimeProperties.basePackages.get().toArray(new String[0]); + if (allPackages.length == 0 && buildTimeProperties.basePackages().isPresent()) { + allPackages = buildTimeProperties.basePackages().get().toArray(new String[0]); } var sessionFactoryRuntimeValue = recorder diff --git a/pom.xml b/pom.xml index 8defde3..a1f41ab 100644 --- a/pom.xml +++ b/pom.xml @@ -161,24 +161,6 @@ -parameters - - - default-compile - - true - - -Xlint:all,-options,-path,-processing,-classfile - -parameters - - -AlegacyConfigRoot=true - - - - org.apache.maven.plugins diff --git a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmBuiltTimeProperties.java b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmBuiltTimeProperties.java index 947b232..bb0f66d 100644 --- a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmBuiltTimeProperties.java +++ b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmBuiltTimeProperties.java @@ -15,9 +15,9 @@ */ package org.neo4j.ogm.quarkus.runtime; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; import java.util.List; import java.util.Optional; @@ -27,14 +27,15 @@ * * @author Michael J. Simons */ -@ConfigRoot(prefix = "org.neo4j", name = "ogm", phase = ConfigPhase.BUILD_TIME) -public class Neo4jOgmBuiltTimeProperties { +@ConfigMapping(prefix = "org.neo4j.ogm") +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +public interface Neo4jOgmBuiltTimeProperties { /** * An optional list of packages to scan. If empty, all classes annotated with * {@link org.neo4j.ogm.annotation.NodeEntity @NodeEntity} * or {@link org.neo4j.ogm.annotation.RelationshipEntity @RelationshipEntity} will be added to the index. + * @return the list of packages to scan */ - @ConfigItem - public Optional> basePackages; + Optional> basePackages(); } diff --git a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmConfigCustomizer.java b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmConfigCustomizer.java new file mode 100644 index 0000000..80ec661 --- /dev/null +++ b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmConfigCustomizer.java @@ -0,0 +1,35 @@ +/* + * Copyright 2022-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.neo4j.ogm.quarkus.runtime; + +import io.smallrye.config.SmallRyeConfigBuilder; +import io.smallrye.config.SmallRyeConfigBuilderCustomizer; + +/** + * Config customizer to ignore validation of unmapped properties between build-time and runtime. + * + * @author Michael J. Simons + * @author Roberto Cortez + * @see Neo4jOgmBuiltTimeProperties + * @see Neo4jOgmProperties + */ +public final class Neo4jOgmConfigCustomizer implements SmallRyeConfigBuilderCustomizer { + + @Override + public void configBuilder(final SmallRyeConfigBuilder builder) { + builder.withMappingIgnore("org.neo4j.ogm.**"); + } +} diff --git a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmProperties.java b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmProperties.java index 4b79e44..cd6aff5 100644 --- a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmProperties.java +++ b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmProperties.java @@ -15,9 +15,10 @@ */ package org.neo4j.ogm.quarkus.runtime; -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; import java.util.Optional; @@ -26,24 +27,24 @@ * * @author Michael J. Simons */ -@ConfigRoot(prefix = "org.neo4j", name = "ogm", phase = ConfigPhase.RUN_TIME) -public class Neo4jOgmProperties { +@ConfigMapping(prefix = "org.neo4j.ogm") +@ConfigRoot(phase = ConfigPhase.RUN_TIME) +public interface Neo4jOgmProperties { /** - * Should Neo4j native types be used for dates, times and similar? + * {@return whether Neo4j should use native types be used for dates, times and similar} */ - @ConfigItem(defaultValue = "false") - public boolean useNativeTypes; + @WithDefault("false") + boolean useNativeTypes(); /** - * This flag instructs OGM to use all static labels when querying domain objects. + * {@return a flag that instructs OGM to use all static labels when querying domain objects} */ - @ConfigItem(defaultValue = "false") - public boolean useStrictQuerying; + @WithDefault("false") + boolean useStrictQuerying(); /** - * The database that should be used (Neo4j EE 4.0+ only). Leave empty for using the default database. + * {@return the database that should be used (Neo4j EE 4.0+ only), Leave empty for using the default database} */ - @ConfigItem - public Optional database; + Optional database(); } diff --git a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmRecorder.java b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmRecorder.java index 34a11c7..8f6cc1b 100644 --- a/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmRecorder.java +++ b/runtime/src/main/java/org/neo4j/ogm/quarkus/runtime/Neo4jOgmRecorder.java @@ -50,11 +50,11 @@ public RuntimeValue initializeSessionFactory( // Actually not needed for the driver to work, but required for the config not to stumble upon null .uri(neo4jConfiguration.uri); - ogmProperties.database.ifPresent(builder::database); - if (ogmProperties.useNativeTypes) { + ogmProperties.database().ifPresent(builder::database); + if (ogmProperties.useNativeTypes()) { builder.useNativeTypes(); } - if (ogmProperties.useStrictQuerying) { + if (ogmProperties.useStrictQuerying()) { builder.strictQuerying(); } builder.withBasePackages(allPackages); diff --git a/runtime/src/main/resources/META-INF/services/io.smallrye.config.SmallRyeConfigBuilderCustomizer b/runtime/src/main/resources/META-INF/services/io.smallrye.config.SmallRyeConfigBuilderCustomizer new file mode 100644 index 0000000..dedaef6 --- /dev/null +++ b/runtime/src/main/resources/META-INF/services/io.smallrye.config.SmallRyeConfigBuilderCustomizer @@ -0,0 +1 @@ +org.neo4j.ogm.quarkus.runtime.Neo4jOgmConfigCustomizer