Hello Amper (now Kotlin-toolchain?) team! I have t...
# kotlin-toolchain
a
Hello Amper (now Kotlin-toolchain?) team! I have to have application jar file with dependencies in child directory. How can I do the same in apmere (kotlin-toolchain)? Now in my `build.gradle.kts`:
Copy code
val copyDependencies by tasks.registering(Copy::class) {
    from(configurations.runtimeClasspath)
    into(layout.buildDirectory.dir("libs/lib"))
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.build {
    dependsOn(copyDependencies)
}

tasks.jar {
    archiveFileName.set("myApp.jar")
    manifest.attributes["Main-Class"] = "MainClassKt"
    manifest.attributes["Class-Path"] = configurations.runtimeClasspath.get().files.joinToString(" ") { "lib/${it.name}" }
}
a
Hi, thanks for reaching out Is package layout a hard requirement? If no, we provide building the executable package for jvm just out of box Try
kotlin package
a
Thank You! It works but... My app.jar has size less than 1Mb app-ampere-jvm-executable.jar - 31Mb When I have to update app on server I want to send only 1Mb. PS: In our production applications we have ~10Mb our code and more then 300Mb libraries (spark, aws etc). Our devops want to have different docker layer for application and libraries
a
Ah, I see, I didn't get you at first
I'll reply later on in 15 minutes after I come to the office (or someone from the team will take over :) )
✅ 1
we don't support that out of box (maybe we should, it's kind of classic distribution format) what you can do now is to implement a tiny extension, which would collect and put jars in the layout you'd like to preserve the example you can find in our repo
a
I've done MVP for this. Will this code help you implement this in Kotlin Toolchain?
a
I would encourage you to share no matter whether we use it or not for the implementation I personally would find it useful, there are a lot of signals we can extract from your implementation, so please share if you can and if It's not hard :)
a
https://codeshare.io/2pL9RV
Copy code
tasks:
  collectLibs:
    action: !collectLibs
      outputDir: ${taskOutputDir}
      baseClasspath: ${module.runtimeClasspath}
      rootDir: ${module.jar}
But it works properly only for single-module app. In multi-module app we have to copy all our jar files outside the lib folder