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 ee4fd9f4100fc..b947848ca194d 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 @@ -21,6 +21,7 @@ import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; +import org.gradle.api.provider.MapProperty; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.testing.Test; @@ -39,7 +40,7 @@ public class QuarkusPluginExtension { private final Property finalName; - private Map quarkusBuildProperties; + private final MapProperty quarkusBuildProperties; private final SourceSetExtension sourceSetExtension; public QuarkusPluginExtension(Project project) { @@ -49,7 +50,7 @@ public QuarkusPluginExtension(Project project) { finalName.convention(project.provider(() -> String.format("%s-%s", project.getName(), project.getVersion()))); this.sourceSetExtension = new SourceSetExtension(); - quarkusBuildProperties = new HashMap<>(); + this.quarkusBuildProperties = project.getObjects().mapProperty(String.class, String.class); } public void beforeTest(Test task) { @@ -99,7 +100,7 @@ public void beforeTest(Test task) { public String buildNativeRunnerName(final Map taskSystemProps) { Properties properties = new Properties(taskSystemProps.size()); properties.putAll(taskSystemProps); - quarkusBuildProperties.entrySet() + quarkusBuildProperties.get().entrySet() .forEach(buildEntry -> properties.putIfAbsent(buildEntry.getKey(), buildEntry.getValue())); System.getProperties().entrySet() .forEach(propEntry -> properties.putIfAbsent(propEntry.getKey(), propEntry.getValue())); @@ -215,7 +216,7 @@ public Path appJarOrClasses() { return classesDir; } - public Map getQuarkusBuildProperties() { + public MapProperty getQuarkusBuildProperties() { return quarkusBuildProperties; } @@ -223,4 +224,8 @@ public void set(String name, @Nullable String value) { quarkusBuildProperties.put(String.format("quarkus.%s", name), value); } + public void set(String name, Property value) { + quarkusBuildProperties.put(String.format("quarkus.%s", name), value); + } + } diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java index 4d98e2e99a3d8..1b3698e4f668a 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusBuild.java @@ -256,8 +256,9 @@ private String getPropValueWithPrecedence(final String propName, final java.util } }); } - if (extension().getQuarkusBuildProperties().containsKey(propName)) { - return extension().getQuarkusBuildProperties().get(propName); + Map quarkusBuildProperties = extension().getQuarkusBuildProperties().get(); + if (quarkusBuildProperties.containsKey(propName)) { + return quarkusBuildProperties.get(propName); } else if (applicationProperties.contains(propName)) { return applicationProperties.getProperty(propName); } else if (getQuarkusBuildEnvProperties().containsKey(propName)) { diff --git a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusTask.java b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusTask.java index 62a24bbdc5abc..e16c737d6009f 100644 --- a/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusTask.java +++ b/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusTask.java @@ -34,8 +34,9 @@ protected Properties getBuildSystemProperties(ResolvedDependency appArtifact) { realProperties.setProperty(key, (String) value); } } - if (!extension().getQuarkusBuildProperties().isEmpty()) { - extension().getQuarkusBuildProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("quarkus.")) + Map quarkusBuildProperties = extension().getQuarkusBuildProperties().get(); + if (!quarkusBuildProperties.isEmpty()) { + quarkusBuildProperties.entrySet().stream().filter(entry -> entry.getKey().startsWith("quarkus.")) .forEach(entry -> { realProperties.put(entry.getKey(), entry.getValue()); });