has anyone setup an MPP to build a fat jar? or con...
# multiplatform
k
has anyone setup an MPP to build a fat jar? or configured the java/shadow plugins?
Copy code
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)
}
d
I tend to simply collect all compile dependencies into an archive task. No plugins required.
Copy code
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.
k
yeah, that's way outside my wheelhouse, and already using shadow on another project
but thanks!