getCacheLargeArtifacts() {
+ return cacheLargeArtifacts;
+ }
+
+ public void setCacheLargeArtifacts(boolean cacheLargeArtifacts) {
+ this.cacheLargeArtifacts.set(cacheLargeArtifacts);
+ }
+
public String finalName() {
return getFinalName().get();
}
diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfigHelper.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfigHelper.java
new file mode 100644
index 00000000000000..4dcde2df3ba922
--- /dev/null
+++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfigHelper.java
@@ -0,0 +1,225 @@
+package io.quarkus.gradle.tasks;
+
+import static java.util.Collections.unmodifiableMap;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+import org.eclipse.microprofile.config.spi.ConfigSource;
+import org.eclipse.microprofile.config.spi.ConfigSourceProvider;
+import org.gradle.api.logging.Logger;
+
+import io.quarkus.gradle.QuarkusPlugin;
+import io.smallrye.config.AbstractLocationConfigSourceLoader;
+import io.smallrye.config.PropertiesConfigSource;
+import io.smallrye.config.source.yaml.YamlConfigSource;
+
+/**
+ * Helper that bundles the various sources of config options for the Gradle plugin: system environment, system properties,
+ * quarkus build properties (on the Quarkus extension), Gradle project properties, application properties and "forced"
+ * properties (on the Gradle task).
+ *
+ *
+ * Eventually used to construct a map with the effective config options from all the sources above.
+ */
+final class EffectiveConfigHelper {
+ // System properties starting with 'quarkus.'
+ final Map quarkusSystemProperties;
+ // Environment properties starting with 'QUARKUS_'
+ final Map quarkusEnvProperties;
+ // Gradle project + extension properties starting with 'quarkus.'
+ private Map quarkusBuildProperties;
+ private Map projectProperties;
+ private Map applicationProperties;
+ private Map forcedProperties;
+ final List applicationPropertiesSourceUrls = new ArrayList<>();
+
+ EffectiveConfigHelper() {
+ this(collectQuarkusSystemProperties(), collectQuarkusEnvProperties());
+ }
+
+ EffectiveConfigHelper(Map quarkusSystemProperties, Map quarkusEnvProperties) {
+ this.quarkusSystemProperties = quarkusSystemProperties;
+ this.quarkusEnvProperties = quarkusEnvProperties;
+ }
+
+ EffectiveConfigHelper applyBuildProperties(Map buildProperties) {
+ quarkusBuildProperties = unmodifiableMap(collectProperties(buildProperties));
+ return this;
+ }
+
+ EffectiveConfigHelper applyProjectProperties(Map buildProperties) {
+ projectProperties = collectProperties(buildProperties);
+ return this;
+ }
+
+ EffectiveConfigHelper applyApplicationProperties(Set sourceDirectories, Logger logger) {
+ applicationProperties = loadApplicationProperties(sourceDirectories, logger, applicationPropertiesSourceUrls::add);
+ return this;
+ }
+
+ EffectiveConfigHelper applyForcedProperties(Map forcedProperties) {
+ this.forcedProperties = forcedProperties;
+ return this;
+ }
+
+ Map buildEffectiveConfiguration() {
+ Map map = new HashMap<>();
+
+ // Add non-"profile-prefixed" configuration options (aka all that do not start with '%')
+ addNonProfileToEffectiveConfig(projectProperties, map);
+ addNonProfileToEffectiveConfig(quarkusBuildProperties, map);
+ addNonProfileToEffectiveConfig(applicationProperties, map);
+ addNonProfileToEffectiveConfig(quarkusEnvProperties, map);
+ addNonProfileToEffectiveConfig(quarkusSystemProperties, map);
+ addNonProfileToEffectiveConfig(forcedProperties, map);
+
+ String quarkusProfile = map.getOrDefault(QuarkusPlugin.QUARKUS_PROFILE, QuarkusPlugin.DEFAULT_PROFILE);
+ String profilePrefix = "%" + quarkusProfile + ".";
+
+ // Add the configuration options for the selected profile (filtering on the key + truncating the key)
+ addProfileToEffectiveConfig(projectProperties, profilePrefix, map);
+ addProfileToEffectiveConfig(quarkusBuildProperties, profilePrefix, map);
+ addProfileToEffectiveConfig(applicationProperties, profilePrefix, map);
+ addProfileToEffectiveConfig(quarkusEnvProperties, profilePrefix, map);
+ addProfileToEffectiveConfig(quarkusSystemProperties, profilePrefix, map);
+ addProfileToEffectiveConfig(forcedProperties, profilePrefix, map);
+
+ return unmodifiableMap(map);
+ }
+
+ static Map loadApplicationProperties(Set sourceDirectories, Logger logger, Consumer sourceUrls) {
+ URL[] resourceUrls = sourceDirectories.stream().map(File::toURI)
+ .map(u -> {
+ try {
+ return u.toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(e);
+ }
+ })
+ .toArray(URL[]::new);
+
+ Map config = new HashMap<>();
+
+ if (logger.isInfoEnabled()) {
+ logger.info("Loading Quarkus application config from resource URLs {}",
+ Arrays.stream(resourceUrls).map(Object::toString).collect(Collectors.joining(", ")));
+ }
+
+ CombinedConfigSourceProvider configSourceProvider = new CombinedConfigSourceProvider(sourceUrls);
+ logger.debug("Loading Quarkus application config");
+ for (URL resourceUrl : resourceUrls) {
+ URLClassLoader classLoader = new URLClassLoader(new URL[] { resourceUrl });
+ for (ConfigSource configSource : configSourceProvider.getConfigSources(classLoader)) {
+ Map properties = configSource.getProperties();
+ logger.debug("Loaded {} Quarkus application config entries via {}", properties.size(),
+ configSource);
+ config.putAll(properties);
+ }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loaded Quarkus application config from 'application.[properties|yaml|yml]: {}",
+ new TreeMap<>(config).entrySet().stream().map(Objects::toString)
+ .collect(Collectors.joining("\n ", "\n ", "")));
+ }
+
+ return unmodifiableMap(config);
+ }
+
+ static final class CombinedConfigSourceProvider extends AbstractLocationConfigSourceLoader implements ConfigSourceProvider {
+ final Consumer sourceUrls;
+
+ CombinedConfigSourceProvider(Consumer sourceUrls) {
+ this.sourceUrls = sourceUrls;
+ }
+
+ @Override
+ protected String[] getFileExtensions() {
+ return new String[] {
+ "application.yaml",
+ "application.yml",
+ "application.properties"
+ };
+ }
+
+ @Override
+ protected ConfigSource loadConfigSource(final URL url, final int ordinal) throws IOException {
+ sourceUrls.accept(url);
+ return url.getPath().endsWith(".properties") ? new PropertiesConfigSource(url, ordinal)
+ : new YamlConfigSource(url, ordinal);
+ }
+
+ @Override
+ public List getConfigSources(final ClassLoader classLoader) {
+ // Note:
+ return loadConfigSources(new String[] { "application.yml", "application.yaml", "application.properties" }, 260,
+ classLoader);
+ }
+ }
+
+ static Map collectQuarkusSystemProperties() {
+ return collectQuarkusSystemProperties(System.getProperties());
+ }
+
+ static Map collectQuarkusSystemProperties(Map