DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Kotlin scripts with JAR dependencies

I wonder if this is possible, I mean, without Gradle or Maven?

Top comments (5)

Collapse
 
nfrankel profile image
Nicolas Fränkel

Yes, it is possible.

First, install the official Kotlin Scripting environment through SDK Man.

Then, just add the @file:DependsOn directive in the .kts script file e.g.:

@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11")
Enter fullscreen mode Exit fullscreen mode

Done

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

How do I install with SDK Man?

Thanks that it is an official support as well, though I don't know how well it would integrate with IntelliJ.

Kotlin support in VSCode is horrible. Seems to be only syntax highlighting.

Collapse
 
nfrankel profile image
Nicolas Fränkel

How do I install with SDK Man?

sdk install kotlin

cf. kotlinlang.org/docs/tutorials/comm...

I don't know how well it would integrate with IntelliJ.

You've got everything that you've in regular Kotlin projects

Collapse
 
alxgrk profile image
Alexander Girke
Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt • Edited

It works, but Java 8 is required... (Cannot use 11 or 14)

Fortunately, it is much easier (and safer?) to switch Java on Linux than on macOS.

computingforgeeks.com/how-to-set-d...

Cool, it even has --idea support. (That is, full IDE suggestion.)