From 814be9658b46085868ec887f845eb7d8e7d00a62 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Sat, 24 Apr 2021 00:21:07 +0100 Subject: [PATCH] Resolve config and env folders with user.dir. --- .../ApplicationPropertiesConfigSourceLoader.java | 5 ++++- .../io/quarkus/runtime/configuration/ConfigUtils.java | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ApplicationPropertiesConfigSourceLoader.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ApplicationPropertiesConfigSourceLoader.java index f5ac2de74bf0a..e605e035d9a5c 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ApplicationPropertiesConfigSourceLoader.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ApplicationPropertiesConfigSourceLoader.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.net.URI; import java.net.URL; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -48,7 +49,9 @@ protected ConfigSource loadConfigSource(final URL url, final int ordinal) throws @Override public List getConfigSources(final ClassLoader classLoader) { - return loadConfigSources("config/application.properties", classLoader); + return loadConfigSources( + Paths.get(System.getProperty("user.dir"), "config", "application.properties").toUri().toString(), + classLoader); } @Override diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java index 96c0d87fa16a8..8f9ba4135817c 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java @@ -1,7 +1,6 @@ package io.quarkus.runtime.configuration; import static io.smallrye.config.AbstractLocationConfigSourceFactory.SMALLRYE_LOCATIONS; -import static io.smallrye.config.DotEnvConfigSourceProvider.dotEnvSources; import static io.smallrye.config.ProfileConfigSourceInterceptor.SMALLRYE_PROFILE; import static io.smallrye.config.ProfileConfigSourceInterceptor.SMALLRYE_PROFILE_PARENT; import static io.smallrye.config.PropertiesConfigSourceProvider.classPathSources; @@ -10,6 +9,7 @@ import java.io.IOException; import java.net.URL; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -100,7 +100,9 @@ public OptionalInt getPriority() { builder.addDefaultInterceptors(); if (runTime) { builder.addDefaultSources(); - builder.withSources(dotEnvSources(classLoader)); + builder.withSources( + new DotEnvConfigSourceProvider(Paths.get(System.getProperty("user.dir"), ".env").toUri().toString()) + .getConfigSources(classLoader)); } else { final List sources = new ArrayList<>(); sources.addAll(classPathSources(META_INF_MICROPROFILE_CONFIG_PROPERTIES, classLoader)); @@ -190,7 +192,7 @@ public String getName() { */ static class BuildTimeDotEnvConfigSourceProvider extends DotEnvConfigSourceProvider { public BuildTimeDotEnvConfigSourceProvider() { - super(); + super(Paths.get(System.getProperty("user.dir"), ".env").toUri().toString()); } public BuildTimeDotEnvConfigSourceProvider(final String location) {