Skip to content

Commit

Permalink
Merge pull request #16777 from radcortez/fix-16429
Browse files Browse the repository at this point in the history
Resolve config and env folders with user.dir
  • Loading branch information
gsmet authored May 7, 2021
2 parents c5f406c + 814be96 commit 869d290
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,7 +49,9 @@ protected ConfigSource loadConfigSource(final URL url, final int ordinal) throws

@Override
public List<ConfigSource> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<ConfigSource> sources = new ArrayList<>();
sources.addAll(classPathSources(META_INF_MICROPROFILE_CONFIG_PROPERTIES, classLoader));
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 869d290

Please sign in to comment.