diff --git a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java index c9ea61d5ae4af..ad25eade3947d 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/configuration/BuildTimeConfigurationReader.java @@ -873,13 +873,16 @@ private Converter getConverter(SmallRyeConfig config, Field field, ConverterT * We collect all properties from eligible ConfigSources, because Config#getPropertyNames exclude the active * profiled properties, meaning that the property is written in the default config source without the profile * prefix. This may cause issues if we run with a different profile and fallback to defaults. - * + *
* We also filter the properties coming from the System with the registered roots, because we don't want to * record properties set by the compiling JVM (or other properties that are only related to the build). + *
+ * Properties coming from the Environment are ignored. */ private Set getAllProperties(final Set registeredRoots) { Set properties = new HashSet<>(); for (ConfigSource configSource : config.getConfigSources()) { + // This is a BuildTimeSysPropConfigSource if (configSource instanceof SysPropConfigSource) { for (String propertyName : configSource.getProperties().keySet()) { NameIterator ni = new NameIterator(propertyName); @@ -888,6 +891,7 @@ private Set getAllProperties(final Set registeredRoots) { } } } else { + // The BuildTimeEnvConfigSource returns an empty Set properties.addAll(configSource.getPropertyNames()); } } @@ -901,10 +905,10 @@ private Set getAllProperties(final Set registeredRoots) { * Use this Config instance to record the runtime default values. We cannot use the main Config * instance because it may record values coming from the EnvSource in build time. Environment variable values * may be completely different between build and runtime, so it doesn't make sense to record these. - * + *
* We do exclude the properties coming from the EnvSource, but a call to getValue may still provide a result * coming from the EnvSource, so we need to exclude it from the sources when recording values for runtime. - * + *
* We also do not want to completely exclude the EnvSource, because it may provide values for the build. This * is only specific when recording the defaults. * diff --git a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java index cf66ecbbcd052..68379f02ae27b 100644 --- a/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java +++ b/devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java @@ -1,5 +1,7 @@ package io.quarkus.maven; +import static io.smallrye.common.expression.Expression.Flag.LENIENT_SYNTAX; +import static io.smallrye.common.expression.Expression.Flag.NO_TRIM; import static java.util.function.Predicate.not; import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId; import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration; @@ -104,6 +106,7 @@ import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.PathList; import io.quarkus.runtime.LaunchMode; +import io.smallrye.common.expression.Expression; /** * The dev mojo, that runs a quarkus app in a forked process. A background compilation process is launched and any changes are @@ -972,7 +975,31 @@ private QuarkusDevModeLauncher newLauncher() throws Exception { } builder.projectDir(project.getFile().getParentFile()); - builder.buildSystemProperties((Map) project.getProperties()); + + Properties projectProperties = project.getProperties(); + Map effectiveProperties = new HashMap<>(); + for (String name : projectProperties.stringPropertyNames()) { + if (name.startsWith("quarkus.")) { + effectiveProperties.put(name, projectProperties.getProperty(name)); + } + } + + // Add other properties that may be required for expansion + for (String value : effectiveProperties.values()) { + for (String reference : Expression.compile(value, LENIENT_SYNTAX, NO_TRIM).getReferencedStrings()) { + String referenceValue = session.getUserProperties().getProperty(reference); + if (referenceValue != null) { + effectiveProperties.put(reference, referenceValue); + continue; + } + + referenceValue = projectProperties.getProperty(reference); + if (referenceValue != null) { + effectiveProperties.put(reference, referenceValue); + } + } + } + builder.buildSystemProperties(effectiveProperties); builder.applicationName(project.getArtifactId()); builder.applicationVersion(project.getVersion());