Skip to content

Instantly share code, notes, and snippets.

@domnikl
Last active October 11, 2024 11:06
Show Gist options
  • Save domnikl/c19c7385927a7bef7217aa036a71d807 to your computer and use it in GitHub Desktop.
Save domnikl/c19c7385927a7bef7217aa036a71d807 to your computer and use it in GitHub Desktop.
Gradle Kotlin DSL: set main class attribute for jar
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "com.example.MainKt"
}
}
@sylhare
Copy link

sylhare commented May 12, 2020

You can have a complete example on stackoverflow on how to set up your build.gradle.kts for it to work. Just that may not be enough to build your kotlin jar.

@axyiee
Copy link

axyiee commented Nov 17, 2020

thx

@Alceatraz
Copy link

Thankyou!

@khamroevjs
Copy link

Awesome!

@elsaulio
Copy link

tasks.withType<Jar> {
    manifest {
        attributes["Main-Class"] = "com.example.MainKt"
    }
}

@samuelneff
Copy link

Also

tasks.jar {
    manifest {
        attributes["Main-Class"] = "com.example.MainKt"
    }
}

@bartekpacia
Copy link

thanks

@kidofcubes
Copy link

thanks

@keanetay624
Copy link

thanks

@betterclient
Copy link

thank you!!

@pmatsinopoulos
Copy link

Thank you!

@NotThatRqd
Copy link

thx

@Kyu
Copy link

Kyu commented Aug 30, 2023

You can have a complete example on stackoverflow on how to set up your build.gradle.kts for it to work. Just that may not be enough to build your kotlin jar.

@sylhare mvp 👑, works great for the new gradle build.gradle.kts files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment