定义删除任务时出错
Error defining delete task
我在使用以下 DSL 脚本块时遇到错误。
val DerbyDbDataFolder: File = file("DerbyDbData")
val DerbyLog: File = file("derby.log")
tasks {
var cleanDerbyDbData by creating (Delete::class) {
delete(DerbyDbDataFolder)
delete(DerbyLog)
}
"clean" {
dependsOn(cleanDerbyDbData)
}
}
但是我收到以下错误消息。
var cleanDerbyDbData by creating (Delete::class) {
^ Missing 'setValue(Nothing?, KProperty<*>, Delete)' method on delegate of type 'PolymorphicDomainObjectContainer<Delete>'
此错误消息是什么,我该如何解决?
TLDR
将 cleanDerbyDbData
定义为 val
而不是 var
:
val DerbyDbDataFolder: File = file("DerbyDbData")
val DerbyLog: File = file("derby.log")
tasks {
val cleanDerbyDbData by creating (Delete::class) {
delete(DerbyDbDataFolder)
delete(DerbyLog)
}
"clean" {
dependsOn(cleanDerbyDbData)
}
}
详情
cleanDerbyDbData
是 creating()
函数返回的 delegated property, and for it to be a var
, the expression to the right of by
must return a mutable value. The PolymorphicDomainObjectContainerDelegateProvider 不提供任何设置器,这就是您看到的错误。
我在使用以下 DSL 脚本块时遇到错误。
val DerbyDbDataFolder: File = file("DerbyDbData")
val DerbyLog: File = file("derby.log")
tasks {
var cleanDerbyDbData by creating (Delete::class) {
delete(DerbyDbDataFolder)
delete(DerbyLog)
}
"clean" {
dependsOn(cleanDerbyDbData)
}
}
但是我收到以下错误消息。
var cleanDerbyDbData by creating (Delete::class) {
^ Missing 'setValue(Nothing?, KProperty<*>, Delete)' method on delegate of type 'PolymorphicDomainObjectContainer<Delete>'
此错误消息是什么,我该如何解决?
TLDR
将 cleanDerbyDbData
定义为 val
而不是 var
:
val DerbyDbDataFolder: File = file("DerbyDbData")
val DerbyLog: File = file("derby.log")
tasks {
val cleanDerbyDbData by creating (Delete::class) {
delete(DerbyDbDataFolder)
delete(DerbyLog)
}
"clean" {
dependsOn(cleanDerbyDbData)
}
}
详情
cleanDerbyDbData
是 creating()
函数返回的 delegated property, and for it to be a var
, the expression to the right of by
must return a mutable value. The PolymorphicDomainObjectContainerDelegateProvider 不提供任何设置器,这就是您看到的错误。