Disable IC when IC cache is missing

Check task build directory for any files
This commit is contained in:
Sergey Igushkin
2017-11-20 17:38:50 +03:00
parent 14c80baec8
commit 4a69d1545b
2 changed files with 17 additions and 5 deletions
@@ -454,6 +454,9 @@ abstract class BaseGradleIT {
System.getProperty("maven.repo.local")?.let {
add("-Dmaven.repo.local=$it") // TODO: proper escaping
}
if (options.withBuildCache) {
add("--build-cache")
}
addAll(options.freeCommandLineArgs)
}
@@ -95,8 +95,6 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
logger.kotlinDebug { "Set $this.incremental=$value" }
}
abstract protected fun createCompilerArgs(): T
@get:Internal
internal val pluginOptions = CompilerPluginOptions()
@@ -238,6 +236,11 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
compilerArgs.pluginClasspaths = pluginClasspath.toTypedArray()
compilerArgs.pluginOptions = pluginOptions.arguments.toTypedArray()
}
protected fun hasFilesInTaskBuildDirectory(): Boolean {
val taskBuildDir = taskBuildDirectory
return taskBuildDir.walk().any { it != taskBuildDir && it.isFile }
}
}
@CacheableTask
@@ -341,11 +344,15 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
val reporter = GradleICReporter(project.rootProject.projectDir)
val environment = when {
!incremental -> GradleCompilerEnvironment(computedCompilerClasspath, messageCollector, outputItemCollector, args)
!incremental ->
GradleCompilerEnvironment(computedCompilerClasspath, messageCollector, outputItemCollector, args)
else -> {
logger.info(USING_INCREMENTAL_COMPILATION_MESSAGE)
val friendTask = friendTaskName?.let { project.tasks.findByName(it) as? KotlinCompile }
GradleIncrementalCompilerEnvironment(computedCompilerClasspath, changedFiles, reporter, taskBuildDirectory,
GradleIncrementalCompilerEnvironment(
computedCompilerClasspath,
if (hasFilesInTaskBuildDirectory()) changedFiles else ChangedFiles.Unknown(),
reporter, taskBuildDirectory,
messageCollector, outputItemCollector, args, kaptAnnotationsFileUpdater,
artifactDifferenceRegistryProvider,
artifactFile = artifactFile,
@@ -508,7 +515,9 @@ open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArguments>(),
incremental -> {
logger.warn(USING_EXPERIMENTAL_JS_INCREMENTAL_COMPILATION_MESSAGE)
GradleIncrementalCompilerEnvironment(
computedCompilerClasspath, changedFiles, reporter, taskBuildDirectory,
computedCompilerClasspath,
if (hasFilesInTaskBuildDirectory()) changedFiles else ChangedFiles.Unknown(),
reporter, taskBuildDirectory,
messageCollector, outputItemCollector, args)
}
else -> {