Make JSR 223 examples compatible with embeddable compiler, strip ...
some dependencies. Fixes #KT-17561 and related issues Warning: API changed slightly
This commit is contained in:
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.repl
|
|||||||
|
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
|
import com.intellij.openapi.util.Disposer
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.cli.common.repl.*
|
import org.jetbrains.kotlin.cli.common.repl.*
|
||||||
@@ -46,6 +47,9 @@ open class GenericReplCompiler(disposable: Disposable,
|
|||||||
messageCollector: MessageCollector
|
messageCollector: MessageCollector
|
||||||
) : ReplCompiler {
|
) : ReplCompiler {
|
||||||
|
|
||||||
|
constructor(scriptDefinition: KotlinScriptDefinition, compilerConfiguration: CompilerConfiguration, messageCollector: MessageCollector) :
|
||||||
|
this(Disposer.newDisposable(), scriptDefinition, compilerConfiguration, messageCollector)
|
||||||
|
|
||||||
private val checker = GenericReplChecker(disposable, scriptDefinition, compilerConfiguration, messageCollector)
|
private val checker = GenericReplChecker(disposable, scriptDefinition, compilerConfiguration, messageCollector)
|
||||||
|
|
||||||
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = GenericReplCompilerState(checker.environment, lock)
|
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = GenericReplCompilerState(checker.environment, lock)
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ dependencies {
|
|||||||
testCompile(project(":kotlin-script-runtime"))
|
testCompile(project(":kotlin-script-runtime"))
|
||||||
testCompile(project(":kotlin-script-util"))
|
testCompile(project(":kotlin-script-util"))
|
||||||
testCompile(project(":kotlin-daemon-client"))
|
testCompile(project(":kotlin-daemon-client"))
|
||||||
|
testCompile(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||||
testRuntime(project(":kotlin-reflect"))
|
testRuntime(project(":kotlin-reflect"))
|
||||||
compilerClasspath(projectRuntimeJar(":kotlin-compiler"))
|
compilerClasspath(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||||
compilerClasspath(projectDist(":kotlin-reflect"))
|
compilerClasspath(projectDist(":kotlin-reflect"))
|
||||||
compilerClasspath(projectDist(":kotlin-stdlib"))
|
compilerClasspath(projectDist(":kotlin-stdlib"))
|
||||||
compilerClasspath(projectDist(":kotlin-script-runtime"))
|
compilerClasspath(projectDist(":kotlin-script-runtime"))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ apply { plugin("kotlin") }
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile(projectDist(":kotlin-stdlib"))
|
compile(projectDist(":kotlin-stdlib"))
|
||||||
compile(projectDist(":kotlin-script-runtime"))
|
compile(projectDist(":kotlin-script-runtime"))
|
||||||
compile(projectRuntimeJar(":kotlin-compiler"))
|
compile(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||||
compile(project(":kotlin-script-util"))
|
compile(project(":kotlin-script-util"))
|
||||||
testCompile(projectDist(":kotlin-test:kotlin-test-junit"))
|
testCompile(projectDist(":kotlin-test:kotlin-test-junit"))
|
||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ dependencies {
|
|||||||
compileOnly("com.jcabi:jcabi-aether:0.10.1")
|
compileOnly("com.jcabi:jcabi-aether:0.10.1")
|
||||||
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
||||||
compileOnly("org.apache.maven:maven-core:3.0.3")
|
compileOnly("org.apache.maven:maven-core:3.0.3")
|
||||||
runtime(projectRuntimeJar(":kotlin-compiler"))
|
|
||||||
testCompileOnly(project(":compiler:cli"))
|
testCompileOnly(project(":compiler:cli"))
|
||||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||||
testRuntime(project(":kotlin-reflect"))
|
testRuntime(project(":kotlin-reflect"))
|
||||||
testCompile(commonDep("junit:junit"))
|
testCompile(commonDep("junit:junit"))
|
||||||
|
testRuntime(projectRuntimeJar(":kotlin-compiler"))
|
||||||
testRuntime("com.jcabi:jcabi-aether:0.10.1")
|
testRuntime("com.jcabi:jcabi-aether:0.10.1")
|
||||||
testRuntime("org.sonatype.aether:aether-api:1.13.1")
|
testRuntime("org.sonatype.aether:aether-api:1.13.1")
|
||||||
testRuntime("org.apache.maven:maven-core:3.0.3")
|
testRuntime("org.apache.maven:maven-core:3.0.3")
|
||||||
|
|||||||
-2
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.script.jsr223
|
package org.jetbrains.kotlin.script.jsr223
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||||
import org.jetbrains.kotlin.cli.common.repl.*
|
import org.jetbrains.kotlin.cli.common.repl.*
|
||||||
@@ -37,7 +36,6 @@ import kotlin.reflect.KClass
|
|||||||
// TODO: need to manage resources here, i.e. call replCompiler.dispose when engine is collected
|
// TODO: need to manage resources here, i.e. call replCompiler.dispose when engine is collected
|
||||||
|
|
||||||
class KotlinJsr223JvmDaemonCompileScriptEngine(
|
class KotlinJsr223JvmDaemonCompileScriptEngine(
|
||||||
disposable: Disposable,
|
|
||||||
factory: ScriptEngineFactory,
|
factory: ScriptEngineFactory,
|
||||||
compilerClasspath: List<File>,
|
compilerClasspath: List<File>,
|
||||||
templateClasspath: List<File>,
|
templateClasspath: List<File>,
|
||||||
|
|||||||
-3
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.script.jsr223
|
package org.jetbrains.kotlin.script.jsr223
|
||||||
|
|
||||||
import com.intellij.openapi.Disposable
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
|
||||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||||
import org.jetbrains.kotlin.cli.common.repl.*
|
import org.jetbrains.kotlin.cli.common.repl.*
|
||||||
@@ -35,7 +34,6 @@ import javax.script.ScriptEngineFactory
|
|||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
class KotlinJsr223JvmLocalScriptEngine(
|
class KotlinJsr223JvmLocalScriptEngine(
|
||||||
disposable: Disposable,
|
|
||||||
factory: ScriptEngineFactory,
|
factory: ScriptEngineFactory,
|
||||||
val templateClasspath: List<File>,
|
val templateClasspath: List<File>,
|
||||||
templateClassName: String,
|
templateClassName: String,
|
||||||
@@ -45,7 +43,6 @@ class KotlinJsr223JvmLocalScriptEngine(
|
|||||||
|
|
||||||
override val replCompiler: ReplCompiler by lazy {
|
override val replCompiler: ReplCompiler by lazy {
|
||||||
GenericReplCompiler(
|
GenericReplCompiler(
|
||||||
disposable,
|
|
||||||
makeScriptDefinition(templateClasspath, templateClassName),
|
makeScriptDefinition(templateClasspath, templateClassName),
|
||||||
makeCompilerConfiguration(),
|
makeCompilerConfiguration(),
|
||||||
PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, false))
|
PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, false))
|
||||||
|
|||||||
-3
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.script.jsr223
|
package org.jetbrains.kotlin.script.jsr223
|
||||||
|
|
||||||
import com.intellij.openapi.util.Disposer
|
|
||||||
import org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineFactoryBase
|
import org.jetbrains.kotlin.cli.common.repl.KotlinJsr223JvmScriptEngineFactoryBase
|
||||||
import org.jetbrains.kotlin.cli.common.repl.ScriptArgsWithTypes
|
import org.jetbrains.kotlin.cli.common.repl.ScriptArgsWithTypes
|
||||||
import org.jetbrains.kotlin.script.util.*
|
import org.jetbrains.kotlin.script.util.*
|
||||||
@@ -30,7 +29,6 @@ class KotlinJsr223JvmLocalScriptEngineFactory : KotlinJsr223JvmScriptEngineFacto
|
|||||||
|
|
||||||
override fun getScriptEngine(): ScriptEngine =
|
override fun getScriptEngine(): ScriptEngine =
|
||||||
KotlinJsr223JvmLocalScriptEngine(
|
KotlinJsr223JvmLocalScriptEngine(
|
||||||
Disposer.newDisposable(),
|
|
||||||
this,
|
this,
|
||||||
scriptCompilationClasspathFromContext("kotlin-script-util.jar"),
|
scriptCompilationClasspathFromContext("kotlin-script-util.jar"),
|
||||||
KotlinStandardJsr223ScriptTemplate::class.qualifiedName!!,
|
KotlinStandardJsr223ScriptTemplate::class.qualifiedName!!,
|
||||||
@@ -43,7 +41,6 @@ class KotlinJsr223JvmDaemonLocalEvalScriptEngineFactory : KotlinJsr223JvmScriptE
|
|||||||
|
|
||||||
override fun getScriptEngine(): ScriptEngine =
|
override fun getScriptEngine(): ScriptEngine =
|
||||||
KotlinJsr223JvmDaemonCompileScriptEngine(
|
KotlinJsr223JvmDaemonCompileScriptEngine(
|
||||||
Disposer.newDisposable(),
|
|
||||||
this,
|
this,
|
||||||
KotlinJars.compilerClasspath,
|
KotlinJars.compilerClasspath,
|
||||||
scriptCompilationClasspathFromContext("kotlin-script-util.jar"),
|
scriptCompilationClasspathFromContext("kotlin-script-util.jar"),
|
||||||
|
|||||||
Reference in New Issue
Block a user