diff --git a/compiler/compiler.pro b/compiler/compiler.pro index 4ae1f210c35..b168a471463 100644 --- a/compiler/compiler.pro +++ b/compiler/compiler.pro @@ -67,6 +67,9 @@ messages/**) -dontwarn org.apache.batik.script.rhino.RhinoInterpreter -dontwarn org.apache.batik.script.rhino.RhinoInterpreterFactory +# The appropriate jar is either loaded separately or added explicitly to the classpath then needed +-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar + -dontwarn org.jdom.xpath.jaxen.* -dontwarn com.intellij.util.io.Decompressor* -dontwarn org.w3c.dom.Location diff --git a/compiler/compiler.pro.181 b/compiler/compiler.pro.181 index 7a109115e96..51b5aa0ccc1 100644 --- a/compiler/compiler.pro.181 +++ b/compiler/compiler.pro.181 @@ -58,6 +58,9 @@ messages/**) # Depends on apache batik which has lots of dependencies -dontwarn com.intellij.util.SVGLoader* +# The appropriate jar is either loaded separately or added explicitly to the classpath then needed +-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar + #-libraryjars '' #-libraryjars '' #-libraryjars '' diff --git a/compiler/compiler.pro.191 b/compiler/compiler.pro.191 index 02131f66d7b..6cac2e1c540 100644 --- a/compiler/compiler.pro.191 +++ b/compiler/compiler.pro.191 @@ -68,6 +68,9 @@ messages/**) -dontwarn org.apache.batik.script.rhino.RhinoInterpreter -dontwarn org.apache.batik.script.rhino.RhinoInterpreterFactory +# The appropriate jar is either loaded separately or added explicitly to the classpath then needed +-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar + -dontwarn org.jdom.xpath.jaxen.* -dontwarn com.intellij.util.io.Decompressor* -dontwarn org.w3c.dom.Location diff --git a/compiler/compiler.pro.as32 b/compiler/compiler.pro.as32 index 1fbc1318b98..0cc79a79ec8 100644 --- a/compiler/compiler.pro.as32 +++ b/compiler/compiler.pro.as32 @@ -59,6 +59,9 @@ messages/**) # Depends on apache batick which has lots of dependencies -dontwarn com.intellij.util.SVGLoader* +# The appropriate jar is either loaded separately or added explicitly to the classpath then needed +-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar + #-libraryjars '' #-libraryjars '' #-libraryjars '' diff --git a/compiler/compiler.pro.as34 b/compiler/compiler.pro.as34 index 02131f66d7b..6cac2e1c540 100644 --- a/compiler/compiler.pro.as34 +++ b/compiler/compiler.pro.as34 @@ -68,6 +68,9 @@ messages/**) -dontwarn org.apache.batik.script.rhino.RhinoInterpreter -dontwarn org.apache.batik.script.rhino.RhinoInterpreterFactory +# The appropriate jar is either loaded separately or added explicitly to the classpath then needed +-dontwarn org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar + -dontwarn org.jdom.xpath.jaxen.* -dontwarn com.intellij.util.io.Decompressor* -dontwarn org.w3c.dom.Location diff --git a/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts b/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts index 05d315f8fcc..89e6d0e528f 100644 --- a/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts +++ b/libraries/examples/kotlin-jsr223-daemon-local-eval-example/build.gradle.kts @@ -17,6 +17,7 @@ dependencies { testCompile(project(":kotlin-test:kotlin-test-junit")) testRuntime(project(":kotlin-reflect")) compilerClasspath(projectRuntimeJar(":kotlin-compiler-embeddable")) + compilerClasspath(projectRuntimeJar(":kotlin-scripting-compiler-embeddable")) compilerClasspath(project(":kotlin-reflect")) compilerClasspath(kotlinStdlib()) compilerClasspath(project(":kotlin-script-runtime")) diff --git a/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts b/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts index e7adb614344..3761186b975 100644 --- a/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts +++ b/libraries/examples/kotlin-jsr223-local-example/build.gradle.kts @@ -17,6 +17,7 @@ dependencies { compileOnly(project(":compiler:cli-common")) // TODO: fix import (workaround for jps build) testCompileOnly(project(":core:util.runtime")) // TODO: fix import (workaround for jps build) testCompileOnly(project(":compiler:daemon-common")) // TODO: fix import (workaround for jps build) + testRuntime(projectRuntimeJar(":kotlin-scripting-compiler-embeddable")) } projectTest() diff --git a/libraries/scripting/jvm/src/kotlin/script/experimental/jvm/util/jvmClasspathUtil.kt b/libraries/scripting/jvm/src/kotlin/script/experimental/jvm/util/jvmClasspathUtil.kt index 13a1018d775..0826dbd6131 100644 --- a/libraries/scripting/jvm/src/kotlin/script/experimental/jvm/util/jvmClasspathUtil.kt +++ b/libraries/scripting/jvm/src/kotlin/script/experimental/jvm/util/jvmClasspathUtil.kt @@ -22,6 +22,10 @@ internal const val KOTLIN_JAVA_STDLIB_JAR = "kotlin-stdlib.jar" internal const val KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar" internal const val KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.jar" internal const val TROVE4J_JAR = "trove4j.jar" +internal const val KOTLIN_SCRIPTING_COMPILER_JAR = "kotlin-scripting-compiler.jar" +internal const val KOTLIN_SCRIPTING_COMPILER_EMBEDDABLE_JAR = "kotlin-scripting-compiler-embeddable.jar" +internal const val KOTLIN_SCRIPTING_COMMON_JAR = "kotlin-scripting-common.jar" +internal const val KOTLIN_SCRIPTING_JVM_JAR = "kotlin-scripting-jvm.jar" internal const val KOTLIN_COMPILER_NAME = "kotlin-compiler" internal const val KOTLIN_COMPILER_JAR = "$KOTLIN_COMPILER_NAME.jar" @@ -158,6 +162,14 @@ object KotlinJars { } val compilerClasspath: List by lazy { + findCompilerClasspath(withScripting = false) + } + + val compilerWithScriptingClasspath: List by lazy { + findCompilerClasspath(withScripting = true) + } + + private fun findCompilerClasspath(withScripting: Boolean): List { val kotlinCompilerJars = listOf( KOTLIN_COMPILER_JAR, KOTLIN_COMPILER_EMBEDDABLE_JAR @@ -168,22 +180,32 @@ object KotlinJars { KOTLIN_JAVA_SCRIPT_RUNTIME_JAR, TROVE4J_JAR ) - val kotlinBaseJars = kotlinCompilerJars + kotlinLibsJars + val kotlinScriptingJars = if (withScripting) listOf( + KOTLIN_SCRIPTING_COMPILER_JAR, + KOTLIN_SCRIPTING_COMPILER_EMBEDDABLE_JAR, + KOTLIN_SCRIPTING_COMMON_JAR, + KOTLIN_SCRIPTING_JVM_JAR + ) else emptyList() + + val kotlinBaseJars = kotlinCompilerJars + kotlinLibsJars + kotlinScriptingJars val classpath = explicitCompilerClasspath - // search classpath from context classloader and `java.class.path` property - ?: (classpathFromFQN( - Thread.currentThread().contextClassLoader, - "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" - ) - ?: classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIf { it.isNotEmpty() } - ?: classpathFromClasspathProperty() - )?.filter { f -> kotlinBaseJars.any { f.matchMaybeVersionedFile(it) } }?.takeIf { it.isNotEmpty() } + // search classpath from context classloader and `java.class.path` property + ?: (classpathFromFQN( Thread.currentThread().contextClassLoader, "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" ) + ?: classpathFromClassloader(Thread.currentThread().contextClassLoader)?.takeIf { it.isNotEmpty() } + ?: classpathFromClasspathProperty() + )?.filter { f -> kotlinBaseJars.any { f.matchMaybeVersionedFile(it) } }?.takeIf { it.isNotEmpty() } // if autodetected, additionally check for presence of the compiler jars - if (classpath == null || (explicitCompilerClasspath == null && classpath.none { f -> kotlinCompilerJars.any { f.matchMaybeVersionedFile(it) } })) { + if (classpath == null || (explicitCompilerClasspath == null && classpath.none { f -> + kotlinCompilerJars.any { + f.matchMaybeVersionedFile( + it + ) + } + })) { throw FileNotFoundException("Cannot find kotlin compiler jar, set kotlin.compiler.classpath property to proper location") } - classpath!! + return classpath!! } fun getLib(propertyName: String, jarName: String, markerClass: KClass<*>, classLoader: ClassLoader? = null): File? = diff --git a/libraries/tools/kotlin-script-util/src/main/kotlin/org/jetbrains/kotlin/script/jsr223/KotlinJsr223ScriptEngineFactoryExamples.kt b/libraries/tools/kotlin-script-util/src/main/kotlin/org/jetbrains/kotlin/script/jsr223/KotlinJsr223ScriptEngineFactoryExamples.kt index fac467988a1..0658d1608b9 100644 --- a/libraries/tools/kotlin-script-util/src/main/kotlin/org/jetbrains/kotlin/script/jsr223/KotlinJsr223ScriptEngineFactoryExamples.kt +++ b/libraries/tools/kotlin-script-util/src/main/kotlin/org/jetbrains/kotlin/script/jsr223/KotlinJsr223ScriptEngineFactoryExamples.kt @@ -42,7 +42,7 @@ class KotlinJsr223JvmDaemonLocalEvalScriptEngineFactory : KotlinJsr223JvmScriptE override fun getScriptEngine(): ScriptEngine = KotlinJsr223JvmDaemonCompileScriptEngine( this, - KotlinJars.compilerClasspath, + KotlinJars.compilerWithScriptingClasspath, scriptCompilationClasspathFromContextOrStlib("kotlin-script-util.jar", wholeClasspath = true), KotlinStandardJsr223ScriptTemplate::class.qualifiedName!!, { ctx, types -> ScriptArgsWithTypes(arrayOf(ctx.getBindings(ScriptContext.ENGINE_SCOPE)), types ?: emptyArray()) },