Quick question, let's say I have ValueSource like ...
# plugin-development
k
Quick question, let's say I have ValueSource like this:
Copy code
val internalFileVersionSource = project.providers.of(CustomPropertiesFileValueSource::class.java) {
    it.parameters.propertiesFile.convention(project.internalVersionFilePath())
}
if I add function that looks like this:
Copy code
fun Project.myValueSource(): Provider<Map<String, String>> {
    return this.providers.of(CustomPropertiesFileValueSource::class.java) {
        it.parameters.propertiesFile.convention(this.internalVersionFilePath())
    }
}
If i start using myValueSource() will it be evaluated once and cached or each instance will be treated as separate execution when provider is resolved? Is there any way to register ValueSources? Passing them as function parameters is not very convenient especially if they are used by multiple parts of the plugin.
m
Each
of
call produces a new instance, which is evaluated separately. However, each instance is only evaluated at most once, the result is cached.
v
Twice if the configuration cache entry gets reused
k
So safest way to optimize build times is to pass single reference everywhere?