Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure all input files are using path sensitivity of relative to avoid cache misses in CI builds. #1107

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/kotlin/com/autonomousapps/tasks/AndroidScoreTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -27,11 +28,11 @@ abstract class AndroidScoreTask @Inject constructor(
description = "Infers if Android project could instead be a JVM project"
}

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val syntheticProject: RegularFileProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputDirectory
abstract val dependencies: DirectoryProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE

/**
* Produces a report of all the artifacts required to build the given project; i.e., the artifacts on the compile
Expand Down Expand Up @@ -46,12 +47,12 @@ abstract class ArtifactsReportTask : DefaultTask() {

/**
* This is the "official" input for wiring task dependencies correctly, but is otherwise
* unused. This needs to use [InputFiles] and [PathSensitivity.ABSOLUTE] because the path to the
* unused. This needs to use [InputFiles] because the path to the
* jars really does matter here. Using [Classpath] is an error, as it looks only at content and
* not name or path, and we really do need to know the actual path to the artifact, even if its
* contents haven't changed.
*/
@PathSensitive(PathSensitivity.ABSOLUTE)
@PathSensitive(RELATIVE)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a ClasspathNormalizer if @autonomousapps confirms that the requirement for absolute path is in the processing

@InputFiles
fun getClasspathArtifactFiles(): FileCollection = artifacts.artifactFiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -28,7 +29,7 @@ abstract class AssetSourceExploderTask @Inject constructor(
description = "Produces a report of all assets in this project"
}

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val androidLocalAssets: ConfigurableFileCollection

Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/com/autonomousapps/tasks/BuildHealthTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.api.tasks.TaskAction

abstract class BuildHealthTask : DefaultTask() {
Expand All @@ -20,11 +21,11 @@ abstract class BuildHealthTask : DefaultTask() {
description = "Generates holistic advice for whole project, and can fail the build if desired"
}

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val shouldFail: RegularFileProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val consoleReport: RegularFileProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -33,22 +34,22 @@ abstract class CodeSourceExploderTask @Inject constructor(
}

/** The Groovy source of the current project. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val groovySourceFiles: ConfigurableFileCollection

/** The Java source of the current project. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val javaSourceFiles: ConfigurableFileCollection

/** The Kotlin source of the current project. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val kotlinSourceFiles: ConfigurableFileCollection

/** The Scala source of the current project. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val scalaSourceFiles: ConfigurableFileCollection

Expand Down
11 changes: 6 additions & 5 deletions src/main/kotlin/com/autonomousapps/tasks/ComputeAdviceTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.SetProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -49,19 +50,19 @@ abstract class ComputeAdviceTask @Inject constructor(
@get:Input
abstract val buildPath: Property<String>

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val dependencyUsageReports: ListProperty<RegularFile>

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val dependencyGraphViews: ListProperty<RegularFile>

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val androidScoreReports: ListProperty<RegularFile>

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val declarations: RegularFileProperty

Expand All @@ -81,7 +82,7 @@ abstract class ComputeAdviceTask @Inject constructor(
abstract val kapt: Property<Boolean>

@get:Optional
@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val redundantJvmPluginReport: RegularFileProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import java.io.File

@CacheableTask
Expand All @@ -31,11 +32,11 @@ abstract class ComputeDominatorTreeTask : DefaultTask() {
@get:Input
abstract val projectPath: Property<String>

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val physicalArtifacts: RegularFileProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val graphView: RegularFileProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import java.util.SortedSet

@CacheableTask
Expand All @@ -21,7 +22,7 @@ abstract class ComputeDuplicateDependenciesTask : DefaultTask() {
description = "Computes 'duplicate' external dependencies across entire build."
}

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val resolvedDependenciesReports: ConfigurableFileCollection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.gradle.api.file.RegularFile
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE

@CacheableTask
abstract class ComputeResolvedDependenciesTask : DefaultTask() {
Expand All @@ -21,7 +22,7 @@ abstract class ComputeResolvedDependenciesTask : DefaultTask() {
description = "Computes resolved external dependencies for all variants."
}

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val externalDependencies: ListProperty<RegularFile>

Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/com/autonomousapps/tasks/ComputeUsagesTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -32,19 +33,19 @@ abstract class ComputeUsagesTask @Inject constructor(
description = "Computes actual dependency usage"
}

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val graph: RegularFileProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val declarations: RegularFileProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputDirectory
abstract val dependencies: DirectoryProperty

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val syntheticProject: RegularFileProperty

Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/com/autonomousapps/tasks/ExplodeJarTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -40,13 +41,13 @@ abstract class ExplodeJarTask @Inject constructor(
abstract val compileClasspath: ConfigurableFileCollection

/** [`Set<PhysicalArtifact>`][com.autonomousapps.model.PhysicalArtifact]. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val physicalArtifacts: RegularFileProperty

/** [`Set<AndroidLinterDependency>?`][com.autonomousapps.model.intermediates.AndroidLinterDependency] */
@get:Optional
@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val androidLinters: RegularFileProperty

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/com/autonomousapps/tasks/FilterAdviceTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -33,7 +34,7 @@ abstract class FilterAdviceTask @Inject constructor(
description = "Filter merged advice based on user preferences"
}

@get:PathSensitive(PathSensitivity.NONE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val projectAdvice: RegularFileProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.gradle.api.artifacts.ArtifactCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE

abstract class FindAndroidAssetProviders : DefaultTask() {

Expand All @@ -27,7 +28,7 @@ abstract class FindAndroidAssetProviders : DefaultTask() {
this.assetDirs = assets
}

@PathSensitive(PathSensitivity.RELATIVE)
@PathSensitive(RELATIVE)
@InputFiles
fun getAssetArtifactFiles(): FileCollection = assetDirs.artifactFiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE
import org.gradle.workers.WorkAction
import org.gradle.workers.WorkParameters
import org.gradle.workers.WorkerExecutor
Expand All @@ -49,7 +50,7 @@ abstract class FindInlineMembersTask @Inject constructor(
abstract val compileClasspath: ConfigurableFileCollection

/** [PhysicalArtifact]s used to compile this project. */
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFile
abstract val artifacts: RegularFileProperty

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.artifacts.ArtifactCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE

@CacheableTask
abstract class FindNativeLibsTask : DefaultTask() {
Expand All @@ -26,7 +27,7 @@ abstract class FindNativeLibsTask : DefaultTask() {
this.androidJni = androidJni
}

@PathSensitive(PathSensitivity.RELATIVE)
@PathSensitive(RELATIVE)
@InputFiles
fun getAndroidJniFiles(): FileCollection = androidJni.artifactFiles

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.MapProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.PathSensitivity.RELATIVE

@CacheableTask
abstract class GenerateBuildHealthTask : DefaultTask() {
Expand All @@ -28,7 +29,7 @@ abstract class GenerateBuildHealthTask : DefaultTask() {
description = "Generates json report for build health"
}

@get:PathSensitive(PathSensitivity.RELATIVE)
@get:PathSensitive(RELATIVE)
@get:InputFiles
abstract val projectHealthReports: ConfigurableFileCollection

Expand Down
Loading