Skip to content

Commit

Permalink
Use Provider instead of Property in Quarkus Gradle Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
dnl50 committed May 20, 2024
1 parent 2d4b470 commit fe4cfae
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 fe4cfae

Please sign in to comment.