diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ConfigBuildTimeConfig.java b/core/deployment/src/main/java/io/quarkus/deployment/ConfigBuildTimeConfig.java
new file mode 100644
index 0000000000000..95d1c4e04bdd4
--- /dev/null
+++ b/core/deployment/src/main/java/io/quarkus/deployment/ConfigBuildTimeConfig.java
@@ -0,0 +1,17 @@
+package io.quarkus.deployment;
+
+import io.quarkus.runtime.annotations.ConfigItem;
+import io.quarkus.runtime.annotations.ConfigPhase;
+import io.quarkus.runtime.annotations.ConfigRoot;
+
+@ConfigRoot(name = ConfigItem.PARENT, phase = ConfigPhase.BUILD_TIME)
+public class ConfigBuildTimeConfig {
+ /**
+ *
+ * Set this to true
to read configuration from system properties and environment variables only. This
+ * only applies to runtime.
+ *
+ */
+ @ConfigItem(name = "config.sources.system-only", defaultValue = "false")
+ public boolean systemOnly;
+}
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigBuildSteps.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigBuildSteps.java
index 2d64454e7298e..17945bdce7b26 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigBuildSteps.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigBuildSteps.java
@@ -5,18 +5,22 @@
import java.util.List;
import java.util.OptionalInt;
import java.util.Set;
+import java.util.function.BooleanSupplier;
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
import org.eclipse.microprofile.config.spi.Converter;
+import io.quarkus.deployment.ConfigBuildTimeConfig;
import io.quarkus.deployment.GeneratedClassGizmoAdaptor;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
import io.quarkus.deployment.builditem.LiveReloadBuildItem;
+import io.quarkus.deployment.builditem.RunTimeConfigBuilderBuildItem;
import io.quarkus.deployment.builditem.RunTimeConfigurationSourceBuildItem;
+import io.quarkus.deployment.builditem.StaticInitConfigBuilderBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.util.ServiceUtil;
@@ -25,6 +29,7 @@
import io.quarkus.gizmo.MethodCreator;
import io.quarkus.gizmo.MethodDescriptor;
import io.quarkus.gizmo.ResultHandle;
+import io.quarkus.runtime.configuration.SystemOnlySourcesConfigBuilder;
import io.quarkus.runtime.graal.InetRunTime;
import io.smallrye.config.ConfigSourceInterceptor;
import io.smallrye.config.ConfigSourceInterceptorFactory;
@@ -97,4 +102,20 @@ void nativeServiceProviders(
RuntimeInitializedClassBuildItem runtimeInitializedClass() {
return new RuntimeInitializedClassBuildItem(InetRunTime.class.getName());
}
+
+ @BuildStep(onlyIf = SystemOnlySources.class)
+ void systemOnlySources(BuildProducer staticInitConfigBuilder,
+ BuildProducer runTimeConfigBuilder) {
+ staticInitConfigBuilder.produce(new StaticInitConfigBuilderBuildItem(SystemOnlySourcesConfigBuilder.class.getName()));
+ runTimeConfigBuilder.produce(new RunTimeConfigBuilderBuildItem(SystemOnlySourcesConfigBuilder.class.getName()));
+ }
+
+ private static class SystemOnlySources implements BooleanSupplier {
+ ConfigBuildTimeConfig configBuildTimeConfig;
+
+ @Override
+ public boolean getAsBoolean() {
+ return configBuildTimeConfig.systemOnly;
+ }
+ }
}
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/SystemOnlySourcesConfigBuilder.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/SystemOnlySourcesConfigBuilder.java
new file mode 100644
index 0000000000000..34aa70b56f2be
--- /dev/null
+++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/SystemOnlySourcesConfigBuilder.java
@@ -0,0 +1,16 @@
+package io.quarkus.runtime.configuration;
+
+import io.smallrye.config.SmallRyeConfigBuilder;
+
+public class SystemOnlySourcesConfigBuilder implements ConfigBuilder {
+ @Override
+ public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) {
+ builder.getSourceProviders().clear();
+ return builder;
+ }
+
+ @Override
+ public int priority() {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/devtools/cli/src/main/resources/application.properties b/devtools/cli/src/main/resources/application.properties
index b48de61d1e8c2..1ec0fef292941 100644
--- a/devtools/cli/src/main/resources/application.properties
+++ b/devtools/cli/src/main/resources/application.properties
@@ -5,4 +5,5 @@ quarkus.native.resources.includes=quarkus.properties
quarkus.native.additional-build-args=--initialize-at-run-time=org.apache.maven.wagon.shared.http.AbstractHttpClientWagon
# Do not attempt to detect "unused removed beans" false positives during programmatic lookup
# at runtime to conserve some memory
-quarkus.arc.detect-unused-false-positives=false
\ No newline at end of file
+quarkus.arc.detect-unused-false-positives=false
+quarkus.config.sources.system-only=true
diff --git a/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliDeploymentConfiguration.java b/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliDeploymentConfiguration.java
index 3be7c8d9e57be..e8d9e43bbd5a6 100644
--- a/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliDeploymentConfiguration.java
+++ b/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliDeploymentConfiguration.java
@@ -26,13 +26,4 @@ class PicocliDeploymentConfiguration {
*/
@ConfigItem(name = "native-image.processing.enable", defaultValue = "true")
boolean nativeImageProcessingEnabled;
-
- /**
- *
- * Set this to true
to disable reading configuration from the default Config Sources. This includes
- * `application.properties` and `.env` files.
- *
- */
- @ConfigItem(defaultValue = "false")
- boolean disableDefaultConfigSources;
}
diff --git a/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliProcessor.java b/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliProcessor.java
index 25204508dd9f9..d18d752f76ce8 100644
--- a/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliProcessor.java
+++ b/extensions/picocli/deployment/src/main/java/io/quarkus/picocli/deployment/PicocliProcessor.java
@@ -21,10 +21,7 @@
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.QuarkusApplicationClassBuildItem;
-import io.quarkus.deployment.builditem.RunTimeConfigBuilderBuildItem;
-import io.quarkus.deployment.builditem.StaticInitConfigBuilderBuildItem;
import io.quarkus.picocli.runtime.DefaultPicocliCommandLineFactory;
-import io.quarkus.picocli.runtime.PicocliConfigBuilder;
import io.quarkus.picocli.runtime.PicocliRunner;
import io.quarkus.picocli.runtime.annotations.TopCommand;
import io.quarkus.runtime.annotations.QuarkusMain;
@@ -47,17 +44,6 @@ IndexDependencyBuildItem picocliIndexDependency() {
return new IndexDependencyBuildItem("info.picocli", "picocli");
}
- @BuildStep
- void configBuilder(
- PicocliDeploymentConfiguration configuration,
- BuildProducer staticInitConfigBuilder,
- BuildProducer runTimeConfigBuilder) {
- if (configuration.disableDefaultConfigSources) {
- staticInitConfigBuilder.produce(new StaticInitConfigBuilderBuildItem(PicocliConfigBuilder.class.getName()));
- runTimeConfigBuilder.produce(new RunTimeConfigBuilderBuildItem(PicocliConfigBuilder.class.getName()));
- }
- }
-
@BuildStep
void picocliRunner(ApplicationIndexBuildItem applicationIndex,
CombinedIndexBuildItem combinedIndex,
diff --git a/extensions/picocli/deployment/src/test/java/io/quarkus/picocli/deployment/AvailableConfigSourcesTest.java b/extensions/picocli/deployment/src/test/java/io/quarkus/picocli/deployment/AvailableConfigSourcesTest.java
index e8e9b778f3cd5..3c0a8d7d3d39c 100644
--- a/extensions/picocli/deployment/src/test/java/io/quarkus/picocli/deployment/AvailableConfigSourcesTest.java
+++ b/extensions/picocli/deployment/src/test/java/io/quarkus/picocli/deployment/AvailableConfigSourcesTest.java
@@ -17,7 +17,7 @@
public class AvailableConfigSourcesTest {
@RegisterExtension
static final QuarkusUnitTest TEST = new QuarkusUnitTest().withApplicationRoot(
- (jar) -> jar.addAsResource(new StringAsset("quarkus.picocli.disable-default-config-sources=true\n" +
+ (jar) -> jar.addAsResource(new StringAsset("quarkus.config.sources.system-only=true\n" +
"my.prop=1234\n"), "application.properties"));
@Inject