Skip to content

Instantly share code, notes, and snippets.

@fmamud
Last active November 29, 2018 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmamud/e557e77ffc523e91e6da377f216afa30 to your computer and use it in GitHub Desktop.
Save fmamud/e557e77ffc523e91e6da377f216afa30 to your computer and use it in GitHub Desktop.
FatJar with Gradle Kotlin DSL
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM
kotlin("jvm").version("1.3.10")
application
}
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// Use the Kotlin JDK 8 standard library
compile(kotlin("stdlib-jdk8"))
// Use the Kotlin test library
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
compile("org.apache.commons:commons-lang3:3.8.1")
}
application {
// Define the main class for the application
mainClassName = "myproject.AppKt"
}
task<Jar>("fatJar") {
dependsOn("build")
manifest { attributes(mapOf("Main-Class" to application.mainClassName)) }
from("build/classes/kotlin/main")
configurations.runtime
.filter { it.name.endsWith(".jar") }
.forEach { from(zipTree(it)) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment