Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Jul 12, 2024

Follow up to #151433.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 12, 2024
@gmackall gmackall marked this pull request as ready for review July 16, 2024 18:25
@gmackall gmackall requested a review from a team July 16, 2024 18:25
@reidbaker
Copy link
Contributor

I think build variants is supported for modules which means that this feature wont work for people who have custom variants.

https://docs.flutter.dev/deployment/flavors#using-flavors-in-android

I think you are going to need to write some dynamic code to handle other variants.

(blog post for apps)
https://medium.com/meeve/build-variants-in-flutter-for-multiple-backend-environments-7e139128949b

Copy link
Contributor

@reidbaker reidbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show that custom variants work before merging.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gmackall
Copy link
Member Author

gmackall commented Aug 7, 2024

I think build variants is supported for modules which means that this feature wont work for people who have custom variants.

https://docs.flutter.dev/deployment/flavors#using-flavors-in-android

I think you are going to need to write some dynamic code to handle other variants.

(blog post for apps) https://medium.com/meeve/build-variants-in-flutter-for-multiple-backend-environments-7e139128949b

I'm not actually sure that modules support flavors, because:

  1. it is possible to build a module as an AAR by itself (independently of a pure android host project)
  2. Configuring flavors per https://docs.flutter.dev/deployment/flavors#using-flavors-in-android requires Gradle changes
  3. The Gradle files are ephemeral for modules, so the user can't change them (reliably)

But I think also this new change would support them anyways, though it's kind of hacky

@gmackall gmackall requested a review from reidbaker August 7, 2024 17:42
@gmackall
Copy link
Member Author

@reidbaker This should be ready for review again fyi

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 12, 2024
@auto-submit auto-submit bot merged commit 814e49b into flutter:master Aug 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 12, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 12, 2024
DBowen33 pushed a commit to DBowen33/flutter that referenced this pull request Aug 16, 2024
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
auto-submit bot pushed a commit that referenced this pull request Sep 10, 2024
#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: #154371
@gmackall gmackall added the cp: stable cherry pick this pull request to stable release candidate branch label Sep 10, 2024
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants