You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try and use providers as inputs for expand, they are accepted, but their values are not computed. Instead, expand() will instead just call toString() on the values, resulting in invalid data.
Example
// build.gradle.ktsval projectPath:Provider<String> = provider { project.path }
val mySyncTask by tasks.registering(Sync::class) {
from(
resources.text.fromString(
"This file was created by project \${projectPath}"
).asFile()
)
into(temporaryDir)
expand(
"projectPath" to projectPath
)
doLast {
temporaryDir.walk().filter { it.isFile }.forEach {
println(it.readText())
}
}
}
Expected output:
> Task :mySyncTask
This file was created by project :
Current Behavior
The actual output does not compute the value of projectPath, resulting invalid output.
> Task :mySyncTask
This file was created by project fixed(class java.lang.String, :)
Context
Reproduced on Gradle 7.6 and 8.0.2
Workaround
As a workaround I have to compute the property in a doFirst {} block. This is unintuitive and confusing.
// build.gradle.ktsval projectPath:Provider<String> = provider { project.path }
val mySyncTask by tasks.registering(Sync::class) {
from(
resources.text.fromString(
"This file was created by project \${projectPath}"
).asFile()
)
into(temporaryDir)
// redefine the variable to be compatible Gradle Config Cacheval projectPath = projectPath
doFirst {
expand(
"projectPath" to projectPath.get()
)
}
doLast {
temporaryDir.walk().filter { it.isFile }.forEach {
println(it.readText())
}
}
}
This produces the correct result
This file was created by project :
The text was updated successfully, but these errors were encountered:
This feature request is in the backlog of the relevant team but this area of Gradle is currently not a focus one so it might take a while before it gets implemented.
I want to use
AbstractCopyTask.expand()
to expand variables when I am Syncing files.When I try and use providers as inputs for
expand
, they are accepted, but their values are not computed. Instead,expand()
will instead just calltoString()
on the values, resulting in invalid data.Example
Expected output:
Current Behavior
The actual output does not compute the value of
projectPath
, resulting invalid output.Context
Reproduced on Gradle 7.6 and 8.0.2
Workaround
As a workaround I have to compute the property in a
doFirst {}
block. This is unintuitive and confusing.This produces the correct result
The text was updated successfully, but these errors were encountered: