I'm using Gradle 5.5. I have a Groovy-based build script that I'm trying to migrate to the Kotlin DSL. The jar
task contains the typical line for copying all dependencies to the JAR file:
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
I can't find a way to translate this line to the Kotlin DSL.
Let me give you some context. This is my original Groovy-based build script:
plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.41"
}
group = "com.rhubarb_lip_sync"
version = "1.0.0"
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile "com.beust:klaxon:5.0.1"
compile "org.apache.commons:commons-lang3:3.9"
compile "no.tornado:tornadofx:1.7.19"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
manifest {
attributes "Main-Class": "com.rhubarb_lip_sync.rhubarb_for_spine.MainKt"
}
// This line of code recursively collects and copies all of a project"s files
// and adds them to the JAR itself. One can extend this task, to skip certain
// files or particular types at will
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
And this is my Kotlin-based build script. It's working fine, except for that one line:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.3.41"
}
group = "com.rhubarb_lip_sync"
version = "1.0.0"
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.beust:klaxon:5.0.1")
implementation("org.apache.commons:commons-lang3:3.9")
implementation("no.tornado:tornadofx:1.7.19")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<Jar> {
manifest {
attributes("Main-Class" to "com.rhubarb_lip_sync.rhubarb_for_spine.MainKt")
}
// ?
}