kscript icon indicating copy to clipboard operation
kscript copied to clipboard

Runtime dependencies not included in `--package` option

Open Dogacel opened this issue 1 year ago • 0 comments

https://github.com/kscripting/kscript/blob/6acd4e1907478c49cc4e3db640200f926933b15d/src/main/kotlin/io/github/kscripting/kscript/code/GradleTemplates.kt#L69-L78

Here I see that we don't use runtimeClasspath and in some scenarios, we need to.

I guess something like so,

from({
    configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }
})

For example,

@file:DependsOn("com.linecorp.armeria:armeria:1.30.1")

import com.linecorp.armeria.client.WebClient

val wc = WebClient.of("https://ssl-checker.io/api/v1/check/")

wc
    .get("/example.com")
    .aggregate()
    .thenAccept { response ->
        println(response.contentUtf8())
    }.join()

Try this script, it works when run using kscript, however it doesn't work when compiled with --package option.

You need to add @file:DependsOn("io.netty:netty-handler-proxy:4.1.112.Final") to make it compile.

Dogacel avatar Oct 16 '24 04:10 Dogacel