-
Notifications
You must be signed in to change notification settings - Fork 5k
Open
Labels
a:featureA new functionalityA new functionalityin:provider-apiproperty lazy provider MapProperty ListProperty DirectoryPropertyproperty lazy provider MapProperty ListProperty DirectoryProperty
Description
Expected Behavior
I am able to simply set a value into a DirectoryProperty
.
interface MyPluginConfig {
val targetDir: DirectoryProperty
val targetFile: RegularFileProperty
}
val myPluginConfig = extensions.create<MyPluginConfig>("myPlugin").apply {
targetDir.convention(project.providers.systemProperty("user.home").map { home ->
file("$home/.cache/myPlugin")
})
targetFile.convention(project.providers.systemProperty("user.home").map { home ->
file("$home/.cache/someFile")
})
}
Current Behavior
I am not able to simply set a value into a DirectoryProperty
.
interface MyPluginConfig {
val targetDir: DirectoryProperty
val targetFile: RegularFileProperty
}
val myPluginConfig = extensions.create<MyPluginConfig>("myPlugin").apply {
// ERROR: None of the following functions can be called with the arguments supplied.
targetDir.convention(project.providers.systemProperty("user.home").map { home ->
project.file("$home/.cache/myPlugin")
})
// None of the following functions can be called with the arguments supplied.
targetFile.convention(project.providers.systemProperty("user.home").map { home ->
file("$home/.cache/someFile")
})
}
Context
The workaround is really verbose, and is not intuitive at all.
interface MyPluginConfig {
val targetDir: DirectoryProperty
val targetFile: RegularFileProperty
}
val myPluginConfig = extensions.create<MyPluginConfig>("myPlugin").apply {
targetDir.convention(project.providers.systemProperty("user.home").flatMap { home ->
project.layout.dir(
project.providers.provider {
project.file("$home/.cache/myPlugin")
}
)
})
targetFile.set(providers.systemProperty("user.home").flatMap {
project.layout.file(
project.providers.provider {
project.file(it) }
)
})
}
Metadata
Metadata
Assignees
Labels
a:featureA new functionalityA new functionalityin:provider-apiproperty lazy provider MapProperty ListProperty DirectoryPropertyproperty lazy provider MapProperty ListProperty DirectoryProperty