Turn off inter-project IC when unknown task writes to java output dir
This commit is contained in:
+1
-2
@@ -196,8 +196,7 @@ open class A {
|
|||||||
// that is not JavaCompile or KotlinCompile
|
// that is not JavaCompile or KotlinCompile
|
||||||
@Test
|
@Test
|
||||||
fun testCompileLibWithGroovy() {
|
fun testCompileLibWithGroovy() {
|
||||||
val gradleVersion = GradleVersionRequired.Exact("3.5") // With newer versions, Groovy uses separate classes dirs
|
val project = Project("incrementalMultiproject")
|
||||||
val project = Project("incrementalMultiproject", gradleVersion)
|
|
||||||
project.setupWorkingDir()
|
project.setupWorkingDir()
|
||||||
val lib = File(project.projectDir, "lib")
|
val lib = File(project.projectDir, "lib")
|
||||||
val libBuildGradle = File(lib, "build.gradle")
|
val libBuildGradle = File(lib, "build.gradle")
|
||||||
|
|||||||
+26
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.tasks
|
package org.jetbrains.kotlin.gradle.tasks
|
||||||
|
|
||||||
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.logging.Logger
|
import org.gradle.api.logging.Logger
|
||||||
@@ -23,6 +24,7 @@ import org.gradle.api.plugins.BasePluginConvention
|
|||||||
import org.gradle.api.tasks.*
|
import org.gradle.api.tasks.*
|
||||||
import org.gradle.api.tasks.Optional
|
import org.gradle.api.tasks.Optional
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
import org.gradle.api.tasks.incremental.IncrementalTaskInputs
|
||||||
import org.jetbrains.kotlin.annotation.AnnotationFileUpdater
|
import org.jetbrains.kotlin.annotation.AnnotationFileUpdater
|
||||||
import org.jetbrains.kotlin.annotation.AnnotationFileUpdaterImpl
|
import org.jetbrains.kotlin.annotation.AnnotationFileUpdaterImpl
|
||||||
@@ -229,6 +231,9 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
|||||||
|
|
||||||
compilerCalled = true
|
compilerCalled = true
|
||||||
callCompiler(args, sourceRoots, ChangedFiles(inputs))
|
callCompiler(args, sourceRoots, ChangedFiles(inputs))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Internal
|
@Internal
|
||||||
@@ -381,6 +386,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
args,
|
args,
|
||||||
environment)
|
environment)
|
||||||
|
|
||||||
|
disableMultiModuleICIfNeeded()
|
||||||
processCompilerExitCode(exitCode)
|
processCompilerExitCode(exitCode)
|
||||||
}
|
}
|
||||||
catch (e: Throwable) {
|
catch (e: Throwable) {
|
||||||
@@ -390,6 +396,26 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
anyClassesCompiled = true
|
anyClassesCompiled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun disableMultiModuleICIfNeeded() {
|
||||||
|
if (!incremental || javaOutputDir == null) return
|
||||||
|
|
||||||
|
val illegalTask = project.tasks.firstOrNull {
|
||||||
|
it is AbstractCompile &&
|
||||||
|
it !is JavaCompile &&
|
||||||
|
it !is AbstractKotlinCompile<*> &&
|
||||||
|
FileUtil.isAncestor(javaOutputDir!!, it.destinationDir, /* strict = */ false)
|
||||||
|
} as? AbstractCompile
|
||||||
|
|
||||||
|
if (illegalTask != null) {
|
||||||
|
project.logger.info(
|
||||||
|
"Kotlin inter-project IC is disabled: " +
|
||||||
|
"unknown task '$illegalTask' destination dir ${illegalTask.destinationDir} " +
|
||||||
|
"intersects with java destination dir $javaOutputDir"
|
||||||
|
)
|
||||||
|
buildHistoryFile.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun cleanupOnError() {
|
private fun cleanupOnError() {
|
||||||
logger.kotlinInfo("deleting $destinationDir on error")
|
logger.kotlinInfo("deleting $destinationDir on error")
|
||||||
destinationDir.deleteRecursively()
|
destinationDir.deleteRecursively()
|
||||||
|
|||||||
Reference in New Issue
Block a user