Nick Isaacs
04/24/2024, 8:51 PMgildor
04/25/2024, 2:51 AMNick Isaacs
04/25/2024, 2:55 AMgildor
04/25/2024, 2:59 AMgildor
04/25/2024, 2:59 AMgildor
04/25/2024, 3:00 AMNick Isaacs
04/25/2024, 3:05 AMgildor
04/25/2024, 4:38 AMKlitos Kyriacou
04/25/2024, 9:03 AMkotlin -cp <your-project's-jarfile>
. Download the kotlin compiler CLI from Github.Nick Isaacs
04/25/2024, 2:01 PMNick Isaacs
04/26/2024, 2:53 AM// Download the Kotlin compiler to run the REPL
tasks.register("downloadKotlinCompiler", Download::class) {
src("<https://github.com/JetBrains/kotlin/releases/download/v$kotlinVersion/kotlin-compiler-$kotlinVersion.zip>")
dest(layout.buildDirectory.file("kotlin-compiler.zip"))
}
// Unzip the Kotlin compiler to run the REPL
tasks.register("unzipKotlinCompiler", Copy::class) {
dependsOn("downloadKotlinCompiler")
from(zipTree(layout.buildDirectory.file("kotlin-compiler.zip")))
into(layout.buildDirectory.dir("kotlin-compiler"))
}
// REPL task, depends on the unzipping & download of the Kotlin compiler
tasks.register("repl", Exec::class.java) {
dependsOn("unzipKotlinCompiler")
// Set the working directory to where Kotlin bin is located
workingDir = layout.buildDirectory.dir("kotlin-compiler").get().asFile
val applicationClasspath = project.sourceSets["main"].runtimeClasspath.asPath
commandLine = listOf(
"kotlinc/bin/kotlin",
"-cp",
applicationClasspath
)
// Set up the standard I/O streams such that Gradle does not interfere
standardInput = System.`in`
standardOutput = System.out
errorOutput = System.err
}
run with ./gradlew repl --console=plain