Wrap null values into serializable optional
Otherwise worker executor fails with NPE
This commit is contained in:
+8
-2
@@ -6,9 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.compilerRunner
|
package org.jetbrains.kotlin.compilerRunner
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.workers.ForkMode
|
||||||
import org.gradle.workers.IsolationMode
|
import org.gradle.workers.IsolationMode
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.SerializableOptional
|
||||||
|
|
||||||
internal class GradleCompilerRunnerWithWorkers(
|
internal class GradleCompilerRunnerWithWorkers(
|
||||||
project: Project,
|
project: Project,
|
||||||
@@ -19,16 +21,20 @@ internal class GradleCompilerRunnerWithWorkers(
|
|||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
environment: GradleCompilerEnvironment
|
environment: GradleCompilerEnvironment
|
||||||
) {
|
) {
|
||||||
|
val icEnv = environment.incrementalCompilationEnvironment
|
||||||
|
val modulesInfo = icEnv?.let { buildModulesInfo(project.gradle) }
|
||||||
|
|
||||||
workersExecutor.submit(KotlinCompilerRunnable::class.java) { config ->
|
workersExecutor.submit(KotlinCompilerRunnable::class.java) { config ->
|
||||||
config.isolationMode = IsolationMode.NONE
|
config.isolationMode = IsolationMode.NONE
|
||||||
|
config.forkMode = ForkMode.NEVER
|
||||||
config.params(
|
config.params(
|
||||||
ProjectFilesForCompilation(project),
|
ProjectFilesForCompilation(project),
|
||||||
environment.compilerFullClasspath,
|
environment.compilerFullClasspath,
|
||||||
compilerClassName,
|
compilerClassName,
|
||||||
ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray(),
|
ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray(),
|
||||||
compilerArgs.verbose,
|
compilerArgs.verbose,
|
||||||
environment.incrementalCompilationEnvironment,
|
SerializableOptional(icEnv),
|
||||||
buildModulesInfo(project.gradle)
|
SerializableOptional(modulesInfo)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.daemon.client.CompileServiceSession
|
|||||||
import org.jetbrains.kotlin.daemon.common.*
|
import org.jetbrains.kotlin.daemon.common.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.SerializableOptional
|
||||||
import org.jetbrains.kotlin.gradle.utils.newTmpFile
|
import org.jetbrains.kotlin.gradle.utils.newTmpFile
|
||||||
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
|
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
|
||||||
import org.jetbrains.kotlin.incremental.*
|
import org.jetbrains.kotlin.incremental.*
|
||||||
@@ -130,8 +131,8 @@ internal open class GradleCompilerRunner(protected val project: Project) {
|
|||||||
compilerClassName = compilerClassName,
|
compilerClassName = compilerClassName,
|
||||||
compilerArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray(),
|
compilerArgs = ArgumentUtils.convertArgumentsToStringList(compilerArgs).toTypedArray(),
|
||||||
isVerbose = compilerArgs.verbose,
|
isVerbose = compilerArgs.verbose,
|
||||||
incrementalCompilationEnvironment = environment.incrementalCompilationEnvironment,
|
incrementalCompilationEnvironment = SerializableOptional(environment.incrementalCompilationEnvironment),
|
||||||
incrementalModuleInfo = buildModulesInfo(project.gradle)
|
incrementalModuleInfo = SerializableOptional(buildModulesInfo(project.gradle))
|
||||||
)
|
)
|
||||||
kotlinCompilerRunnable.run()
|
kotlinCompilerRunnable.run()
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.daemon.common.*
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||||
import org.jetbrains.kotlin.gradle.tasks.GradleMessageCollector
|
import org.jetbrains.kotlin.gradle.tasks.GradleMessageCollector
|
||||||
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
|
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
|
||||||
|
import org.jetbrains.kotlin.gradle.utils.SerializableOptional
|
||||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
@@ -48,15 +49,15 @@ internal class KotlinCompilerRunnable @Inject constructor(
|
|||||||
private val compilerClassName: String,
|
private val compilerClassName: String,
|
||||||
private val compilerArgs: Array<String>,
|
private val compilerArgs: Array<String>,
|
||||||
private val isVerbose: Boolean,
|
private val isVerbose: Boolean,
|
||||||
private val incrementalCompilationEnvironment: IncrementalCompilationEnvironment?,
|
private val incrementalCompilationEnvironment: SerializableOptional<IncrementalCompilationEnvironment>,
|
||||||
private val incrementalModuleInfo: IncrementalModuleInfo?
|
private val incrementalModuleInfo: SerializableOptional<IncrementalModuleInfo>
|
||||||
) : Runnable {
|
) : Runnable {
|
||||||
private val log: KotlinLogger =
|
private val log: KotlinLogger =
|
||||||
SL4JKotlinLogger(LoggerFactory.getLogger("KotlinCompilerRunnable"))
|
SL4JKotlinLogger(LoggerFactory.getLogger("KotlinCompilerRunnable"))
|
||||||
private val messageCollector = GradleMessageCollector(log)
|
private val messageCollector = GradleMessageCollector(log)
|
||||||
|
|
||||||
private val isIncremental: Boolean
|
private val isIncremental: Boolean
|
||||||
get() = incrementalCompilationEnvironment != null
|
get() = incrementalCompilationEnvironment.value != null
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val exitCode = compileWithDaemonOrFallbackImpl()
|
val exitCode = compileWithDaemonOrFallbackImpl()
|
||||||
@@ -165,7 +166,7 @@ internal class KotlinCompilerRunnable @Inject constructor(
|
|||||||
sessionId: Int,
|
sessionId: Int,
|
||||||
targetPlatform: CompileService.TargetPlatform
|
targetPlatform: CompileService.TargetPlatform
|
||||||
): CompileService.CallResult<Int> {
|
): CompileService.CallResult<Int> {
|
||||||
val icEnv = incrementalCompilationEnvironment ?: error("incrementalCompilationEnvironment is null!")
|
val icEnv = incrementalCompilationEnvironment.value ?: error("incrementalCompilationEnvironment is null!")
|
||||||
val knownChangedFiles = icEnv.changedFiles as? ChangedFiles.Known
|
val knownChangedFiles = icEnv.changedFiles as? ChangedFiles.Known
|
||||||
|
|
||||||
val compilationOptions = IncrementalCompilationOptions(
|
val compilationOptions = IncrementalCompilationOptions(
|
||||||
@@ -181,7 +182,7 @@ internal class KotlinCompilerRunnable @Inject constructor(
|
|||||||
usePreciseJavaTracking = icEnv.usePreciseJavaTracking,
|
usePreciseJavaTracking = icEnv.usePreciseJavaTracking,
|
||||||
localStateDirs = icEnv.localStateDirs,
|
localStateDirs = icEnv.localStateDirs,
|
||||||
multiModuleICSettings = icEnv.multiModuleICSettings,
|
multiModuleICSettings = icEnv.multiModuleICSettings,
|
||||||
modulesInfo = incrementalModuleInfo!!
|
modulesInfo = incrementalModuleInfo.value!!
|
||||||
)
|
)
|
||||||
|
|
||||||
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.utils
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
|
internal class SerializableOptional<T>(val value: T?) : Serializable {
|
||||||
|
companion object {
|
||||||
|
const val serialVersionUID: Long = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user