Skip to content

Instantly share code, notes, and snippets.

@ghale
Last active July 11, 2020 12:53
Show Gist options
  • Save ghale/c5318501da2d50a9f084812e1c9e9bbc to your computer and use it in GitHub Desktop.
Save ghale/c5318501da2d50a9f084812e1c9e9bbc to your computer and use it in GitHub Desktop.
Workaround for MergeResources cache miss
tasks.withType(com.android.build.gradle.tasks.MergeResources) { task ->
Map<String, FileCollection> originalResources = [:]
// Create a synthetic input with the original value and RELATIVE path sensitivity
project.gradle.taskGraph.beforeTask {
if (it == task) {
originalResources.putAll(task.resourcesComputer.resources)
task.resourcesComputer.resources.clear()
task.inputs.files(originalResources.values())
.withPathSensitivity(PathSensitivity.RELATIVE)
.withPropertyName("rawLocalResources.workaround")
}
}
// Set the source back to its original value before we execute the main task action
task.doFirst {
task.resourcesComputer.resources.putAll(originalResources)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment