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

sylhare commented May 12, 2020

Copy link
Copy Markdown

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.

ghost commented Nov 17, 2020

Copy link
Copy Markdown

thx

@Alceatraz

Copy link
Copy Markdown

Thankyou!

@khamroevjs

Copy link
Copy Markdown

Awesome!

@3xau1o

3xau1o commented Jul 14, 2021

Copy link
Copy Markdown
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

Kyu commented Aug 30, 2023

Copy link
Copy Markdown

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

Yedelo commented Jun 25, 2025

Copy link
Copy Markdown

thanks

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