Hi everyone. I'd like to install this script in my...
# gradle
r
Hi everyone. I'd like to install this script in my build:
Copy code
// Assuming Kotlin plugin is applied...
 
// Run as: ./gradlew kotlinRepl --console plain --no-daemon
val kotlinRepl by tasks.creating {
  dependsOn("assemble")
  doFirst {
    val buildscriptClasspath = rootProject.buildscript.configurations["classpath"]
 
    val embeddedableCompiler = buildscriptClasspath
      .resolvedConfiguration
      .resolvedArtifacts
      .first { it.name == "kotlin-compiler-embeddable" }
    val jarLocation = embeddedableCompiler.file
 
    val mainClasspath = java.sourceSets["main"].runtimeClasspath.joinToString(separator = ":")
    javaexec {
      classpath = files(jarLocation)
      main = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
      standardInput = System.`in`
      args("-cp", mainClasspath)
    }
  }
}
but when It attempts to compile it, it bails with:
Copy code
Caused by: org.gradle.cache.CacheOpenException: Could not open cache directory 1w2yoljzkhbi9mrklhbh5ttcm (/home/raulraja/.gradle/caches/4.4.1/gradle-kotlin-dsl/1w2yoljzkhbi9mrklhbh5ttcm)
no other useful information. Any ideas of what I must be doing wrong? other kotlin scripts for example the one I have for detekt works fine.
m
Are there any script compilation errors? This seems to be the exception that pops up and it is sort of hidden
r
Nothing even with
--stacktrace
that I can tell from the output