[Gradle, JS] Await worker which builds cache
This commit is contained in:
+4
-1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.compilerRunner
|
|||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.workers.WorkAction
|
import org.gradle.workers.WorkAction
|
||||||
import org.gradle.workers.WorkParameters
|
import org.gradle.workers.WorkParameters
|
||||||
|
import org.gradle.workers.WorkQueue
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.tasks.GradleCompileTaskProvider
|
import org.jetbrains.kotlin.gradle.tasks.GradleCompileTaskProvider
|
||||||
@@ -21,13 +22,15 @@ internal class GradleCompilerRunnerWithWorkers(
|
|||||||
jdkToolsJar: File?,
|
jdkToolsJar: File?,
|
||||||
private val workerExecutor: WorkerExecutor
|
private val workerExecutor: WorkerExecutor
|
||||||
) : GradleCompilerRunner(taskProvider, jdkToolsJar) {
|
) : GradleCompilerRunner(taskProvider, jdkToolsJar) {
|
||||||
override fun runCompilerAsync(workArgs: GradleKotlinCompilerWorkArguments) {
|
|
||||||
|
override fun runCompilerAsync(workArgs: GradleKotlinCompilerWorkArguments): WorkQueue {
|
||||||
loggerProvider.kotlinDebug { "Starting Kotlin compiler work from task '${pathProvider}'" }
|
loggerProvider.kotlinDebug { "Starting Kotlin compiler work from task '${pathProvider}'" }
|
||||||
|
|
||||||
val workQueue = workerExecutor.noIsolation()
|
val workQueue = workerExecutor.noIsolation()
|
||||||
workQueue.submit(GradleKotlinCompilerWorkAction::class.java) {
|
workQueue.submit(GradleKotlinCompilerWorkAction::class.java) {
|
||||||
it.compilerWorkArguments.set(workArgs)
|
it.compilerWorkArguments.set(workArgs)
|
||||||
}
|
}
|
||||||
|
return workQueue
|
||||||
}
|
}
|
||||||
|
|
||||||
internal abstract class GradleKotlinCompilerWorkAction
|
internal abstract class GradleKotlinCompilerWorkAction
|
||||||
|
|||||||
+11
-9
@@ -11,6 +11,7 @@ import org.gradle.api.logging.Logger
|
|||||||
import org.gradle.api.plugins.JavaPluginConvention
|
import org.gradle.api.plugins.JavaPluginConvention
|
||||||
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
|
import org.gradle.workers.WorkQueue
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
||||||
@@ -82,14 +83,14 @@ internal open class GradleCompilerRunner(
|
|||||||
args: K2JVMCompilerArguments,
|
args: K2JVMCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment,
|
environment: GradleCompilerEnvironment,
|
||||||
jdkHome: File
|
jdkHome: File
|
||||||
) {
|
): WorkQueue? {
|
||||||
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
args.freeArgs += sourcesToCompile.map { it.absolutePath }
|
||||||
args.commonSources = commonSources.map { it.absolutePath }.toTypedArray()
|
args.commonSources = commonSources.map { it.absolutePath }.toTypedArray()
|
||||||
args.javaSourceRoots = javaSourceRoots.map { it.absolutePath }.toTypedArray()
|
args.javaSourceRoots = javaSourceRoots.map { it.absolutePath }.toTypedArray()
|
||||||
args.javaPackagePrefix = javaPackagePrefix
|
args.javaPackagePrefix = javaPackagePrefix
|
||||||
if (args.jdkHome == null) args.jdkHome = jdkHome.absolutePath
|
if (args.jdkHome == null) args.jdkHome = jdkHome.absolutePath
|
||||||
loggerProvider.kotlinInfo("Kotlin compilation 'jdkHome' argument: ${args.jdkHome}")
|
loggerProvider.kotlinInfo("Kotlin compilation 'jdkHome' argument: ${args.jdkHome}")
|
||||||
runCompilerAsync(KotlinCompilerClass.JVM, args, environment)
|
return runCompilerAsync(KotlinCompilerClass.JVM, args, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,10 +102,10 @@ internal open class GradleCompilerRunner(
|
|||||||
kotlinCommonSources: List<File>,
|
kotlinCommonSources: List<File>,
|
||||||
args: K2JSCompilerArguments,
|
args: K2JSCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
) {
|
): WorkQueue? {
|
||||||
args.freeArgs += kotlinSources.map { it.absolutePath }
|
args.freeArgs += kotlinSources.map { it.absolutePath }
|
||||||
args.commonSources = kotlinCommonSources.map { it.absolutePath }.toTypedArray()
|
args.commonSources = kotlinCommonSources.map { it.absolutePath }.toTypedArray()
|
||||||
runCompilerAsync(KotlinCompilerClass.JS, args, environment)
|
return runCompilerAsync(KotlinCompilerClass.JS, args, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,16 +116,16 @@ internal open class GradleCompilerRunner(
|
|||||||
kotlinSources: List<File>,
|
kotlinSources: List<File>,
|
||||||
args: K2MetadataCompilerArguments,
|
args: K2MetadataCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
) {
|
): WorkQueue? {
|
||||||
args.freeArgs += kotlinSources.map { it.absolutePath }
|
args.freeArgs += kotlinSources.map { it.absolutePath }
|
||||||
runCompilerAsync(KotlinCompilerClass.METADATA, args, environment)
|
return runCompilerAsync(KotlinCompilerClass.METADATA, args, environment)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runCompilerAsync(
|
private fun runCompilerAsync(
|
||||||
compilerClassName: String,
|
compilerClassName: String,
|
||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
) {
|
): WorkQueue? {
|
||||||
if (compilerArgs.version) {
|
if (compilerArgs.version) {
|
||||||
loggerProvider.lifecycle(
|
loggerProvider.lifecycle(
|
||||||
"Kotlin version " + loadCompilerVersion(environment.compilerClasspath) +
|
"Kotlin version " + loadCompilerVersion(environment.compilerClasspath) +
|
||||||
@@ -187,12 +188,13 @@ internal open class GradleCompilerRunner(
|
|||||||
allWarningsAsErrors = compilerArgs.allWarningsAsErrors
|
allWarningsAsErrors = compilerArgs.allWarningsAsErrors
|
||||||
)
|
)
|
||||||
TaskLoggers.put(pathProvider, loggerProvider)
|
TaskLoggers.put(pathProvider, loggerProvider)
|
||||||
runCompilerAsync(workArgs)
|
return runCompilerAsync(workArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun runCompilerAsync(workArgs: GradleKotlinCompilerWorkArguments) {
|
protected open fun runCompilerAsync(workArgs: GradleKotlinCompilerWorkArguments): WorkQueue? {
|
||||||
val kotlinCompilerRunnable = GradleKotlinCompilerWork(workArgs)
|
val kotlinCompilerRunnable = GradleKotlinCompilerWork(workArgs)
|
||||||
kotlinCompilerRunnable.run()
|
kotlinCompilerRunnable.run()
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-1
@@ -318,7 +318,7 @@ internal class CacheBuilder(
|
|||||||
emptyList(),
|
emptyList(),
|
||||||
compilerArgs,
|
compilerArgs,
|
||||||
environment
|
environment
|
||||||
)
|
)?.await()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
Reference in New Issue
Block a user