Skip to content

Conversation

@bartekpacia
Copy link
Member

@bartekpacia bartekpacia commented Mar 9, 2023

This PR fixes #122289

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 9, 2023
@gnprice
Copy link
Member

gnprice commented Mar 10, 2023

@bartekpacia
Copy link
Member Author

bartekpacia commented Mar 10, 2023

Thanks for taking a look and for these links :)

Even though I consider myself a fairly experienced Flutter developer, I have never used flutter migrate on the CLI 😅 Maybe an IDE did some of it for me, but I can't recall. I feel like flutter migrate is not advertised enough - which is a pity, because it looks nice.

The migration sounds like a good idea, but I don't think it's worth it for this change. After all, it's a very minor change and I'm pretty sure the performance benefit is negligible. People who'll get the warning will Google it and replace the default, eager clean task declaration with a lazy one.

That said, if you think it's worth adding this anyway, I'll be happy to dive in and write the migration when I find some free time :)

@gnprice
Copy link
Member

gnprice commented Mar 13, 2023

Even though I consider myself a fairly experienced Flutter developer, I have never used flutter migrate on the CLI Maybe an IDE did some of it for me, but I can't recall. I feel like flutter migrate is not advertised enough - which is a pity, because it looks nice.

Yeah, this appears to be an entirely separate system from flutter migrate. (Which itself apparently no longer exists? Try flutter migrate --help and it says it can't find the command.)

If you take one of those existing migration classes and look at where it's used, you find that the migrations are applied as basically the first step of flutter run or flutter build. For example, the buildLinux function has this near the top:

  final List<ProjectMigrator> migrators = <ProjectMigrator>[
    CmakeCustomCommandMigration(linuxProject, globals.logger),
  ];

  final ProjectMigration migration = ProjectMigration(migrators);
  migration.run();

before it goes on to call _runCmake and _runBuild, and that buildLinux function is in turn called from flutter build linux and flutter run for a Linux target.

So this system doesn't need any advertising; it's already integrated into people's normal workflows.

The migration sounds like a good idea, but I don't think it's worth it for this change. After all, it's a very minor change and I'm pretty sure the performance benefit is negligible. People who'll get the warning will Google it and replace the default, eager clean task declaration with a lazy one.

Everyone will get the warning when they upgrade to Gradle 8+, right? Everyone who's building for Android, anyway.

Many Flutter developers will make that upgrade themselves after Gradle 8 reaches a stable release. And then in a few years everyone will make that upgrade who hasn't already, with the successor to #122376 when some Gradle 8+ version is needed for Java 21.

That's a lot of people who can be saved the effort of spotting this warning, figuring out what it's talking about, locating the fix, and then applying it and convincing themselves it was correct and didn't break anything. (Especially as many of those developers will know very little about Gradle — I suspect that even most people writing native Android apps try to avoid thinking about Gradle much, and all the more so for people working mainly in Flutter.)

So if you're up for taking the understanding you've already acquired of what this warning is about, and spending a bit of time to write and test an automated migration that encodes that understanding, then I think that would be a quite useful thing to do.

It looks like this would also be the pioneering example of a migration for Android builds — all the other platforms have one or more (and iOS is in the lead with ten), but not Android. Fortunately I think that part will be straightforward, just adding a few lines at the top of buildGradleApp similar to the code I quoted above.

@bartekpacia
Copy link
Member Author

Thank you very much for this thorough explanation @gnprice. I agree with this - let's spare people some Gradle warnings :)

I'll add the migration code to this PR when I find some free time (in a few days).

@gnprice
Copy link
Member

gnprice commented Mar 13, 2023

Great!

If you find you have any questions about how that migration system works, I recommend you go to the tools channel in Discord and ping jmagman there. She's the expert on this system, and I've seen her several times recently recommend people use it for various changes.

@bartekpacia bartekpacia marked this pull request as ready for review March 18, 2023 17:28
@bartekpacia
Copy link
Member Author

bartekpacia commented Mar 18, 2023

Hi @gnprice, I added a migrator :) I'll be happy if you review it!

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for writing this! Generally looks great. Various small comments below.

@gnprice gnprice requested a review from jmagman March 19, 2023 21:00
@gnprice
Copy link
Member

gnprice commented Mar 19, 2023

Would also be great to have a review from someone who's worked with this migration system. @jmagman, tagging you in as the expert, but please feel free to pass it off to someone else.

@bartekpacia
Copy link
Member Author

Thanks a lot for the review @gnprice! I addressed all the things you mentioned.

Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM except one nit. We'll also want that second review as mentioned above at #122290 (comment) .

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

This migration should be run in all the example/integration test projects so when folks run them locally they don't have changes to their working copy.

Here's an example of a migration that did that: https://github.com/flutter/flutter/pull/108331/files

@jmagman jmagman requested a review from reidbaker March 20, 2023 19:48
@jmagman
Copy link
Member

jmagman commented Mar 20, 2023

@reidbaker can you add the right person to review?

@bartekpacia
Copy link
Member Author

bartekpacia commented Mar 20, 2023

Uh, Mac web_tool_tests are failing and from looking at the logs, I can't figure out why.

EDIT 1: Looks like it's a known issue #123018

EDIT 2: Works after rebase

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.

The gradle parts look good to me that said I a have not yet written a migration. Pinging
@camsim99 to see if they have any migration based input.

@reidbaker reidbaker requested a review from camsim99 March 20, 2023 21:33
@camsim99
Copy link
Contributor

The gradle parts look good to me that said I a have not yet written a migration. Pinging @camsim99 to see if they have any migration based input.

I don't have any experience writing migrators, so I would defer to you @reidbaker.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Remove dead code in test.

Copy link
Member

Choose a reason for hiding this comment

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

@camsim99 @reidbaker @gnprice I can review the "migration" part (that LGTM) but I don't know anything about the gradle part of this.
This only changes android/build.gradle but not android/app/build.gradle, do they both need to be changed?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, changing just the one is correct. That's the only one where the templates happen to contain the pattern that generates the Gradle warning in #122289.

@bartekpacia bartekpacia requested review from jmagman and removed request for camsim99 March 21, 2023 20:02
@auto-submit auto-submit bot merged commit c40dd27 into flutter:master Mar 21, 2023
@bartekpacia bartekpacia deleted the fix/flutter_create_android_gradle_task_warning branch March 22, 2023 09:39
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 23, 2023
gnprice added a commit to gnprice/zulip-flutter that referenced this pull request Mar 27, 2023
This update gets made automatically by a `flutter build` or
`flutter run` command targeting Android.  It was introduced
last week:
  flutter/flutter#122290
  flutter/flutter@c40dd27
chrisbobbe pushed a commit to zulip/zulip-flutter that referenced this pull request Mar 27, 2023
This update gets made automatically by a `flutter build` or
`flutter run` command targeting Android.  It was introduced
last week:
  flutter/flutter#122290
  flutter/flutter@c40dd27
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
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 platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fresh flutter createed Android project has a Gradle warning on Android Studio Giraffe (Canary version)

5 participants