Allow additional build info properties to have provided values
Closes gh-37889
This commit is contained in:
@@ -95,3 +95,5 @@ include::../gradle/integrating-with-actuator/build-info-additional.gradle[tags=a
|
||||
----
|
||||
include::../gradle/integrating-with-actuator/build-info-additional.gradle.kts[tags=additional]
|
||||
----
|
||||
|
||||
An additional property's value can be computed lazily by using a `Provider`.
|
||||
|
||||
@@ -30,6 +30,7 @@ import javax.inject.Inject;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.provider.MapProperty;
|
||||
import org.gradle.api.provider.Property;
|
||||
import org.gradle.api.provider.Provider;
|
||||
import org.gradle.api.provider.SetProperty;
|
||||
import org.gradle.api.tasks.Input;
|
||||
import org.gradle.api.tasks.Internal;
|
||||
@@ -155,7 +156,12 @@ public abstract class BuildInfoProperties implements Serializable {
|
||||
|
||||
private Map<String, String> coerceToStringValues(Map<String, Object> input) {
|
||||
Map<String, String> output = new HashMap<>();
|
||||
input.forEach((key, value) -> output.put(key, (value != null) ? value.toString() : null));
|
||||
input.forEach((key, value) -> {
|
||||
if (value instanceof Provider<?> provider) {
|
||||
value = provider.getOrNull();
|
||||
}
|
||||
output.put(key, (value != null) ? value.toString() : null);
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ springBoot {
|
||||
buildInfo {
|
||||
properties {
|
||||
additional = [
|
||||
'a': 'alpha', 'b': 'bravo'
|
||||
'a': 'alpha',
|
||||
'b': providers.provider({'bravo'})
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user