Skip to content

Instantly share code, notes, and snippets.

@nickytoh
Created January 7, 2020 04:32
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 nickytoh/d04e380832f2d7ad31464b1841929f03 to your computer and use it in GitHub Desktop.
Save nickytoh/d04e380832f2d7ad31464b1841929f03 to your computer and use it in GitHub Desktop.
Generate a fat jar by Gradle Kotlin DSL.
// run gradle jar in the command line to get the jar
plugins {
java
application
kotlin("jvm") version "1.3.60"
}
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib", "1.3.60")) //
}
application {
mainClassName = "package.name.MainClassName" // Don't append Kt to class name.
}
val jar by tasks.getting(Jar::class) {
manifest {
attributes["Main-Class"] = application.mainClassName
}
from(configurations.compileClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment