Skip to content

Instantly share code, notes, and snippets.

@domnikl
Last active April 12, 2024 22:34
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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.

@axyiee
Copy link

axyiee commented Nov 17, 2020

thx

@Alceatraz
Copy link

Thankyou!

@khamroevjs
Copy link

Awesome!

@utenma
Copy link

utenma 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