How do I overwrite a task in gradle kotlin-dsl

梦想与她 提交于 2019-12-22 10:28:08

问题


In Groovy, I overwrite a task like this:

task jar(overwrite: true) {
    ...
}

How do I do that with Kotlin-dsl? I know that I can create a task like this:

tasks {
     val jar by creating {
          ...
     }
}

but I can't find the equivalent way to declare it as overwrite, this leads to an error


回答1:


By opening an issue on the kotlin-dsl github I found the correct syntax:

tasks.replace("jar") {
    ...
}

However, this is the old way and does not work within a tasks { } block, so this issue will be further tracked here



来源:https://stackoverflow.com/questions/48553029/how-do-i-overwrite-a-task-in-gradle-kotlin-dsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!