reikje
reikje

Reputation: 3064

How do you disable distZip in a multi project builds on Kotlin DSL in Gradle

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"
}

This is sub/build.gradle.kts in my sub project:

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")
}

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

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" 

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

Upvotes: 7

Views: 3270

Answers (1)

Opal
Opal

Reputation: 84854

What you need is:

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

or:

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

Upvotes: 9

Related Questions