flutter/packages/flutter_tools/templates/module/android
Gray Mackall f964f15dcb
Fix flutter build aar for modules that use a plugin (#154757)
https://github.com/flutter/flutter/pull/151675 bumped module templates to AGP 8.1.

In doing so, I tried to work around a behavior change [that was new in AGP 8.0](https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes):
> AGP 8.0 creates no SoftwareComponent by default. Instead AGP creates SoftwareComponents only for variants that are configured to be published using the publishing DSL.

by using AGP's publishing DSL to define which variants to publish in the module's ephemeral gradle files:
```
android.buildTypes.all {buildType ->
    if (!android.productFlavors.isEmpty()) {
        android.productFlavors.all{productFlavor ->
            android.publishing.singleVariant(productFlavor.name + buildType.name.capitalize()) {
                withSourcesJar()
                withJavadocJar()
            }
        }
    } else {
        android.publishing.singleVariant(buildType.name) {
            withSourcesJar()
            withJavadocJar()
        }
    }
}
```

The problem is that this doesn't get applied to the plugin projects used by the module, so if a module uses any plugin it breaks. This PR fixes that by applying similar logic, but to each project (not just the module's project).

Tested manually with https://github.com/gmackall/GrayAddToApp, and also re-enabled an old test that tested this use case as a part of the PR.

Fixes: https://github.com/flutter/flutter/issues/154371
2024-09-10 16:42:22 +00:00
..
deferred_component Reland "Update template/test compileSdk, targetSdk, ndk versions" (#153795) 2024-08-21 18:27:00 +00:00
gradle Remove conditionality in templates that was for AGP <= 4.2 support (#151845) 2024-07-16 22:33:24 +00:00
host_app_common/app.tmpl Remove conditionality in templates that was for AGP <= 4.2 support (#151845) 2024-07-16 22:33:24 +00:00
host_app_editable Make paths absolute in settings.gradle (#33228) 2019-05-23 23:32:11 -07:00
host_app_ephemeral Make paths absolute in settings.gradle (#33228) 2019-05-23 23:32:11 -07:00
library_new_embedding Fix flutter build aar for modules that use a plugin (#154757) 2024-09-10 16:42:22 +00:00