Implement automatic loading of .main.kts scripts support

also fix discovery from ScriptDefinitionsProvider
This commit is contained in:
Ilya Chernikov
2020-01-10 12:43:52 +01:00
parent d15d62a338
commit b5ac35dec1
5 changed files with 45 additions and 7 deletions
@@ -100,13 +100,15 @@ interface KotlinPaths {
CoroutinesCore(PathUtil.KOTLINX_COROUTINES_CORE_NAME),
KotlinDaemon(PathUtil.KOTLIN_DAEMON_NAME),
Ktor(PathUtil.KTOR_NAME),
MainKts(PathUtil.MAIN_KTS_NAME)
}
// TODO: Maybe we need separate classpaths for compilers with and without the daemon
enum class ClassPaths(val contents: List<Jar> = emptyList()) {
Empty(),
Compiler(Jar.Compiler, Jar.StdLib, Jar.Reflect, Jar.ScriptRuntime, Jar.Trove4j, Jar.KotlinDaemon, Jar.Ktor),
CompilerWithScripting(Compiler, Jar.ScriptingPlugin, Jar.ScriptingImpl, Jar.ScriptingLib, Jar.ScriptingJvmLib)
CompilerWithScripting(Compiler, Jar.ScriptingPlugin, Jar.ScriptingImpl, Jar.ScriptingLib, Jar.ScriptingJvmLib),
MainKts(Jar.MainKts, Jar.ScriptRuntime, Jar.StdLib, Jar.Reflect)
;
constructor(vararg jars: Jar) : this(jars.asList())
@@ -79,6 +79,7 @@ object PathUtil {
const val KOTLIN_SCRIPTING_COMPILER_IMPL_JAR = "$KOTLIN_SCRIPTING_COMPILER_IMPL_NAME.jar"
const val JS_ENGINES_NAME = "js.engines"
const val JS_ENGINES_JAR = "$JS_ENGINES_NAME.jar"
const val MAIN_KTS_NAME = "kotlin-main-kts"
val KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS = arrayOf(
KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR, KOTLIN_SCRIPTING_COMPILER_IMPL_JAR,