Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Provider instead of Property in Quarkus Gradle Extension #40728

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"));
}
}
Loading