how do I generate a farJar for a multiplatform pro...
# multiplatform
c
how do I generate a farJar for a multiplatform project? I get weird dependency resolution errors (can't reconfigure commonApi?) when I try some of the things I found on the web (involving customising the jar task)
I was able to accomplish this using the following:
Copy code
kotlin {
    jvm() {
        compilations {
            val main = getByName("main")
            tasks {
                register<Jar>("buildFatJar") {
                    group = "application"
                    dependsOn(build)
                    manifest {
                        attributes["Main-Class"] = "my.package.MainKt"
                    }

                    excludes += "META-INF/versions/9/module-info.class"

                    from(configurations.getByName("jvmRuntimeClasspath").map { if (it.isDirectory) it else zipTree(it) }, main.output.classesDirs)
                    archiveBaseName.set("${project.name}-jar")
                }
            }
        }
        ...
t
I typically use the shadow plugin for that:
Copy code
plugins {
    id("com.github.johnrengelman.shadow") version "7.1.2"
}

tasks {
    shadowJar {
        mergeServiceFiles()
        //  minimize() // do not use minimize!!!
    }
}
Full example (this builds a docker image as well): https://github.com/spxbhuhb/zakadabar-application-template/blob/842effccf066cbb9e0469264311848bc370473f6/build.gradle.kts
c
have you tried it with a multiplatform project Tóth?
t
Yes, I work almost exclusively with multiplatform. The example project above builds a distribution zip which contains all the JVM and JavaScript needed. It also builds a docker image which contains everything.