Skip to content

Instantly share code, notes, and snippets.

@domnikl
Last active February 2, 2025 14:53
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"
}
}
@ttpro1995
Copy link

thanks

@austin0925
Copy link

thanks

@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.

Copy link

ghost commented Nov 17, 2020

thx

@Alceatraz
Copy link

Thankyou!

@khamroevjs
Copy link

Awesome!

@3xau1o
Copy link

3xau1o commented Jul 14, 2021

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