Kotlin Script Host - Embedded script compilation

Managed to find a solution.

I switched to the experimental scripting engine, and managed to find the following solution.

val SCRIPT_ENGINE_CONFIG by lazy {
    createJvmCompilationConfigurationFromTemplate<SimpleScript> {
        jvm {
            // wow, just...wow
            compilerOptions.append("-jvm-target")
            compilerOptions.append("1.8")
            compilerOptions.append("-Xnew-inference")
            compilerOptions.append("-Xinline-classes")
            dependenciesFromCurrentContext(
                    wholeClasspath = true
            )
        }
    }
}

val SCRIPT_HOST = BasicJvmScriptingHost()

@KotlinScript(fileExtension = "simplescript.kts")
abstract class SimpleScript

… and then using it like so…

val compileResult = SCRIPT_HOST.eval(StringScriptSource(finalScript), SCRIPT_ENGINE_CONFIG, null)

I don’t fully understand the purpose of the SimpleScript type…my gut tells me that the above could somehow be simplified further.