Skip to content

Commit

Permalink
Merge pull request #40728 from dnl50/use-provider
Browse files Browse the repository at this point in the history
Use Provider instead of Property in Quarkus Gradle Extension
  • Loading branch information
gastaldi authored May 23, 2024
2 parents d2c4899 + 9e38233 commit 8f878f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,14 @@ public ListProperty<String> getCachingRelevantProperties() {
}

public void set(String name, @Nullable String value) {
quarkusBuildProperties.put(String.format("quarkus.%s", name), value);
quarkusBuildProperties.put(addQuarkusBuildPropertyPrefix(name), value);
}

public void set(String name, Property<String> value) {
quarkusBuildProperties.put(String.format("quarkus.%s", name), value);
public void set(String name, Provider<String> value) {
quarkusBuildProperties.put(addQuarkusBuildPropertyPrefix(name), value);
}

private String addQuarkusBuildPropertyPrefix(String name) {
return String.format("quarkus.%s", name);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quarkus.gradle.extension;

import static io.quarkus.gradle.QuarkusPlugin.EXTENSION_NAME;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;

import org.gradle.api.Project;
import org.gradle.testfixtures.ProjectBuilder;
Expand All @@ -15,4 +17,16 @@ public void extensionInstantiates() {
QuarkusPluginExtension extension = project.getExtensions().create(EXTENSION_NAME, QuarkusPluginExtension.class,
project);
}

@Test
void prefixesBuildProperty() {
Project project = ProjectBuilder.builder().build();
project.getPluginManager().apply("java");
QuarkusPluginExtension extension = project.getExtensions()
.create(EXTENSION_NAME, QuarkusPluginExtension.class, project);

extension.set("test.args", "value");

assertThat(extension.getQuarkusBuildProperties().get()).containsExactly(entry("quarkus.test.args", "value"));
}
}

0 comments on commit 8f878f7

Please sign in to comment.