KScript
Convenient kotlin script running engine for JVM.
Examples
Base class:
open class Test(val test: String)
KScript("println(test)").apply {
configuration.addClasspath(classpathFromClassOrException(Test::class))
configuration.setBaseClass<Test>(arguments = arrayOf("test"))
}.eval()
External dependencies
By default, library uses MavenExternalResolver, but we can change it:
val script = """...""".toKScript()
script.configuration.externalResolver = FilesExternalResolver(File("..."), File("...")) // one of the default implementations.
script.eval()
Also, we can cache it:
script.configuration.externalResolver = CacheableMavenResolver(File("path_to_cache_folder"))
Implementation
For now not everything is implemented, but it will be available upon request.
repositories {
maven("https://maven.kotlingang.fun")
}
dependencies {
implementation("fun.kotlingang.kscript:kscript:$version")
}