Last active
November 29, 2018 23:41
-
-
Save fmamud/e557e77ffc523e91e6da377f216afa30 to your computer and use it in GitHub Desktop.
FatJar with Gradle Kotlin DSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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