Expected Behavior
It should work
Current Behavior
It does not. Property is always considered "not present"
Context
I am trying to use the new ProviderFactory#gradleProperty() APIs to better prepare for configuration caching.
Steps to Reproduce
Repro case:
This project + branch: https://github.com/ZacSweers/CatchUp/compare/z/gradlePropertyIssueDemo?expand=1
In app/build.gradle.kts there are two properties used, one local to app and the other local to the whole project.
val localProperty = providers.gradleProperty("localProperty").orElse("not found")
val rootProperty = providers.gradleProperty("rootProperty").orElse("not found")
println("Local property is ${localProperty.get()}")
println("Root property is ${rootProperty.get()}")
Run ./gradlew help
Observe that the local property is not found and only the root project is
> Configure project :app
Local property is not found
Root property is rootPropertyValue
I would expect that the localProperty would be found. If I manually do it like so
val localProperty = providers.provider { property("localProperty")?.toString() }.orElse("not found")
it works
> Configure project :app
Local property is localPropertyValue
Root property is rootPropertyValue
This is with Gradle 6.4.1. I gave it a try on 6.5-rc-1, but to no avail. A slight change is that 6.5 doesn't allow resolving those at configuration time, but with a simple dummy task:
val localProperty = providers.gradleProperty("localProperty").orElse("not found")
val rootProperty = providers.gradleProperty("rootProperty").orElse("not found")
abstract class DummyTask : DefaultTask() {
@get:Input abstract val localPropertyProp: Property<String>
@get:Input abstract val rootPropertyProp: Property<String>
@TaskAction
fun act() {
println("Local property is ${localPropertyProp.get()}")
println("Root property is ${rootPropertyProp.get()}")
}
}
tasks.register<DummyTask>("testingThingsOut") {
localPropertyProp.set(localProperty)
rootPropertyProp.set(rootProperty)
}
And then running ./gradlew testingThingsOut
> Task :app:testingThingsOut
Local property is not found
Root property is rootPropertyValue
Still no dice :/
Your Environment
Build scan URL:
Expected Behavior
It should work
Current Behavior
It does not. Property is always considered "not present"
Context
I am trying to use the new
ProviderFactory#gradleProperty()APIs to better prepare for configuration caching.Steps to Reproduce
Repro case:
This project + branch: https://github.com/ZacSweers/CatchUp/compare/z/gradlePropertyIssueDemo?expand=1
In
app/build.gradle.ktsthere are two properties used, one local toappand the other local to the whole project.Run
./gradlew helpObserve that the local property is not found and only the root project is
I would expect that the
localPropertywould be found. If I manually do it like soit works
This is with Gradle 6.4.1. I gave it a try on 6.5-rc-1, but to no avail. A slight change is that 6.5 doesn't allow resolving those at configuration time, but with a simple dummy task:
And then running
./gradlew testingThingsOutStill no dice :/
Your Environment
Build scan URL: