Kotlin / kotlin-interactive-shell

Kotlin Language Interactive Shell
Apache License 2.0
587 stars 36 forks source link

`kotlinc -cp foo.jar` Equivalent #121

Open aryeh-looker opened 1 year ago

aryeh-looker commented 1 year ago

Does ki have something similar? i.e. to have some jars available in the classpath when the repl is loaded (i.e. without having to type :load).

aryeh-looker commented 1 year ago

I have accomplished this by a workaround, i.e. with https://github.com/Kotlin/kotlin-interactive-shell/issues/122; which invokes ki programmatically from a java process with the classpath set as desired.

aryeh-looker commented 1 year ago

One can also download the ki jar from mvnrepository (see the Files section and click on jar) and invoke it using:

CLASSPATH="a:b:c" java -jar path/to/ki-shell-0.5.2.jar

Unfortunately, one must also furnish dependencies like the kotlin reflection library and most other dependencies via classpath that are declared in https://repo1.maven.org/maven2/org/jetbrains/kotlinx/ki-shell/0.5.2/ki-shell-0.5.2.pom. Thus leveraging a build tool that furnishes required transitive dependencies for you as explained in https://github.com/Kotlin/kotlin-interactive-shell/issues/122 is a more easeful option (even just using mvn likely straightforward for this, though I personally don't use it often as my build tool thus don't know the gesture off-hand [though likely fairly quick to Google]).

It should be easy enough to add something like -cp or have ki leverage a CLASSPATH environment variable. I can potentially write a PR to support this at some point in the future if there is interest and if I haven't overlooked such existing functionality in this repo.