https://kotlinlang.org logo
Title
g

Gunslingor

07/07/2020, 2:54 AM
Could use a hand, does any one know why buildFatJar seems to build the jar correctly but then it never runs, saying it can't find the main class, however runLocally runs fine locally? I'd prefer not to use shadow... my experience with gradle, if there is one thing I've learned, mixing plugins is futile and a brain murderer.
register<Jar>("buildFatJar") {
    group = "application"
    manifest {
        attributes["Implementation-Title"] = "Gradle Jar File Example"
        attributes["Implementation-Version"] = archiveVersion
        attributes["Main-Class"] = "com.app.BackendAppKt"
    }
    archiveBaseName.set("${project.name}-fat")
    from(main.output.classesDirs, main.compileDependencyFiles)
    with(jar.get() as CopySpec)
}
register<JavaExec>("runLocally") {
    group = "application"
    setMain("com.app.BackendAppKt")
    classpath = main.output.classesDirs
    classpath += main.compileDependencyFiles
}
f

FranSoto

07/07/2020, 6:47 AM
It's manifest.mf generated? Its contents match your config?
c

Casey Brooks

07/07/2020, 5:52 PM
Shadow actually works really well with the kotlin plugin, both normal JVM plugin and Multiplatform plugin (using
jvm { withJava() }
). I’ve personally set it up many times, and it’s nearly trivial and works flawlessly. Have you actually tried using it?
g

Gunslingor

07/07/2020, 11:00 PM
Not sure what version you are using... anyway, the withJava was missing so that was a major issue along with others I documented here (second solution down: https://stackoverflow.com/questions/61245847/create-fat-jar-from-ktor-kotlin-multiplatform-project-with-kotlin-gradle-dsl I don' really understand what it is.