I\'ve written a simple kotlin source file in order to get started, and a gradle script file. But I can\'t figure out how to add the main func to the manifest, so that the ja
If using Gradle
with the Kotlin
DSL
, then my duplicate question has an answer of:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
kotlin("jvm") version "1.2.51"
id("com.github.johnrengelman.shadow") version "2.0.4"
}
group = "xxx.yyy"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
tasks.withType {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType {
manifest.attributes.apply {
put("Implementation-Title", "Gradle Jar File Example")
//put("Implementation-Version" version)
put("Main-Class", "HelloKotlinWorld.App")
}
Which is, I think, the simplest solution. Oh, perhaps you're using just Kotlin
itself and not the DSL
.