Move daemon jar from compiler

This commit is contained in:
Vadim Brilyantov
2019-04-03 19:34:06 +03:00
parent ced973b707
commit 01a05a5495
67 changed files with 441 additions and 759 deletions
@@ -18,6 +18,7 @@ dependencies {
testCompile(project(":kotlin-script-runtime"))
testCompile(project(":kotlin-script-util"))
testCompile(projectRuntimeJar(":kotlin-daemon-client"))
testCompile(projectRuntimeJar(":kotlin-daemon"))
testCompile(projectRuntimeJar(":kotlin-compiler-embeddable"))
testCompile(commonDep("junit:junit"))
testCompile(project(":kotlin-test:kotlin-test-junit"))
@@ -30,7 +31,7 @@ dependencies {
compilerClasspath(commonDep("org.jetbrains.intellij.deps", "trove4j"))
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)
testCompileOnly(project(":daemon-common")) // TODO: fix import (workaround for jps build)
}
projectTest {
@@ -22,7 +22,7 @@ dependencies {
testRuntime(project(":kotlin-reflect"))
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)
testCompileOnly(project(":daemon-common")) // TODO: fix import (workaround for jps build)
testRuntime(project(":kotlin-scripting-compiler-embeddable"))
}
@@ -20,7 +20,7 @@ dependencies {
runtime(project(":kotlin-reflect"))
testCompile(projectTests(":compiler:tests-common"))
testCompile(commonDep("junit"))
testCompile(project(":compiler:daemon-common")) // TODO: fix import (workaround for jps build)
testCompile(project(":daemon-common")) // TODO: fix import (workaround for jps build)
}
sourceSets {
@@ -34,7 +34,7 @@ dependencies {
compile(project(":kotlin-gradle-plugin-model"))
compileOnly(project(":compiler"))
compileOnly(project(":compiler:incremental-compilation-impl"))
compileOnly(project(":compiler:daemon-common"))
compileOnly(project(":daemon-common"))
compile(kotlinStdlib())
compileOnly(project(":kotlin-reflect-api"))
@@ -36,6 +36,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.gradle.utils.newTmpFile
import org.jetbrains.kotlin.gradle.utils.relativeToRoot
import org.jetbrains.kotlin.incremental.IncrementalModuleInfo
import org.jetbrains.kotlin.incremental.IncrementalModuleEntry
import org.jetbrains.kotlin.incremental.classpathAsList
import org.jetbrains.kotlin.incremental.destinationAsFile
import org.jetbrains.kotlin.incremental.makeModuleFile
@@ -183,7 +185,12 @@ internal open class GradleCompilerRunner(protected val task: Task) {
for (project in gradle.rootProject.allprojects) {
project.tasks.withType(AbstractKotlinCompile::class.java).toList().forEach { task ->
val module = IncrementalModuleEntry(project.path, task.moduleName, project.buildDir, task.buildHistoryFile)
val module = IncrementalModuleEntry(
project.path,
task.moduleName,
project.buildDir,
task.buildHistoryFile
)
dirToModule[task.destinationDir] = module
task.javaOutputDir?.let { dirToModule[it] = module }
nameToModules.getOrPut(module.name) { HashSet() }.add(module)
@@ -201,7 +208,12 @@ internal open class GradleCompilerRunner(protected val task: Task) {
for (target in kotlinExt.targets) {
val mainCompilation = target.compilations.findByName(KotlinCompilation.MAIN_COMPILATION_NAME) ?: continue
val kotlinTask = mainCompilation.compileKotlinTask as? AbstractKotlinCompile<*> ?: continue
val module = IncrementalModuleEntry(project.path, kotlinTask.moduleName, project.buildDir, kotlinTask.buildHistoryFile)
val module = IncrementalModuleEntry(
project.path,
kotlinTask.moduleName,
project.buildDir,
kotlinTask.buildHistoryFile
)
val jarTask = project.tasks.findByName(target.artifactsTaskName) as? AbstractArchiveTask ?: continue
jarToModule[jarTask.archivePath] = module
}
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.gradle.tasks.clearLocalState
import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError
import org.jetbrains.kotlin.gradle.utils.stackTraceAsString
import org.jetbrains.kotlin.incremental.ChangedFiles
import org.jetbrains.kotlin.incremental.IncrementalModuleInfo
import org.slf4j.LoggerFactory
import java.io.*
import java.net.URLClassLoader
@@ -148,7 +149,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
}
private fun compileWithDaemon(messageCollector: MessageCollector): ExitCode? {
val isDebugEnabled = log.isDebugEnabled || System.getProperty("kotlin.daemon.debug.log")?.toBoolean() ?: false
val isDebugEnabled = log.isDebugEnabled || System.getProperty("kotlin.daemon.debug.log")?.toBoolean() ?: true
val enableAssertions = System.getProperty("kotlin.daemon.ea")?.toBoolean() ?: false
val daemonMessageCollector =
if (isDebugEnabled) messageCollector else MessageCollector.NONE
@@ -39,6 +39,7 @@ private val KOTLIN_SCRIPT_ANNOTATION_EXPECTED_CLASS = "kotlin.script.experimenta
private val KOTLIN_JVM_SCRIPT_COMPILER_EXPECTED_CLASS = "kotlin.script.experimental.jvm.JvmScriptCompiler"
private val KOTLIN_REFLECT_EXPECTED_CLASS = "kotlin.reflect.full.KClasses"
private val TROVE4J_EXPECTED_CLASS = "gnu.trove.THashMap"
private val DAEMON_EXPECTED_CLASS = "org.jetbrains.kotlin.daemon.CompileServiceImpl"
internal const val KOTLIN_MODULE_GROUP = "org.jetbrains.kotlin"
private val KOTLIN_GRADLE_PLUGIN = "kotlin-gradle-plugin"
internal const val KOTLIN_COMPILER_EMBEDDABLE = "kotlin-compiler-embeddable"
@@ -76,20 +77,23 @@ internal fun findKotlinCompilerClasspath(project: Project): List<File> {
return findKotlinStdlibClasspath(project) +
findKotlinScriptRuntimeClasspath(project) +
findKotlinReflectClasspath(project) +
listOfNotNull(findTrove4j())
listOfNotNull(findTrove4j(), findDaemon())
}
internal fun findTrove4j(): File? {
internal fun findJarByClass(classFqName: String): File? {
val classLoader = Thread.currentThread().contextClassLoader
val classFromTrove4j = try {
classLoader.loadClass(TROVE4J_EXPECTED_CLASS)
val classFromJar = try {
classLoader.loadClass(classFqName)
} catch (e: ClassNotFoundException) {
null
} ?: return null
return findJarByClass(classFromTrove4j)
return findJarByClass(classFromJar)
}
internal fun findTrove4j() = findJarByClass(TROVE4J_EXPECTED_CLASS)
internal fun findDaemon() = findJarByClass(DAEMON_EXPECTED_CLASS)
internal fun findKotlinStdlibClasspath(project: Project): List<File> =
findKotlinModuleJar(project, KOTLIN_STDLIB_EXPECTED_CLASS, KOTLIN_STDLIB)
@@ -16,7 +16,7 @@ dependencies {
compile(project(":kotlin-scripting-jvm"))
compile(commonDep("org.jetbrains.intellij.deps", "trove4j"))
compileOnly(project(":compiler:cli"))
compileOnly(project(":compiler:daemon-common"))
compileOnly(project(":daemon-common"))
compileOnly(project(":kotlin-scripting-compiler"))
compile(projectRuntimeJar(":kotlin-daemon-client"))
compileOnly("com.jcabi:jcabi-aether:1.0-SNAPSHOT")