Usage of absolute path as input
See original GitHub issueRecently after comparing build scans produced on developer machine and CI node we noticed following:
Input ‘kotlinCompile.com.squareup.anvil.compiler.src-gen-dir’ is in both builds but the values are different.
This produces remote build cache misses for following tasks as paths are different:
org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTaskorg.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTaskorg.jetbrains.kotlin.gradle.tasks.KotlinCompileWithWorkers
I took a look in the source code and found this line: https://github.com/square/anvil/blob/9fb3c5f5b8a5134dd97d21d740271dcb276c6e0c/gradle-plugin/src/main/java/com/squareup/anvil/plugin/AnvilSubplugin.kt#L46 that returns absolute path to the Kotlin plugin. Kotlin plugin itself sets this as task inputs via https://github.com/JetBrains/kotlin/blob/34b55dbeb3a65b39b3585a646b5a0d2b1ce4dd96/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt#L1078
I am not sure what proper fix should be. Probably either using srcGenDir.relativeTo(project.buildDir) or asking Kotlin team to add relative kind type to FilesSubpluginOptions.
Issue Analytics
- State:
- Created 3 years ago
- Comments:25

Top Related StackOverflow Question
@gabrielittner I’ve checked on 1.4.10 - same issue
I’m going to stick this in the ticket so it doesn’t get lost in the pull request. 😃 I would recommend writing a cache relocatability test to ensure that all the tasks are relocatable.
Here is a sample in groovy: https://github.com/gradle/android-cache-fix-gradle-plugin/blob/master/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy#L32
Here is a sample in kotlin: https://android.googlesource.com/platform/tools/base/+/mirror-goog-studio-master-dev/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/cacheability/CacheabilityTest.kt#181