From 11bd532b05d3bf17c4d9045a757b2b67f0ea4e4c Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Fri, 23 Feb 2024 23:48:07 +0000 Subject: [PATCH] Do not expand configuration for Gradle cache --- .../extension/QuarkusPluginExtension.java | 2 +- .../tasks/AbstractQuarkusExtension.java | 35 ++++++++++++++++++- .../io/quarkus/gradle/tasks/BaseConfig.java | 8 ++--- .../java/io/quarkus/gradle/tasks/Deploy.java | 3 +- .../quarkus/gradle/tasks/EffectiveConfig.java | 34 ++++++++++-------- .../tasks/QuarkusBuildDependencies.java | 20 ++++++----- .../gradle/tasks/QuarkusBuildTask.java | 22 ++++++------ .../gradle/tasks/QuarkusGenerateCode.java | 6 ++-- .../io/quarkus/gradle/tasks/QuarkusRun.java | 3 +- .../tasks/QuarkusShowEffectiveConfig.java | 22 ++++++------ .../gradle/tasks/EffectiveConfigTest.java | 20 +++++------ 11 files changed, 107 insertions(+), 68 deletions(-) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java index 1a6c34842d24c..718a53f8798f9 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java @@ -73,7 +73,7 @@ public void beforeTest(Test task) { Map props = task.getSystemProperties(); ApplicationModel appModel = getApplicationModel(TEST); - SmallRyeConfig config = buildEffectiveConfiguration(appModel.getAppArtifact()).config(); + SmallRyeConfig config = buildEffectiveConfiguration(appModel.getAppArtifact()).getConfig(); config.getOptionalValue(TEST.getProfileKey(), String.class) .ifPresent(value -> props.put(TEST.getProfileKey(), value)); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java index f2696a9266f23..85f67e430dfc1 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java @@ -1,12 +1,17 @@ package io.quarkus.gradle.tasks; import static io.quarkus.gradle.tasks.QuarkusGradleUtils.getSourceSet; +import static io.smallrye.common.expression.Expression.Flag.DOUBLE_COLON; +import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX; +import static io.smallrye.common.expression.Expression.Flag.NO_SMART_BRACES; +import static io.smallrye.common.expression.Expression.Flag.NO_TRIM; import static java.util.Collections.emptyList; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -24,6 +29,7 @@ import io.quarkus.gradle.dsl.Manifest; import io.quarkus.maven.dependency.ResolvedDependency; +import io.smallrye.common.expression.Expression; /** * This base class exists to hide internal properties, make those only available in the {@link io.quarkus.gradle.tasks} @@ -138,7 +144,7 @@ private EffectiveConfig buildEffectiveConfiguration(Map properti * @param appArtifact the application dependency to retrive the quarkus application name and version. * @return a filtered view of the configuration only with quarkus. names. */ - protected Map buildSystemProperties(ResolvedDependency appArtifact) { + protected Map buildSystemProperties(ResolvedDependency appArtifact, Map quarkusProperties) { Map buildSystemProperties = new HashMap<>(); buildSystemProperties.putIfAbsent("quarkus.application.name", appArtifact.getArtifactId()); buildSystemProperties.putIfAbsent("quarkus.application.version", appArtifact.getVersion()); @@ -158,6 +164,33 @@ protected Map buildSystemProperties(ResolvedDependency appArtifa buildSystemProperties.put(entry.getKey(), entry.getValue().toString()); } } + + Set quarkusValues = new HashSet<>(); + quarkusValues.addAll(quarkusProperties.values()); + quarkusValues.addAll(buildSystemProperties.values()); + + for (String value : quarkusValues) { + Expression expression = Expression.compile(value, LENIENT_SYNTAX, NO_TRIM, NO_SMART_BRACES, DOUBLE_COLON); + for (String reference : expression.getReferencedStrings()) { + String expanded = forcedPropertiesProperty.get().get(reference); + if (expanded != null) { + buildSystemProperties.put(reference, expanded); + continue; + } + + expanded = quarkusBuildProperties.get().get(reference); + if (expanded != null) { + buildSystemProperties.put(reference, expanded); + continue; + } + + expanded = (String) project.getProperties().get(reference); + if (expanded != null) { + buildSystemProperties.put(reference, expanded); + } + } + } + return buildSystemProperties; } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java index 90c229c043b9b..5e0d9533e92dc 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/BaseConfig.java @@ -21,20 +21,20 @@ final class BaseConfig { private final Manifest manifest; private final PackageConfig packageConfig; - private final Map configMap; + private final Map values; // Note: EffectiveConfig has all the code to load the configurations from all the sources. BaseConfig(EffectiveConfig config) { manifest = new Manifest(); packageConfig = new PackageConfig(); - ConfigInstantiator.handleObject(packageConfig, config.config()); + ConfigInstantiator.handleObject(packageConfig, config.getConfig()); // populate the Gradle Manifest object manifest.attributes(packageConfig.manifest.attributes); packageConfig.manifest.manifestSections.forEach((section, attribs) -> manifest.attributes(attribs, section)); - configMap = config.configMap(); + values = config.getValues(); } PackageConfig packageConfig() { @@ -53,7 +53,7 @@ Map cachingRelevantProperties(List propertyPatterns) { List patterns = propertyPatterns.stream().map(s -> "^(" + s + ")$").map(Pattern::compile) .collect(Collectors.toList()); Predicate> keyPredicate = e -> patterns.stream().anyMatch(p -> p.matcher(e.getKey()).matches()); - return configMap.entrySet().stream() + return values.entrySet().stream() .filter(keyPredicate) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java index 132d956279771..d5b13e65e4a06 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java @@ -90,9 +90,8 @@ public Deploy() { @TaskAction public void checkRequiredExtensions() { ApplicationModel appModel = resolveAppModelForBuild(); - Map configMap = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).configMap(); Properties sysProps = new Properties(); - sysProps.putAll(configMap); + sysProps.putAll(extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getValues()); try (CuratedApplication curatedApplication = QuarkusBootstrap.builder() .setBaseClassLoader(getClass().getClassLoader()) .setExistingModel(appModel) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java index 1166d55e410d3..1c67c52ac4637 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Supplier; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.ConfigSourceProvider; @@ -26,6 +27,7 @@ import io.quarkus.runtime.configuration.ConfigUtils; import io.smallrye.config.AbstractLocationConfigSourceLoader; import io.smallrye.config.EnvConfigSource; +import io.smallrye.config.Expressions; import io.smallrye.config.PropertiesConfigSource; import io.smallrye.config.PropertiesConfigSourceProvider; import io.smallrye.config.SmallRyeConfig; @@ -42,9 +44,8 @@ * the Quarkus config objects like {@link PackageConfig}, {@link ClassLoadingConfig} and the underlying {@link SmallRyeConfig}. */ public final class EffectiveConfig { - private final Map fullConfig; - private final SmallRyeConfig config; + private final Map values; private EffectiveConfig(Builder builder) { List configSources = new ArrayList<>(); @@ -81,13 +82,17 @@ private EffectiveConfig(Builder builder) { .addAll(PropertiesConfigSourceProvider.classPathSources(META_INF_MICROPROFILE_CONFIG_PROPERTIES, classLoader)); this.config = buildConfig(builder.profile, configSources); - this.fullConfig = generateFullConfigMap(config); + this.values = generateFullConfigMap(config); } - public SmallRyeConfig config() { + public SmallRyeConfig getConfig() { return config; } + public Map getValues() { + return values; + } + private Map asStringMap(Map map) { Map target = new HashMap<>(); map.forEach((k, v) -> { @@ -100,14 +105,19 @@ private Map asStringMap(Map map) { @VisibleForTesting static Map generateFullConfigMap(SmallRyeConfig config) { - Map map = new HashMap<>(); - config.getPropertyNames().forEach(property -> { - String v = config.getConfigValue(property).getValue(); - if (v != null) { - map.put(property, v); + return Expressions.withoutExpansion(new Supplier>() { + @Override + public Map get() { + Map properties = new HashMap<>(); + for (String propertyName : config.getPropertyNames()) { + String value = config.getRawValue(propertyName); + if (value != null) { + properties.put(propertyName, value); + } + } + return unmodifiableMap(properties); } }); - return unmodifiableMap(map); } @VisibleForTesting @@ -126,10 +136,6 @@ static Builder builder() { return new Builder(); } - public Map configMap() { - return fullConfig; - } - static final class Builder { private Map buildProperties = emptyMap(); private Map projectProperties = emptyMap(); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java index a410e1af41270..d18dd3c70636f 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java @@ -24,6 +24,7 @@ import io.quarkus.maven.dependency.ArtifactKey; import io.quarkus.maven.dependency.DependencyFlags; import io.quarkus.maven.dependency.ResolvedDependency; +import io.smallrye.config.SmallRyeConfig; /** * Collect the Quarkus app dependencies, the contents of the {@code quarkus-app/lib} folder, without making the task @@ -139,22 +140,23 @@ private void jarDependencies(Path libBoot, Path libMain) { } ApplicationModel appModel = resolveAppModelForBuild(); - Map configMap = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).configMap(); + SmallRyeConfig config = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getConfig(); // see https://quarkus.io/guides/class-loading-reference#configuring-class-loading - Set removedArtifacts = java.util.Optional.ofNullable( - configMap.getOrDefault(CLASS_LOADING_REMOVED_ARTIFACTS, null)) + Set removedArtifacts = config.getOptionalValue(CLASS_LOADING_REMOVED_ARTIFACTS, String.class) .map(QuarkusBuildDependencies::dependenciesListToArtifactKeySet) .orElse(Collections.emptySet()); - getLogger().info("Removed artifacts: {}", configMap.getOrDefault(CLASS_LOADING_REMOVED_ARTIFACTS, "(none)")); + getLogger().info("Removed artifacts: {}", + config.getOptionalValue(CLASS_LOADING_REMOVED_ARTIFACTS, String.class).orElse("(none)")); - String parentFirstArtifactsProp = configMap.getOrDefault(CLASS_LOADING_PARENT_FIRST_ARTIFACTS, ""); + String parentFirstArtifactsProp = config.getOptionalValue(CLASS_LOADING_PARENT_FIRST_ARTIFACTS, String.class) + .orElse(""); Set parentFirstArtifacts = dependenciesListToArtifactKeySet(parentFirstArtifactsProp); - getLogger().info("parent first artifacts: {}", configMap.getOrDefault(CLASS_LOADING_PARENT_FIRST_ARTIFACTS, "(none)")); + getLogger().info("parent first artifacts: {}", + config.getOptionalValue(CLASS_LOADING_PARENT_FIRST_ARTIFACTS, String.class).orElse("(none)")); - String optionalDependenciesProp = configMap.getOrDefault(INCLUDED_OPTIONAL_DEPENDENCIES, ""); - boolean filterOptionalDependencies = Boolean - .parseBoolean(configMap.getOrDefault(FILTER_OPTIONAL_DEPENDENCIES, "false")); + String optionalDependenciesProp = config.getOptionalValue(INCLUDED_OPTIONAL_DEPENDENCIES, String.class).orElse(""); + boolean filterOptionalDependencies = config.getOptionalValue(FILTER_OPTIONAL_DEPENDENCIES, Boolean.class).orElse(false); Set optionalDependencies = filterOptionalDependencies ? dependenciesListToArtifactKeySet(optionalDependenciesProp) : Collections.emptySet(); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java index 88196dbba173a..827ace86ae845 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java @@ -29,6 +29,7 @@ import io.quarkus.gradle.tasks.worker.BuildWorker; import io.quarkus.maven.dependency.GACTV; import io.smallrye.config.Expressions; +import io.smallrye.config.SmallRyeConfig; /** * Base class for the {@link QuarkusBuildDependencies}, {@link QuarkusBuildCacheableAppParts}, {@link QuarkusBuild} tasks @@ -207,30 +208,29 @@ void generateBuild() { }); ApplicationModel appModel = resolveAppModelForBuild(); - Map configMap = new HashMap<>(); - EffectiveConfig effectiveConfig = extension().buildEffectiveConfiguration(appModel.getAppArtifact()); - Expressions.withoutExpansion(() -> { - for (Map.Entry entry : effectiveConfig.configMap().entrySet()) { - if (entry.getKey().startsWith("quarkus.")) { - configMap.put(entry.getKey(), effectiveConfig.config().getRawValue(entry.getKey())); - } - } + SmallRyeConfig config = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getConfig(); + Map quarkusProperties = Expressions.withoutExpansion(() -> { + Map values = new HashMap<>(); + config.getValues("quarkus", String.class, String.class) + .forEach((key, value) -> values.put("quarkus." + key, value)); + return values; }); getLogger().info("Starting Quarkus application build for package type {}", packageType); if (getLogger().isEnabled(LogLevel.INFO)) { getLogger().info("Effective properties: {}", - configMap.entrySet().stream() + quarkusProperties.entrySet().stream() .map(Object::toString) .sorted() .collect(Collectors.joining("\n ", "\n ", ""))); } - WorkQueue workQueue = workQueue(configMap, () -> extension().buildForkOptions); + WorkQueue workQueue = workQueue(quarkusProperties, () -> extension().buildForkOptions); workQueue.submit(BuildWorker.class, params -> { - params.getBuildSystemProperties().putAll(extension().buildSystemProperties(appModel.getAppArtifact())); + params.getBuildSystemProperties() + .putAll(extension().buildSystemProperties(appModel.getAppArtifact(), quarkusProperties)); params.getBaseName().set(extension().finalName()); params.getTargetDirectory().set(buildDir.toFile()); params.getAppModel().set(appModel); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java index b01ffdb6732f0..1b1cc049c8bd5 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java @@ -102,17 +102,17 @@ public Set getInputDirectory() { @TaskAction public void generateCode() { ApplicationModel appModel = extension().getApplicationModel(launchMode); - Map configMap = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).configMap(); + Map values = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getValues(); File outputPath = getGeneratedOutputDirectory().get().getAsFile(); getLogger().debug("Will trigger preparing sources for source directories: {} buildDir: {}", sourcesDirectories, buildDir.getAbsolutePath()); - WorkQueue workQueue = workQueue(configMap, () -> extension().codeGenForkOptions); + WorkQueue workQueue = workQueue(values, () -> extension().codeGenForkOptions); workQueue.submit(CodeGenWorker.class, params -> { - params.getBuildSystemProperties().putAll(configMap); + params.getBuildSystemProperties().putAll(values); params.getBaseName().set(extension().finalName()); params.getTargetDirectory().set(buildDir); params.getAppModel().set(appModel); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java index ea37bcb6875d2..5935f9d46caea 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java @@ -100,9 +100,8 @@ public void setJvmArgs(List jvmArgs) { @TaskAction public void runQuarkus() { ApplicationModel appModel = resolveAppModelForBuild(); - Map configMap = extension().buildEffectiveConfiguration(appModel.getAppArtifact()).configMap(); Properties sysProps = new Properties(); - sysProps.putAll(configMap); + sysProps.putAll(extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getValues()); try (CuratedApplication curatedApplication = QuarkusBootstrap.builder() .setBaseClassLoader(getClass().getClassLoader()) .setExistingModel(appModel) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java index cd37b8b1aad86..2115ee6ee6ad6 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java @@ -9,7 +9,6 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Properties; import java.util.stream.Collectors; @@ -22,6 +21,7 @@ import org.gradle.api.tasks.options.Option; import io.quarkus.gradle.QuarkusPlugin; +import io.smallrye.config.SmallRyeConfig; /** * Just show the effective configuration and settings. @@ -45,21 +45,21 @@ public Property getSaveConfigProperties() { @TaskAction public void dumpEffectiveConfiguration() { try { - EffectiveConfig effective = extension() + EffectiveConfig effectiveConfig = extension() .buildEffectiveConfiguration(extension().getApplicationModel().getAppArtifact()); - Map configMap = effective.configMap(); + SmallRyeConfig config = effectiveConfig.getConfig(); List sourceNames = new ArrayList<>(); - effective.config().getConfigSources().forEach(configSource -> sourceNames.add(configSource.getName())); + config.getConfigSources().forEach(configSource -> sourceNames.add(configSource.getName())); - String config = configMap.entrySet().stream() - .filter(e -> e.getKey().startsWith("quarkus.")) - .map(e -> format("%s=%s", e.getKey(), e.getValue())).sorted() + String quarkusConfig = config.getValues("quarkus", String.class, String.class) + .entrySet() + .stream() + .map(e -> format("quarkus.%s=%s", e.getKey(), e.getValue())).sorted() .collect(Collectors.joining("\n ", "\n ", "\n")); - - getLogger().lifecycle("Effective Quarkus configuration options: {}", config); + getLogger().lifecycle("Effective Quarkus configuration options: {}", quarkusConfig); String finalName = extension().finalName(); - String packageType = configMap.getOrDefault(QuarkusPlugin.QUARKUS_PACKAGE_TYPE, "fast-jar"); + String packageType = config.getOptionalValue(QuarkusPlugin.QUARKUS_PACKAGE_TYPE, String.class).orElse("fast-jar"); File fastJar = fastJar(); getLogger().lifecycle( "Quarkus package type: {}\n" + @@ -79,7 +79,7 @@ public void dumpEffectiveConfiguration() { if (getSaveConfigProperties().get()) { Properties props = new Properties(); - props.putAll(configMap); + props.putAll(effectiveConfig.getValues()); Path file = buildDir.toPath().resolve(finalName + ".quarkus-build.properties"); try (BufferedWriter writer = newBufferedWriter(file)) { props.store(writer, format("Quarkus build properties with package type %s", packageType)); diff --git a/devtools/gradle/gradle-application-plugin/src/test/java/io/quarkus/gradle/tasks/EffectiveConfigTest.java b/devtools/gradle/gradle-application-plugin/src/test/java/io/quarkus/gradle/tasks/EffectiveConfigTest.java index 3adaa53804e4f..18e6b53f40321 100644 --- a/devtools/gradle/gradle-application-plugin/src/test/java/io/quarkus/gradle/tasks/EffectiveConfigTest.java +++ b/devtools/gradle/gradle-application-plugin/src/test/java/io/quarkus/gradle/tasks/EffectiveConfigTest.java @@ -33,21 +33,21 @@ void empty() { // Cannot do an exact match, because `map` contains both the "raw" environment variables AND the // "property-key-ish" entries - i.e. environment appears "twice". - soft.assertThat(effectiveConfig.configMap()).containsAllEntriesOf(expect); + soft.assertThat(effectiveConfig.getValues()).containsAllEntriesOf(expect); } @Test void fromProjectProperties() { EffectiveConfig effectiveConfig = EffectiveConfig.builder().withProjectProperties(Map.of("quarkus.foo", "bar")).build(); - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "bar"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.foo", "bar"); } @Test void fromForcedProperties() { EffectiveConfig effectiveConfig = EffectiveConfig.builder().withTaskProperties(Map.of("quarkus.foo", "bar")).build(); - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "bar"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.foo", "bar"); } @Test @@ -56,7 +56,7 @@ void crypto() { EffectiveConfig effectiveConfig = EffectiveConfig.builder() .withTaskProperties(Map.of("quarkus.foo", "${aes-gcm-nopadding::superSecret}")).build(); - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.foo", "superSecret"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.foo", "superSecret"); } @Test @@ -69,13 +69,13 @@ void appPropsOverload() throws Exception { EffectiveConfig effectiveConfig = EffectiveConfig.builder().withSourceDirectories(source).build(); - SmallRyeConfig config = effectiveConfig.config(); + SmallRyeConfig config = effectiveConfig.getConfig(); List sourceNames = new ArrayList<>(); config.getConfigSources().forEach(configSource -> sourceNames.add(configSource.getName())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url1.getPath())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url2.getPath())); // The YAML source is always higher in ordinal than the properties source - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.prop.overload", "from-yaml"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.prop.overload", "from-yaml"); } @Test @@ -90,14 +90,14 @@ void appPropsOverloadWrongProfile() throws Exception { EffectiveConfig effectiveConfig = EffectiveConfig.builder().withSourceDirectories(source).build(); - SmallRyeConfig config = effectiveConfig.config(); + SmallRyeConfig config = effectiveConfig.getConfig(); List sourceNames = new ArrayList<>(); config.getConfigSources().forEach(configSource -> sourceNames.add(configSource.getName())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url1.getPath())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url2.getPath())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url3.getPath())); // The YAML source is always higher in ordinal than the properties source - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.prop.overload", "from-yaml"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.prop.overload", "from-yaml"); } @Test @@ -116,7 +116,7 @@ void appPropsOverloadProdProfile() throws Exception { EffectiveConfig effectiveConfig = EffectiveConfig.builder().withSourceDirectories(source).build(); - SmallRyeConfig config = effectiveConfig.config(); + SmallRyeConfig config = effectiveConfig.getConfig(); List sourceNames = new ArrayList<>(); config.getConfigSources().forEach(configSource -> sourceNames.add(configSource.getName())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url1.getPath())); @@ -125,6 +125,6 @@ void appPropsOverloadProdProfile() throws Exception { soft.assertThat(sourceNames).anyMatch(s -> s.contains(url4.getPath())); soft.assertThat(sourceNames).anyMatch(s -> s.contains(url5.getPath())); // The YAML source is always higher in ordinal than the properties source, even for profile property names - soft.assertThat(effectiveConfig.configMap()).containsEntry("quarkus.prop.overload", "from-yaml-prod"); + soft.assertThat(effectiveConfig.getValues()).containsEntry("quarkus.prop.overload", "from-yaml-prod"); } }