[Gradle] Convert taskOutputsBackupExcludes into SetProperty
#KT-49785 In Progress
This commit is contained in:
committed by
Space Team
parent
0260d1d63f
commit
432b08e158
+2
-12
@@ -386,14 +386,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
||||
|
||||
/** Task outputs that we don't want to include in [TaskOutputsBackup] (see [TaskOutputsBackup.outputsToRestore] for more info). */
|
||||
@get:Internal
|
||||
protected open val taskOutputsBackupExcludes: List<File>
|
||||
get() {
|
||||
val list = mutableListOf<File>()
|
||||
if (preciseCompilationResultsBackup.get()) {
|
||||
list.add(destinationDirectory.get().asFile)
|
||||
}
|
||||
return list
|
||||
}
|
||||
internal abstract val taskOutputsBackupExcludes: SetProperty<File>
|
||||
|
||||
@TaskAction
|
||||
fun execute(inputChanges: InputChanges) {
|
||||
@@ -420,7 +413,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
||||
fileSystemOperations,
|
||||
layout.buildDirectory,
|
||||
layout.buildDirectory.dir("snapshot/kotlin/$name"),
|
||||
outputsToRestore = allOutputFiles() - taskOutputsBackupExcludes,
|
||||
outputsToRestore = allOutputFiles() - taskOutputsBackupExcludes.get(),
|
||||
logger
|
||||
).also {
|
||||
it.createSnapshot()
|
||||
@@ -639,9 +632,6 @@ abstract class KotlinCompile @Inject constructor(
|
||||
classpathSnapshotProperties.classpathSnapshot
|
||||
)
|
||||
|
||||
override val taskOutputsBackupExcludes: List<File>
|
||||
get() = (classpathSnapshotProperties.classpathSnapshotDir.orNull?.asFile?.let { listOf(it) } ?: emptyList()) + super.taskOutputsBackupExcludes
|
||||
|
||||
@get:Internal
|
||||
final override val defaultKotlinJavaToolchain: Provider<DefaultKotlinJavaToolchain> = objectFactory
|
||||
.propertyWithNewInstance({ this })
|
||||
|
||||
+3
@@ -80,6 +80,9 @@ internal abstract class AbstractKotlinCompileConfig<TASK : AbstractKotlinCompile
|
||||
task.preciseCompilationResultsBackup
|
||||
.convention(propertiesProvider.preciseCompilationResultsBackup)
|
||||
.finalizeValueOnRead()
|
||||
task.taskOutputsBackupExcludes.addAll(task.preciseCompilationResultsBackup.map {
|
||||
if (it) listOf(task.destinationDirectory.get().asFile, task.taskBuildLocalStateDirectory.get().asFile) else emptyList()
|
||||
})
|
||||
|
||||
task.incremental = false
|
||||
task.useModuleDetection.convention(false)
|
||||
|
||||
+7
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.gradle.plugin.sources.DefaultLanguageSettingsBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.tcsOrNull
|
||||
import org.jetbrains.kotlin.gradle.report.BuildMetricsService
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.utils.providerWithLazyConvention
|
||||
import org.jetbrains.kotlin.project.model.LanguageSettings
|
||||
|
||||
internal typealias KotlinCompileConfig = BaseKotlinCompileConfig<KotlinCompile>
|
||||
@@ -57,6 +58,12 @@ internal open class BaseKotlinCompileConfig<TASK : KotlinCompile> : AbstractKotl
|
||||
} else {
|
||||
task.classpathSnapshotProperties.classpath.from(task.project.provider { task.libraries }).disallowChanges()
|
||||
}
|
||||
task.taskOutputsBackupExcludes.addAll(
|
||||
task.classpathSnapshotProperties.classpathSnapshotDir.asFile.flatMap {
|
||||
// it looks weird, but it's required to work around this issue: https://github.com/gradle/gradle/issues/17704
|
||||
objectFactory.providerWithLazyConvention { listOf(it) }
|
||||
}.orElse(emptyList())
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user