diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java index 7e45c652dbcf4..cbf5e6e62ee96 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/extension/QuarkusPluginExtension.java @@ -74,7 +74,8 @@ public void beforeTest(Test task) { Map props = task.getSystemProperties(); ApplicationModel appModel = getApplicationModel(TEST); - SmallRyeConfig config = buildEffectiveConfiguration(appModel.getAppArtifact()).getConfig(); + SmallRyeConfig config = buildEffectiveConfiguration(appModel) + .getConfig(); config.getOptionalValue(TEST.getProfileKey(), String.class) .ifPresent(value -> props.put(TEST.getProfileKey(), value)); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java index e717ca883d7da..81301d6c807ad 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/AbstractQuarkusExtension.java @@ -27,6 +27,7 @@ import org.gradle.api.tasks.SourceSet; import org.gradle.process.JavaForkOptions; +import io.quarkus.bootstrap.model.ApplicationModel; import io.quarkus.gradle.dsl.Manifest; import io.quarkus.maven.dependency.ResolvedDependency; import io.smallrye.common.expression.Expression; @@ -117,7 +118,9 @@ protected Manifest manifest() { return baseConfig().manifest(); } - protected EffectiveConfig buildEffectiveConfiguration(ResolvedDependency appArtifact) { + protected EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel) { + ResolvedDependency appArtifact = appModel.getAppArtifact(); + Map properties = new HashMap<>(); exportCustomManifestProperties(properties); @@ -140,6 +143,7 @@ protected EffectiveConfig buildEffectiveConfiguration(ResolvedDependency appArti defaultProperties.putIfAbsent("quarkus.application.version", appArtifact.getVersion()); return EffectiveConfig.builder() + .withPlatformProperties(appModel.getPlatformProperties()) .withForcedProperties(forcedPropertiesProperty.get()) .withTaskProperties(properties) .withBuildProperties(quarkusBuildProperties.get()) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java index 4833c5be53da2..da99d0a7386b3 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/Deploy.java @@ -91,7 +91,7 @@ public Deploy() { public void checkRequiredExtensions() { ApplicationModel appModel = resolveAppModelForBuild(); Properties sysProps = new Properties(); - sysProps.putAll(extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getValues()); + sysProps.putAll(extension().buildEffectiveConfiguration(appModel).getValues()); try (CuratedApplication curatedApplication = QuarkusBootstrap.builder() .setBaseClassLoader(getClass().getClassLoader()) .setExistingModel(appModel) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java index 52583a3088096..8e49f6a2b5a10 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/EffectiveConfig.java @@ -60,6 +60,15 @@ private EffectiveConfig(Builder builder) { // 100 -> microprofile.properties in classpath (provided by default sources) // 0 -> fallback config source for error workaround (see below) + PropertiesConfigSource platformPropertiesConfigSource; + if (builder.platformProperties.isEmpty()) { + // we don't have the model yet so we don't have the Platform properties around + platformPropertiesConfigSource = new PropertiesConfigSource( + Map.of("platform.quarkus.native.builder-image", "<>"), "platformProperties", 0); + } else { + platformPropertiesConfigSource = new PropertiesConfigSource(builder.platformProperties, "platformProperties", 0); + } + this.config = ConfigUtils.emptyConfigBuilder() .forClassLoader(toUrlClassloader(builder.sourceDirectories)) .withSources(new PropertiesConfigSource(builder.forcedProperties, "forcedProperties", 600)) @@ -70,9 +79,7 @@ private EffectiveConfig(Builder builder) { .withSources(new YamlConfigSourceLoader.InFileSystem()) .withSources(new YamlConfigSourceLoader.InClassPath()) .addPropertiesSources() - // todo: this is due to ApplicationModel#getPlatformProperties not being included in the effective config - .withSources(new PropertiesConfigSource(Map.of("platform.quarkus.native.builder-image", "<>"), - "NativeConfig#builderImage", 0)) + .withSources(platformPropertiesConfigSource) .withDefaultValues(builder.defaultProperties) .withProfile(builder.profile) .withMapping(PackageConfig.class) @@ -122,6 +129,7 @@ static Builder builder() { } static final class Builder { + private Map platformProperties = emptyMap(); private Map forcedProperties = emptyMap(); private Map taskProperties = emptyMap(); private Map buildProperties = emptyMap(); @@ -134,6 +142,11 @@ EffectiveConfig build() { return new EffectiveConfig(this); } + Builder withPlatformProperties(Map platformProperties) { + this.platformProperties = platformProperties; + return this; + } + Builder withForcedProperties(Map forcedProperties) { this.forcedProperties = forcedProperties; return this; diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java index 40e811c1b02a2..7885ce37c0d1d 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildDependencies.java @@ -144,7 +144,8 @@ private void jarDependencies(Path libBoot, Path libMain) { } ApplicationModel appModel = resolveAppModelForBuild(); - SmallRyeConfig config = getExtensionView().buildEffectiveConfiguration(appModel.getAppArtifact(), new HashMap<>()) + SmallRyeConfig config = getExtensionView() + .buildEffectiveConfiguration(appModel, new HashMap<>()) .getConfig(); // see https://quarkus.io/guides/class-loading-reference#configuring-class-loading diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java index c6d4f6b160d3b..39eae2b51e20b 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuildTask.java @@ -244,7 +244,7 @@ void generateBuild() { ApplicationModel appModel = resolveAppModelForBuild(); SmallRyeConfig config = getExtensionView() - .buildEffectiveConfiguration(appModel.getAppArtifact(), getAdditionalForcedProperties().get().getProperties()) + .buildEffectiveConfiguration(appModel, getAdditionalForcedProperties().get().getProperties()) .getConfig(); Map quarkusProperties = Expressions.withoutExpansion(() -> { Map values = new HashMap<>(); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java index a86e1b4e794f9..226a1cccacc19 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusGenerateCode.java @@ -119,7 +119,7 @@ public Set getInputDirectory() { public void generateCode() throws IOException { ApplicationModel appModel = ToolingUtils.deserializeAppModel(getApplicationModel().get().getAsFile().toPath()); Map configMap = getExtensionView() - .buildEffectiveConfiguration(appModel.getAppArtifact(), new HashMap<>()).getValues(); + .buildEffectiveConfiguration(appModel, new HashMap<>()).getValues(); File outputPath = getGeneratedOutputDirectory().get().getAsFile(); diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPluginExtensionView.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPluginExtensionView.java index 9dc97a6c53ea7..22bb019e69da6 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPluginExtensionView.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusPluginExtensionView.java @@ -38,6 +38,7 @@ import org.gradle.process.JavaForkOptions; import org.gradle.util.GradleVersion; +import io.quarkus.bootstrap.model.ApplicationModel; import io.quarkus.deployment.pkg.PackageConfig; import io.quarkus.gradle.QuarkusPlugin; import io.quarkus.gradle.dsl.Manifest; @@ -209,8 +210,10 @@ private void exportCustomManifestProperties(Map properties) { } } - protected EffectiveConfig buildEffectiveConfiguration(ResolvedDependency appArtifact, + protected EffectiveConfig buildEffectiveConfiguration(ApplicationModel appModel, Map additionalForcedProperties) { + ResolvedDependency appArtifact = appModel.getAppArtifact(); + Map properties = new HashMap<>(); exportCustomManifestProperties(properties); @@ -235,6 +238,7 @@ protected EffectiveConfig buildEffectiveConfiguration(ResolvedDependency appArti forced.put("quarkus.native.enabled", "true"); } return EffectiveConfig.builder() + .withPlatformProperties(appModel.getPlatformProperties()) .withForcedProperties(forced) .withTaskProperties(properties) .withBuildProperties(getQuarkusBuildProperties().get()) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java index e65e7e8c2759b..f944cbd1cd6ba 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusRun.java @@ -102,7 +102,7 @@ public void setJvmArgs(List jvmArgs) { public void runQuarkus() { ApplicationModel appModel = resolveAppModelForBuild(); Properties sysProps = new Properties(); - sysProps.putAll(extension().buildEffectiveConfiguration(appModel.getAppArtifact()).getValues()); + sysProps.putAll(extension().buildEffectiveConfiguration(appModel).getValues()); try (CuratedApplication curatedApplication = QuarkusBootstrap.builder() .setBaseClassLoader(getClass().getClassLoader()) .setExistingModel(appModel) diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java index 39882f3e5434c..6d5af8ef63caa 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusShowEffectiveConfig.java @@ -49,7 +49,7 @@ public void dumpEffectiveConfiguration() { try { ApplicationModel appModel = resolveAppModelForBuild(); EffectiveConfig effectiveConfig = getExtensionView() - .buildEffectiveConfiguration(appModel.getAppArtifact(), + .buildEffectiveConfiguration(appModel, getAdditionalForcedProperties().get().getProperties()); SmallRyeConfig config = effectiveConfig.getConfig(); List sourceNames = new ArrayList<>();