Slackbot
10/14/2022, 9:55 AMVampire
10/14/2022, 10:13 AMTapchicoma
10/14/2022, 10:14 AMlocal.properties
via ValueSource
but Gradle 7.3.3 complains about itVampire
10/14/2022, 10:14 AMTapchicoma
10/14/2022, 10:14 AM.forUseWithConfigurationCache()
doesn't help eitherTapchicoma
10/14/2022, 10:17 AMCannot obtain value from provider of Kotlin_bootstrap_settings_gradle.PropertiesValueSource at configuration time.
Use a provider returned by 'forUseAtConfigurationTime()' instead.
Tapchicoma
10/14/2022, 10:17 AMValueSource
code:
abstract class PropertiesValueSource : ValueSource<Properties, PropertiesValueSource.Parameters> {
interface Parameters : ValueSourceParameters {
val fileName: Property<String>
val rootDir: Property<File>
}
override fun obtain(): Properties {
return parameters.rootDir.get().resolve(
parameters.fileName.get()
).bufferedReader().use {
Properties().apply { load(it) }
}
}
}
Vampire
10/14/2022, 10:18 AMforUseAtConfigurationTime()
on both those properties?Tapchicoma
10/14/2022, 10:19 AMprivate val localProperties = providers.of(PropertiesValueSource::class.java) {
parameters {
fileName.set("local.properties")
rootDir.set(settings.rootDir)
}
}
val customBootstrapRepo = localProperties
.map { it.getProperty(Config.REPO_KEY) }
.orElse(providers.gradleProperty(Config.REPO_KEY))
.forUseAtConfigurationTime()
Gradle complains when customBootstrapRepo.orNull
is calledMikhail Lopatkin
10/14/2022, 4:20 PMforUseAtConfigurationTime
is not propagated upstream, so you have to sprinkle it onto every "unsafe" provider:
val customBootstrapRepo = localProperties
.forUseAtConfigurationTime()
.map { it.getProperty("someProperty") }
.orElse(providers.gradleProperty("someProperty").forUseAtConfigurationTime())
at least, that's my reading of the forUseAtConfigurationTime codeTapchicoma
10/14/2022, 9:05 PM