Hello.
I’m trying to collect Android Lint reports from multiple gradle modules and then aggregate them in the root module. And I’m trying to do this the project-isolation-compatible way, so no direct references between projects. From what I could read, the best way to do this was using configurations. Here is what I came up:
First, I would create a configuration in the every module:
project.configurations.create("reportAggregatingConfiguration")
Then, in producer modules, I would configure all AndroidLint tasks to push artifacts into the created configuration:
tasks.withType(AndroidLintTask::class.java).configureEach { lintTask ->
artifacts.add("reportAggregatingConfiguration", lintTask.sarifReportOutputFile) { artifact ->
artifact.builtBy(lintTask)
}
}
In the root module, I would first automatically add a dependency to all subprojects (since I don’t want to specify every single module manually):
subprojects {
dependencies.add(
"reportAggregatingConfiguration",
dependencies.project(
mapOf(
"path" to it.isolated.path,
"configuration" to "reportAggregatingConfiguration"
)
)
)
}
Then, finally, I would create a task in the root module that receives all of the files added to that configuration :
project.tasks.register("reportMerge", SarifMergeTask::class.java) { task ->
task.input.from(configurations.getByName("reportAggregatingConfiguration").incoming.artifactView {
it.isLenient = true
}.files)
}
Above worked fine until Gradle 9, but now it crashes with the Cannot mutate the artifacts of configuration ‘reportAggregatingConfiguration’ after the configuration was consumed as a variant. After a configuration has been observed, it should not be modified. error.
From what I can see, the issue is that AndroidLint tasks get created and configured after all variants are resolved and after my configuration has been consumed, freezing it.
How could this be resolved? Is there an alternate path that I can take?
Thanks.