Skip to content

Commit 568a9a2

Browse files
authored
Merge pull request #4 from pesjak/fix/config-cache-robolectric
Keep TaskProviders out of the unit-test task's onlyIf spec for configuration-cache compatibility
2 parents 02ce30e + 07447e9 commit 568a9a2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

compose-nav-graph-gradle/src/main/kotlin/com/github/skydoves/navgraph/gradle/NavGraphGradlePlugin.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ public class NavGraphGradlePlugin : Plugin<Project> {
716716
gradle.taskGraph.whenReady {
717717
val active = wired.filter { hasTask(it.anchor.get()) }
718718
if (active.isEmpty()) return@whenReady
719+
// Materialized OUTSIDE the closures attached to the test task: the configuration cache serializes that
720+
// task's whole state — sysprops AND its onlyIf specs — so a spec capturing `active` would drag each
721+
// Wired's TaskProviders (realized DefaultTasks) into the entry and fail serialization. Plain Files don't.
722+
val renderListFiles = active.map { it.renderListFile.get().asFile }
719723
agpTest.get().apply {
720724
filter {
721725
includeTestsMatching("*NavGraphRobolectricRenderTest")
@@ -734,9 +738,7 @@ public class NavGraphGradlePlugin : Plugin<Project> {
734738
}
735739
// Run iff ANY active pipeline has a non-empty render list (a Layoutlib failure to fill somewhere).
736740
onlyIf {
737-
active.any { w ->
738-
w.renderListFile.get().asFile.let { it.isFile && it.readText().isNotBlank() }
739-
}
741+
renderListFiles.any { it.isFile && it.readText().isNotBlank() }
740742
}
741743
// Force the render to run when requested (the prior thumbnails aren't a tracked output of the test).
742744
outputs.upToDateWhen { false }

0 commit comments

Comments
 (0)