如何在Gradle中基于Kotlin DSL的多项目中禁用distZip [英] How do you disable distZip in a multi project builds on Kotlin DSL in Gradle

查看:72
本文介绍了如何在Gradle中基于Kotlin DSL的多项目中禁用distZip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Kotlin DSL建立了Gradle多项目构建。这是根目录中的 build.gradle.kts

I have set up a Gradle multi project build using Kotlin DSL. This is build.gradle.kts in the root:

plugins {
    kotlin("jvm") version "1.2.70" apply false
}

allprojects {
    repositories {
      mavenCentral()
    }
}

subprojects {
    version = "1.0"
}

这是我的子项目中的 sub / build.gradle.kts

plugins {
    application
    kotlin("jvm")
}

application {
    mainClassName = "me.package.MainKt"
}

dependencies {
    compile(kotlin("stdlib"))
    compile("io.github.microutils:kotlin-logging:1.6.10")
    compile("ch.qos.logback:logback-classic:1.2.3")
}

当我运行 $ gradle build 时,应用程序插件为我创建了一个发行版在 sub / build / distribution 中。

When I run $ gradle build the application plugin creates me a distribution in sub/build/distribution.

我不需要zip发行版,也不需要tar发行版中的版本号。两者在常规 build.gradle 中都应该是微不足道的:

I don't need the zip distribution and I want no version number in the tar distribution. Both should be trivial in the regular build.gradle like:

distZip.enabled = false
distTar.archiveName = "${project.name}.tar" 

无论我尝试使用Kotlin DSL多少,都会得到未解决的参考:distZip 。如何处理 distZip distTar 任务?

Whatever I try using Kotlin DSL, I get Unresolved reference: distZip. How do I address the distZip and distTar tasks?

推荐答案

您需要的是:

val distZip by tasks
distZip.enabled = false
val distTar by tasks
distTar.archiveName = "${project.name}.tar" 

或:

tasks.getByName<Zip>("distZip").enabled = false
tasks.getByName<Tar>("distTar").archiveName = "${project.name}.tar" 

这篇关于如何在Gradle中基于Kotlin DSL的多项目中禁用distZip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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