This message was deleted.
# configuration-cache
s
This message was deleted.
v
Iirc they were compatible before if not even introduce because of CC, but I think what changed is, that the auto-detection of CC inputs like read properties, read files, and so on is disabled within the value source value calculation. (Except if you have one value source backed property as input to the value source as there is a bug that the disabling of the detection is quit before the actual value is calculated)
t
yeah, in my case I want to read
local.properties
via
ValueSource
but Gradle 7.3.3 complains about it
v
Complains with what?
t
Adding
.forUseWithConfigurationCache()
doesn't help either
Here is the message:
Copy code
Cannot obtain value from provider of Kotlin_bootstrap_settings_gradle.PropertiesValueSource at configuration time.
Use a provider returned by 'forUseAtConfigurationTime()' instead.
and here is the
ValueSource
code:
Copy 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) }
        }
    }
}
v
Hm, not sure. Did you try to use the
forUseAtConfigurationTime()
on both those properties?
t
More code:
Copy code
private 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 called
m
I suspect that
forUseAtConfigurationTime
is not propagated upstream, so you have to sprinkle it onto every "unsafe" provider:
Copy code
val customBootstrapRepo = localProperties
    .forUseAtConfigurationTime()
    .map { it.getProperty("someProperty") }
    .orElse(providers.gradleProperty("someProperty").forUseAtConfigurationTime())
at least, that's my reading of the forUseAtConfigurationTime code
t
Thank you! That solved the issue!