Yauhen
06/07/2022, 4:27 PM@get:InputFile
and mergedManifest.set(variant.artifacts.get(SingleArtifact.MERGED_MANIFEST))
). Task works, but it is not attached to default AGP build pipeline. I mean when I call it manually - it works, but when I just assemble project - task is not executed. My question is how to attach my task to default build pipeline?
So if I want to check manifest I need to wait until “processManifest” task finishes. In my case, if I call my custom manifest verification task manually - my tasks successfully executes after AGP “processManifest” task, but, when I just build project in AS - my task is not executed after “processManifest”. Previously I used just dependsOn
and stuff like that, but now as I understand it is not what expected? Maybe I need to use “wire” API’s but all these methods need some output, but I don’t have any. My task needs just input.
Here is the code:
Task creation
fun createManifestCheckerTask(project: Project, variant: Variant) {
val taskProvider = project.tasks.register(
"networkSecurityConfigCheckerTask${variant.name.capitalize()}",
NetworkSecurityConfigCheckerTask::class.java
) {
it.group = GROUP_NAME
it.mergedManifest.set(variant.artifacts.get(SingleArtifact.MERGED_MANIFEST))
}
}
Task
abstract class NetworkSecurityConfigCheckerTask : DefaultTask() {
@get:InputFile
abstract val mergedManifest: RegularFileProperty
@TaskAction
fun checkNetworkSecurityConfig() {
val mergedManifestFile = mergedManifest.get().asFile
//...
}
}
Xavier Ducrohet
06/07/2022, 4:35 PM