Slackbot
06/09/2023, 8:54 AMThomas Broyer
06/09/2023, 9:23 AMcom.jaredsburrows.license
, all tasks declare the same @OutputDirectory
by default, so you should probably start by using a separate output directory for each task.Vampire
06/09/2023, 9:25 AMlicenseReportTask
properly declares its ouptput to be the exact files and not declare the whole directory as output directory, then use from(licenseReportTas)
instead of the dir with filter and it should work properly I guess.
Btw. are you aware that you completely disable task configuration avoidance?Vampire
06/09/2023, 9:26 AMtasks.matching
each and every task needs to be realized to check the predicate. If possible you should at least guard it before with a withType
to at least only force realization of all tasks of that type.Thomas Broyer
06/09/2023, 9:43 AMtasks.named("license${variantName}Report")
should be enough (and then licenseReportTask.configure { … }
rather than then configureEach
). Same for the merge task: tasks.named("merge${variantName}Report") { dependsOn(…) }
.Thomas Keller
06/09/2023, 10:17 AMVampire
06/09/2023, 10:19 AMthough in this caseIf the tasks are already registered, yes. I mean to remember that AGP does dirty stuff with registering tasks inshould be enoughtasks.named("license${variantName}Report")
afterEvaluate
or something like that.
But that might also have changed in the meantime. I don't follow Android development too closely.Thomas Keller
06/09/2023, 10:22 AMonVariants
is already better than afterEvaluate
, but I’ll try my best.Thomas Keller
06/09/2023, 10:51 AMtasks.named("…")
does not work, because the task is generated lazily afterwards and I can’t filter the task collection more, because the task’s type is internal
, i.e. not visible for me. (On a related note, I see this in more and more plugins that task classes are considered “private”, unaccessible for users, e.g. also in some of Jetbrain’s plugins, like kotlinx-kover
https://github.com/Kotlin/kotlinx-kover/blob/main/kover-gradle-plugin/src/main/kotlin/kotlinx/kover/gradle/plugin/tasks/reports/KoverHtmlTask.kt, is this actually bad design then, because there is no single task-matching lazy API available other than tasks.matching { … }
?)Thomas Keller
06/09/2023, 10:52 AMVampire
06/09/2023, 11:23 AMVampire
06/11/2023, 9:07 PMtasks.configureEach {
if (it.name == "merge${variantName}Assets") {
dependsOn(licenseReportTask)
dependsOn(copyTask)
}
}
Vampire
06/11/2023, 9:09 PMif
even needs to only be evaluated on the tasks actually being configure instead of all tasks.Thomas Keller
06/12/2023, 7:51 AM