mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Get rid of kotlinx-coroutines usage in scripting libs and plugins
the dependency on the coroutines library caused various problems like KT-30778, or stdlib/runtime version conflicts. The only function used was `runBlocking`, so this change replaces it with the internal implementation based on the similar internal thing from the stdlib. #KT-30778 fixed
This commit is contained in:
committed by
TeamCityServer
parent
9b1de90452
commit
0cd29adcc7
@@ -10,7 +10,6 @@ dependencies {
|
||||
runtimeOnly(project(":kotlin-scripting-common"))
|
||||
runtimeOnly(project(":kotlin-scripting-jvm"))
|
||||
runtimeOnly(kotlinStdlib())
|
||||
runtimeOnly(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core"))
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
@@ -17,7 +17,6 @@ dependencies {
|
||||
compile(project(":kotlin-scripting-jvm"))
|
||||
compile(kotlinStdlib())
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(intellijDep()) { includeJars("asm-all", rootProject = rootProject) }
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.scripting.resolve
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.script.dependencies.Environment
|
||||
import kotlin.script.dependencies.ScriptContents
|
||||
import kotlin.script.experimental.dependencies.AsyncDependenciesResolver
|
||||
import kotlin.script.experimental.dependencies.DependenciesResolver
|
||||
import kotlin.script.experimental.impl.internalScriptingRunSuspend
|
||||
|
||||
// wraps AsyncDependenciesResolver to provide implementation for synchronous DependenciesResolver::resolve
|
||||
class AsyncDependencyResolverWrapper(
|
||||
@@ -18,8 +18,9 @@ class AsyncDependencyResolverWrapper(
|
||||
|
||||
override fun resolve(
|
||||
scriptContents: ScriptContents, environment: Environment
|
||||
): DependenciesResolver.ResolveResult
|
||||
= runBlocking { delegate.resolveAsync(scriptContents, environment) }
|
||||
): DependenciesResolver.ResolveResult =
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
internalScriptingRunSuspend { delegate.resolveAsync(scriptContents, environment) }
|
||||
|
||||
|
||||
suspend override fun resolveAsync(
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -34,6 +33,7 @@ import kotlin.script.experimental.dependencies.AsyncDependenciesResolver
|
||||
import kotlin.script.experimental.dependencies.DependenciesResolver
|
||||
import kotlin.script.experimental.dependencies.ScriptDependencies
|
||||
import kotlin.script.experimental.host.*
|
||||
import kotlin.script.experimental.impl.internalScriptingRunSuspend
|
||||
import kotlin.script.experimental.jvm.*
|
||||
import kotlin.script.experimental.jvm.compat.mapToDiagnostics
|
||||
import kotlin.script.experimental.jvm.impl.toClassPathOrEmpty
|
||||
@@ -255,7 +255,8 @@ fun refineScriptCompilationConfiguration(
|
||||
// runBlocking is using there to avoid loading dependencies asynchronously
|
||||
// because it leads to starting more than one gradle daemon in case of resolving dependencies in build.gradle.kts
|
||||
// It is more efficient to use one hot daemon consistently than multiple daemon in parallel
|
||||
runBlocking {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
internalScriptingRunSuspend {
|
||||
resolver.resolveAsync(scriptContents, environment)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -35,6 +35,7 @@ dependencies {
|
||||
testCompile(commonDep("junit:junit"))
|
||||
|
||||
testImplementation(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
testImplementation(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core"))
|
||||
testRuntimeOnly(intellijDep()) { includeJars("jps-model", "jna") }
|
||||
|
||||
testImplementation(project(":kotlin-reflect"))
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.scripting.compiler.plugin
|
||||
|
||||
import com.intellij.core.JavaCoreProjectEnvironment
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
@@ -20,11 +19,11 @@ import org.jetbrains.kotlin.scripting.configuration.ScriptingConfigurationKeys
|
||||
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider
|
||||
import java.io.File
|
||||
import java.io.Serializable
|
||||
import java.util.*
|
||||
import kotlin.script.experimental.api.*
|
||||
import kotlin.script.experimental.host.FileScriptSource
|
||||
import kotlin.script.experimental.host.StringScriptSource
|
||||
import kotlin.script.experimental.host.toScriptSource
|
||||
import kotlin.script.experimental.impl.internalScriptingRunSuspend
|
||||
import kotlin.script.experimental.jvm.util.renderError
|
||||
|
||||
abstract class AbstractScriptEvaluationExtension : ScriptEvaluationExtension {
|
||||
@@ -132,19 +131,20 @@ abstract class AbstractScriptEvaluationExtension : ScriptEvaluationExtension {
|
||||
): ExitCode {
|
||||
val scriptCompiler = createScriptCompiler(environment)
|
||||
|
||||
return runBlocking {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
return internalScriptingRunSuspend {
|
||||
val compiledScript = scriptCompiler.compile(script, scriptCompilationConfiguration).valueOr {
|
||||
for (report in it.reports) {
|
||||
messageCollector.report(report.severity.toCompilerMessageSeverity(), report.render(withSeverity = false))
|
||||
}
|
||||
return@runBlocking ExitCode.COMPILATION_ERROR
|
||||
return@internalScriptingRunSuspend ExitCode.COMPILATION_ERROR
|
||||
}
|
||||
|
||||
val evalResult = createScriptEvaluator().invoke(compiledScript, evaluationConfiguration).valueOr {
|
||||
for (report in it.reports) {
|
||||
messageCollector.report(report.severity.toCompilerMessageSeverity(), report.render(withSeverity = false))
|
||||
}
|
||||
return@runBlocking ExitCode.INTERNAL_ERROR
|
||||
return@internalScriptingRunSuspend ExitCode.INTERNAL_ERROR
|
||||
}
|
||||
|
||||
when (evalResult.returnValue) {
|
||||
|
||||
Reference in New Issue
Block a user