Skip to content

Remove code that manipulates AGP tasks by discovering them via their name #166550

@gmackall

Description

@gmackall

The Flutter Gradle plugin is (by necessity) built on top of AGP.

AGP today has exposed APIs designed for extending it https://developer.android.com/build/extend-agp#variant-api-artifacts-tasks.

This was not the case when the Flutter Gradle plugin was written. Instead, we discovered tasks that AGP added by guessing their name as a string and then doing things with them (typically making them depend on the Flutter tasks that we were adding). We should remove this string based guessing, and migrate to their intended API.

e.g.

Task packageAssets
Task cleanPackageAssets
try {
packageAssets = project.tasks.named("package${variant.name.capitalize()}Assets").get()
} catch (UnknownTaskException ignored) {
packageAssets = null
}
try {
cleanPackageAssets = project.tasks.named("cleanPackage${variant.name.capitalize()}Assets").get()
} catch (UnknownTaskException ignored) {
cleanPackageAssets = null
}

The good news is that I think these attempts to get tasks might already be failing? They seemed to be always null in my brief testing, which means it would be easy to remove them. But that is a guess.

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toolplatform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions