Thomas Keller
12/19/2024, 10:42 AMOutputDirectory annotated property codeDir a provider from the project layout and then map the task property to the srcDir of the source set it contributes code to. Still, Gradle responds with Reason: Task ':app:explodeCodeSourceMyVariant' uses this output of task ':app:generateActualResourceCollectorsForAndroidMain' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. (https://youtrack.jetbrains.com/issue/CMP-7283). So why does implicit task wiring not work here? Because the zip operator is used instead of map? Because srcDir is called with listOf() (I guess to have a sane default if sources should not be generated, so emptyList() can act as fallback)?Javi
12/19/2024, 11:09 AMMartin
12/19/2024, 11:39 AMMartin
12/19/2024, 11:41 AM.zip doesn't carry over task dependencies?Martin
12/19/2024, 11:44 AMMartin
12/19/2024, 11:45 AMMartin
12/19/2024, 11:54 AMzip seems to carry task dependencies:
abstract class MyTask: DefaultTask() {
@get:InputFiles
abstract val inputFiles: ConfigurableFileCollection
@get:OutputFile
abstract val outputFile: RegularFileProperty
@TaskAction
fun taskAction() {
outputFile.get().asFile.parentFile.mkdirs()
outputFile.get().asFile.writeText("hello" + inputFiles.files.single().readText())
}
}
val producer = tasks.register("producer", MyTask::class.java) {
inputFiles.from(file("settings.gradle.kts"))
outputFile = file("build/producerOutput")
}
val shouldGenerateCode = provider { true }
val consumer = tasks.register("consumer", MyTask::class.java) {
inputFiles.from(producer.zip(shouldGenerateCode) { file, flag ->
if (flag) listOf(file) else emptyList()
})
outputFile = file("build/consumerOutput")
}Martin
12/19/2024, 11:55 AMThomas Keller
12/19/2024, 12:09 PMThomas Keller
12/19/2024, 12:09 PMVampire
12/19/2024, 2:58 PMzip looses task dependencies, but that was fixed in 7.2-RC2.Martin
12/19/2024, 3:12 PMVampire
12/19/2024, 3:14 PMThomas Keller
12/19/2024, 7:31 PM