Add 'NormalizeLineEndings' to cacheable tasks and transformations

^KT-50673 Fixed
This commit is contained in:
Yahor Berdnikau
2022-04-01 13:08:18 +02:00
committed by Space
parent 5733ed5c76
commit 785831c82a
12 changed files with 58 additions and 1 deletions
@@ -22,6 +22,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.Incremental
import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.WorkerExecutor
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptionsImpl
@@ -83,6 +84,7 @@ abstract class KaptGenerateStubsTask @Inject constructor(
@Input
fun getIfKaptClasspathIsPresent() = !kaptClasspath.isEmpty
@get:NormalizeLineEndings
@get:Classpath
@Suppress("unused")
internal abstract val kotlinTaskPluginClasspath: ConfigurableFileCollection
@@ -94,6 +96,7 @@ abstract class KaptGenerateStubsTask @Inject constructor(
* Changes in this additional sources will trigger stubs regeneration,
* but the sources themselves will not be used to find kapt annotations and generate stubs.
*/
@get:NormalizeLineEndings
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
@@ -110,6 +113,7 @@ abstract class KaptGenerateStubsTask @Inject constructor(
// Task need to run even if there is no Kotlin sources, but only Java
@get:Incremental
@get:InputFiles
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
override val sources: FileCollection = super.sources
@@ -12,6 +12,7 @@ import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.Incremental
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporterImpl
import org.jetbrains.kotlin.gradle.internal.kapt.incremental.ClasspathSnapshot
@@ -69,14 +70,17 @@ abstract class KaptTask @Inject constructor(
@get:Internal
internal abstract val stubsDir: DirectoryProperty
@get:NormalizeLineEndings
@get:Classpath
abstract val kaptClasspath: ConfigurableFileCollection
//part of kaptClasspath consisting from external artifacts only
//basically kaptClasspath = kaptExternalClasspath + artifacts built locally
@get:NormalizeLineEndings
@get:Classpath
abstract val kaptExternalClasspath: ConfigurableFileCollection
@get:NormalizeLineEndings
@get:Classpath
abstract val compilerClasspath: ConfigurableFileCollection
@@ -85,6 +89,7 @@ abstract class KaptTask @Inject constructor(
@get:PathSensitive(PathSensitivity.NONE)
@get:Incremental
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:Optional
@get:InputFiles
@@ -144,6 +149,7 @@ abstract class KaptTask @Inject constructor(
level = DeprecationLevel.ERROR
)
@get:Incremental
@get:NormalizeLineEndings
@get:Classpath
internal val internalNonAbiClasspath: FileCollection = project.objects.fileCollection().from(
{ if (includeCompileClasspath.get()) classpath else null }
@@ -158,6 +164,7 @@ abstract class KaptTask @Inject constructor(
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:Incremental
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val source: ConfigurableFileCollection
@@ -12,6 +12,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
import org.jetbrains.kotlin.compilerRunner.GradleCompilerRunner
@@ -49,6 +50,7 @@ abstract class KaptWithKotlincTask @Inject constructor(
@get:Internal
internal val pluginOptions = CompilerPluginOptions()
@get:NormalizeLineEndings
@get:Classpath
abstract val pluginClasspath: ConfigurableFileCollection
@@ -15,6 +15,7 @@ import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.listProperty
import org.gradle.process.CommandLineArgumentProvider
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.IsolationMode
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
@@ -51,6 +52,7 @@ abstract class KaptWithoutKotlincTask @Inject constructor(
}
}
@get:NormalizeLineEndings
@get:Classpath
abstract val kaptJars: ConfigurableFileCollection
@@ -9,6 +9,7 @@ import org.gradle.api.artifacts.transform.*
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Classpath
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.org.objectweb.asm.ClassReader
import org.jetbrains.org.objectweb.asm.ClassWriter
import java.io.*
@@ -20,6 +21,8 @@ private const val MODULE_INFO = "module-info.class"
@CacheableTransform
abstract class StructureTransformAction : TransformAction<TransformParameters.None> {
@get:NormalizeLineEndings
@get:InputArtifact
@get:Classpath
abstract val inputArtifact: Provider<FileSystemLocation>
@@ -41,6 +44,8 @@ abstract class StructureTransformAction : TransformAction<TransformParameters.No
*/
@CacheableTransform
abstract class StructureTransformLegacyAction : TransformAction<TransformParameters.None> {
@get:NormalizeLineEndings
@get:InputArtifact
@get:Classpath
abstract val inputArtifact: File
@@ -12,6 +12,7 @@ import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Internal
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.gradle.report.BuildMetricsReporterService
import org.jetbrains.kotlin.incremental.classpathDiff.ClassSnapshotGranularity
@@ -34,6 +35,7 @@ abstract class ClasspathEntrySnapshotTransform : TransformAction<ClasspathEntryS
abstract val buildMetricsReporterService: Property<BuildMetricsReporterService>
}
@get:NormalizeLineEndings
@get:Classpath
@get:InputArtifact
abstract val inputArtifact: Provider<FileSystemLocation>
@@ -11,6 +11,7 @@ import org.gradle.api.file.FileCollection
import org.gradle.api.file.ProjectLayout
import org.gradle.api.model.ObjectFactory
import org.gradle.api.tasks.*
import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.WorkerExecutor
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.parseCommandLineArguments
@@ -97,6 +98,7 @@ abstract class KotlinJsIrLink @Inject constructor(
@get:SkipWhenEmpty
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:InputDirectory
@get:PathSensitive(PathSensitivity.RELATIVE)
internal abstract val entryModule: DirectoryProperty
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.targets.native.internal
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.commonizer.CommonizerDependency
import org.jetbrains.kotlin.commonizer.TargetedCommonizerDependency
import org.jetbrains.kotlin.commonizer.allLeaves
@@ -30,7 +31,10 @@ internal open class CInteropCommonizerTask : AbstractCInteropCommonizerTask() {
@get:Input val identifier: CInteropIdentifier,
@get:Input val konanTarget: KonanTarget,
@get:Internal val sourceSets: Provider<Set<KotlinSourceSet>>,
@get:Classpath val libraryFile: Provider<File>
@get:NormalizeLineEndings
@get:Classpath
val libraryFile: Provider<File>
) {
@Suppress("unused") // Used for UP-TO-DATE check
@get:Input
@@ -49,6 +53,7 @@ internal open class CInteropCommonizerTask : AbstractCInteropCommonizerTask() {
get() = getAllInteropsGroups().map { outputDirectory(it) }.toSet()
@Suppress("unused") // Used for UP-TO-DATE check
@get:NormalizeLineEndings
@get:Classpath
val commonizedNativeDistributionDependencies: Set<File>
get() = getAllInteropsGroups().flatMap { group -> group.targets }
@@ -21,6 +21,7 @@ import org.gradle.api.file.FileTree
import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.CommonToolArguments
import org.jetbrains.kotlin.compilerRunner.*
@@ -158,6 +159,7 @@ abstract class AbstractKotlinNativeCompile<
compilation.konanTarget
}
@get:NormalizeLineEndings
@get:Classpath
override val libraries: ConfigurableFileCollection by project.provider {
// Avoid resolving these dependencies during task graph construction when we can't build the target:
@@ -168,6 +170,7 @@ abstract class AbstractKotlinNativeCompile<
else objectFactory.fileCollection()
}
@get:NormalizeLineEndings
@get:Classpath
protected val friendModule: FileCollection by project.provider {
project.files(compilation.friendPaths)
@@ -233,6 +236,7 @@ abstract class AbstractKotlinNativeCompile<
get() = compilerPluginOptions.arguments
@Optional
@NormalizeLineEndings
@Classpath
open var compilerPluginClasspath: FileCollection? = null
@@ -544,6 +548,7 @@ constructor(
val processTests: Boolean
@Input get() = binary is TestExecutable
@get:NormalizeLineEndings
@get:Classpath
val exportLibraries: FileCollection by project.provider {
binary.let {
@@ -1098,6 +1103,7 @@ open class CInteropProcess @Inject constructor(@get:Internal val settings: Defau
@OutputFile
val outputFileProvider: Provider<File> = project.provider { destinationDir.get().resolve(outputFileName) }
@get:NormalizeLineEndings
@get:InputFile
@get:PathSensitive(PathSensitivity.RELATIVE)
val defFile: File
@@ -1113,6 +1119,7 @@ open class CInteropProcess @Inject constructor(@get:Internal val settings: Defau
@Input get() = settings.linkerOpts
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
val headers: FileCollection
@@ -1125,6 +1132,7 @@ open class CInteropProcess @Inject constructor(@get:Internal val settings: Defau
@Input get() = settings.includeDirs.headerFilterDirs.files
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
val libraries: FileCollection
@@ -22,6 +22,7 @@ import org.gradle.api.model.ObjectFactory
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.WorkerExecutor
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments
import org.jetbrains.kotlin.compilerRunner.GradleCompilerEnvironment
@@ -128,6 +129,7 @@ abstract class KotlinCompileCommon @Inject constructor(
}
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:InputFiles
internal val refinesMetadataPaths: ConfigurableFileCollection = objectFactory.fileCollection()
@@ -23,6 +23,7 @@ import org.gradle.api.tasks.*
import org.gradle.work.ChangeType
import org.gradle.work.Incremental
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.jetbrains.kotlin.cli.common.arguments.DevModeOverwritingStrategies
import org.jetbrains.kotlin.cli.common.arguments.K2JSDceArguments
import org.jetbrains.kotlin.cli.js.dce.K2JSDce
@@ -78,11 +79,13 @@ abstract class KotlinJsDce @Inject constructor(
// Source could be empty, while classpath not
@get:Incremental
@get:InputFiles
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
override val sources: FileCollection = super.sources
@get:Incremental
@get:NormalizeLineEndings
@get:InputFiles
abstract override val libraries: ConfigurableFileCollection
@@ -30,6 +30,7 @@ import org.gradle.api.tasks.util.PatternSet
import org.gradle.work.ChangeType
import org.gradle.work.Incremental
import org.gradle.work.InputChanges
import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.WorkerExecutor
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
import org.jetbrains.kotlin.build.report.metrics.*
@@ -97,6 +98,7 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments> @Inject constr
@get:InputFiles
@get:SkipWhenEmpty
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
open val sources: FileCollection = objectFactory.fileCollection()
@@ -171,6 +173,7 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments> @Inject constr
}
@get:Classpath
@get:NormalizeLineEndings
@get:Incremental
abstract val libraries: ConfigurableFileCollection
@@ -186,6 +189,7 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments> @Inject constr
*
* Empty classpath will fail the build.
*/
@get:NormalizeLineEndings
@get:Classpath
internal val defaultCompilerClasspath: ConfigurableFileCollection =
project.objects.fileCollection()
@@ -347,6 +351,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
protected val multiModuleICSettings: MultiModuleICSettings
get() = MultiModuleICSettings(buildHistoryFile.get().asFile, useModuleDetection.get())
@get:NormalizeLineEndings
@get:Classpath
open val pluginClasspath: ConfigurableFileCollection = objectFactory.fileCollection()
@@ -374,6 +379,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:Incremental
@get:PathSensitive(PathSensitivity.RELATIVE)
internal val commonSourceSet: ConfigurableFileCollection = objectFactory.fileCollection()
@@ -739,11 +745,13 @@ abstract class KotlinCompile @Inject constructor(
abstract val useClasspathSnapshot: Property<Boolean>
@get:Classpath
@get:NormalizeLineEndings
@get:Incremental
@get:Optional // Set if useClasspathSnapshot == true
abstract val classpathSnapshot: ConfigurableFileCollection
@get:Classpath
@get:NormalizeLineEndings
@get:Incremental
@get:Optional // Set if useClasspathSnapshot == false (to restore the existing classpath annotations when the feature is disabled)
abstract val classpath: ConfigurableFileCollection
@@ -830,6 +838,7 @@ abstract class KotlinCompile @Inject constructor(
@get:InputFiles
@get:SkipWhenEmpty
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
internal open val scriptSources: FileCollection = scriptSourceFiles
@@ -994,6 +1003,7 @@ abstract class KotlinCompile @Inject constructor(
@get:Incremental
@get:InputFiles
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
open val javaSources: FileCollection = objectFactory.fileCollection()
@@ -1011,6 +1021,7 @@ abstract class KotlinCompile @Inject constructor(
*/
@get:Incremental
@get:InputFiles
@get:NormalizeLineEndings
@get:IgnoreEmptyDirectories
@get:PathSensitive(PathSensitivity.RELATIVE)
internal open val androidLayoutResources: FileCollection = androidLayoutResourceFiles
@@ -1184,6 +1195,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:Incremental
@get:Optional
@get:PathSensitive(PathSensitivity.RELATIVE)
@@ -1200,6 +1212,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
@Suppress("unused")
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:Optional
@get:PathSensitive(PathSensitivity.RELATIVE)
internal val sourceMapBaseDirs: FileCollection?
@@ -1330,6 +1343,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
}
data class KotlinCompilerPluginData(
@get:NormalizeLineEndings
@get:Classpath
val classpath: FileCollection,
@@ -1348,6 +1362,7 @@ data class KotlinCompilerPluginData(
@get:InputFiles
@get:IgnoreEmptyDirectories
@get:NormalizeLineEndings
@get:PathSensitive(PathSensitivity.RELATIVE)
val inputFiles: Set<File>,