Thread
#multiplatform
    Kris Wong

    Kris Wong

    2 years ago
    has anyone setup an MPP to build a fat jar? or configured the java/shadow plugins?
    tasks.register<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
        val target = kotlin.targets["jvm"]
        dependsOn(target.artifactsTaskName)
    
        group = "shadow"
        description = "Builds a fat jar"
    
        val compilation = target.compilations["main"] as org.jetbrains.kotlin.gradle.plugin.KotlinCompilationToRunnableFiles
        from(compilation.output)
        configurations = listOf(compilation.runtimeDependencyFiles as Configuration)
    }
    Dico

    Dico

    2 years ago
    I tend to simply collect all compile dependencies into an archive task. No plugins required.
    val jvmFatJar by tasks.creating(Jar::class) {
        // set name & path
        from(*configurations["jvmMainCompile"].resolvedConfiguration.files.map { if (it.isFile) zipTree(it) else it }.toTypedArray())
    }
    Something like this, you may need to use
    afterEvaluate
    Might be able to improve it with new model.
    Kris Wong

    Kris Wong

    2 years ago
    yeah, that's way outside my wheelhouse, and already using shadow on another project
    but thanks!