No main manifest attribute Gradle Kotlin DSL

You can get this error if you try to run jar without specifying the name of the class that contains fun main() and which you want to run.

To do this, you need to register the full class name in the Main-Class key of your manifest.

Plain jar without dependencies

tasks.jar {
    manifest {
        attributes("Main-Class" to "tech.mchesnavsky.MainKt")

You need to replace the line tech.mchesnavsky.MainKt with your class name. tech.mchesnavsky is the name of the package, it may not be there.

Fat jar (Uber jar) with dependencies

The code template below is taken from my last article:

tasks.register<Jar>("uberJar") {
        configurations.runtimeClasspath.get().filter {"jar") }.map { zipTree(it) }
    manifest {
        attributes("Main-Class" to "tech.mchesnavsky.MainKt")

That’s all.

Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at

If I saved your day, you can support me 🤝