How can I run the Kotlin REPL in the context of my Maven project?
This works, but is ugly:
kotlinc-jvm -cp target/classes/:`ruby -e "puts Dir['target/**/*.jar'].join(':')"`
I've tried different variations on the following (after using Maven to copy the compiler JAR as a dependency), but nothing works (Error: Could not find or load main class org.jetbrains.kotlin.runner.Main
):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-classpath</argument>
<argument>${project.basedir}/target/dependency/kotlin-compiler-1.0.0.jar</argument>
<argument>org.jetbrains.kotlin.runner.Main</argument>
</arguments>
</configuration>
</plugin>
Please try K2JVMCompiler
instead, since it's currently the entrypoint for REPL in kotlin-compiler.jar
:
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-classpath</argument>
<argument>${project.basedir}/target/dependency/kotlin-compiler-1.0.0.jar</argument>
<argument>org.jetbrains.kotlin.cli.jvm.K2JVMCompiler</argument>
</arguments>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With