如何在Gradle Kotlin-dsl中覆盖任务 [英] How do I overwrite a task in gradle kotlin-dsl

查看:136
本文介绍了如何在Gradle Kotlin-dsl中覆盖任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Groovy中,我覆盖了这样的任务:

In Groovy, I overwrite a task like this:

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

如何使用Kotlin-dsl做到这一点?我知道我可以创建这样的任务:

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

推荐答案

通过打开一个关于kotlin-dsl github 的问题,我找到了正确的语法:

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

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

但是,这是旧方法,在tasks { }块中不起作用,因此将进一步跟踪此问题

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

这篇关于如何在Gradle Kotlin-dsl中覆盖任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆