简体   繁体   English

如何在gradle kotlin-dsl中覆盖任务

[英]How do I overwrite a task in gradle kotlin-dsl

In Groovy, I overwrite a task like this: 在Groovy中,我覆盖了这样的任务:

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

How do I do that with Kotlin-dsl? 我怎么用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 但我找不到将其声明为覆盖的等效方法,这会导致错误

By opening an issue on the kotlin-dsl github I found the correct syntax: 通过在kotlin-dsl github上打开一个问题,我找到了正确的语法:

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 但是,这是旧方法,并且在tasks { }块内不起作用,因此将在此处进一步跟踪此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM