Repository navigation
Flutter Gradle Plugin (flutter.gradle) is not taking advantage of Gradle's Configuration Avoidance API #119196
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jan 26, 2023 Thanks for the report. Seeing same behavior as reported. Will keep this issue open and label for team's thoughts on current behavior.
stable, master flutter doctor -v
[!] Flutter (Channel stable, 3.7.0, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.7.0 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision b06b8b2710 (28 hours ago), 2023-01-23 16:55:55 -0800 • Engine revision b24591ed32 • Dart version 2.19.0 • DevTools version 2.20.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.7.0-27.0.pre.25, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.7.0-27.0.pre.25 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision c9affdba9d (3 hours ago), 2023-01-25 21:25:02 -0800 • Engine revision 8f1e5dc1b1 • Dart version 3.0.0 (build 3.0.0-157.0.dev) • DevTools version 2.20.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category.- addedplatform-androidAndroid applications specificallyAndroid applications specificallytoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.t: gradle"flutter build" and "flutter run" on Android"flutter build" and "flutter run" on Androidhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onfound in release: 3.7Found to occur in 3.7Found to occur in 3.7and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Jan 26, 2023 - addedc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capability
on Jan 26, 2023 Can you describe some of the benefit developers will get if this work is done?
- addedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jan 26, 2023 Sure.
Overall, it ain't gonna be that much of a benefit, but I think it's still worth it (if it's merely replacing a few method calls).
For example, here's what motivated me to create this issue: I was optimizing my app's build times on Android and was using Gradle's Build Scan feature for this. I followed the Gradle tutorial I linked above. I saw that a few Flutter's Gradle tasks (e.g for releasing - which happens quite rarely compare to, say,
assembleDebug) are configured on each build, and initially I though that I mesed something up in my app's code (before I checked Flutter's Gradle plugin code).There should also be some performance benefit, but I didn't measure it. I guess it'll be negligible for most people on modern hardware.
And we'll be following Gradle best practices. Hooray.
I can contribute this if you agree with this issue.
- removedwaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter respondsThe Flutter team cannot make further progress on this issue until the original reporter responds
on Jan 26, 2023 Yeah I am open to a pull request if you decide to contribute.
- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Jan 26, 2023 - addedteam-androidOwned by Android platform teamOwned by Android platform teamtriaged-androidTriaged by Android platform teamTriaged by Android platform team
on Jul 8, 2023
Steps to Reproduce
flutter createa simple appRun a debug Gradle build in the
androiddirectory$ ./gradlew :app:tasksExpected results:
I expect no tasks to be created immediately, to follow Gradle's best practices (Task Configuration Avoidance in this case).
Tasks such as
compileFlutterBuildReleaseorpackBuildsFlutterLibReleasesound like they should only be configured when building an app in release mode, but instead, they're created in every Gradle build.These tasks are registered in flutter.gradle. According to Gradle, the lazy
project.tasks.register()method should be used instead of the eagerproject.tasks.create()method.Actual results:
Some tasks are created immediately on every Gradle invocation (so basically every time someone
flutter runs on Android).How to see what tasks are created immediately in Gradle?
Use Build Scans. To create a scan for the Gradle build:
$ ./gradlew :app:tasks --scanSee an example Build Scan demonstrating this: link.
Logs