Skip to content

Instantly share code, notes, and snippets.

@domnikl
Last active January 28, 2026 00:01
Show Gist options
  • Select an option

  • Save domnikl/c19c7385927a7bef7217aa036a71d807 to your computer and use it in GitHub Desktop.

Select an option

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"
}
}
@ttpro1995
Copy link
Copy Markdown

thanks

@austin0925
Copy link
Copy Markdown

thanks

@sylhare
Copy link
Copy Markdown

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.

Copy link
Copy Markdown

ghost commented Nov 17, 2020

thx

@Alceatraz
Copy link
Copy Markdown

Thankyou!

@khamroevjs
Copy link
Copy Markdown

Awesome!

@3xau1o
Copy link
Copy Markdown

3xau1o commented Jul 14, 2021

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

@samuelneff
Copy link
Copy Markdown

Also

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

@bartekpacia
Copy link
Copy Markdown

thanks

@kidofcubes
Copy link
Copy Markdown

thanks

@keanetay624
Copy link
Copy Markdown

thanks

@betterclient
Copy link
Copy Markdown

thank you!!

@pmatsinopoulos
Copy link
Copy Markdown

Thank you!

@NotThatRqd
Copy link
Copy Markdown

thx

@Kyu
Copy link
Copy Markdown

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

@Yedelo
Copy link
Copy Markdown

Yedelo commented Jun 25, 2025

thanks

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