Created
January 5, 2020 03:56
-
-
Save apolaskey/21411c7c7982b1981818cb6b3e766431 to your computer and use it in GitHub Desktop.
Gradle Kotlin Fat Jar with Main
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
// Put main in companion object of said class | |
/* | |
class App { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
System.out.println("Hello") | |
} | |
} | |
} | |
*/ | |
val jar by tasks.getting(Jar::class) { | |
manifest { | |
attributes["Implementation-Title"] = "MyApp" | |
attributes["Implementation-Version"] = "1.0.0" | |
attributes["Main-Class"] = "com.server.App" | |
} | |
from(configurations.compileClasspath.get().map { | |
logger.info("File: " + it.name) | |
if (it.isDirectory) it else zipTree(it) | |
}) | |
} | |
// Run with "gradle clean jar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment