Repository navigation
[CP-stable][tool] Don't require a Flutter compile task when staging jniLibs - #189075
Conversation
…tter#188805) The variant-API jniLibs copy task referenced the Flutter compile task by name via tasks.named(...), which throws when that task is not registered. It is not registered for builds where shouldConfigureFlutterTask returns false - e.g. `./gradlew :app:assembleAndroidTest` after `flutter build apk --config-only`, which is how flutter/packages' Firebase Test Lab tooling builds - causing "Could not create task ':app:copyJniLibsflutterBuildDebug'. > Task with name 'compileFlutterBuildDebug' not found". Look the compile task up tolerantly with findByName and make the copy task's intermediateDir input optional, so the task degrades to a no-op (empty output) when there is no Flutter build for the variant - matching the forgiving behavior of the previous source-set approach. Adds an assembleAndroidTest regression test. Fixes flutter#188785 --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@gmackall please fill out the PR description above, afterwards the release team will review this request. |
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request modifies the Gradle plugin to handle builds where the Flutter compile task is absent, such as assembleAndroidTest, by using tolerant task lookups and marking the intermediate directory as optional. It also adds an integration test for this scenario. The review feedback suggests restricting the task lookup using .withType(FlutterTask::class.java) to maintain Gradle task configuration avoidance.
| // Look it up tolerantly (findByName, not named) so this task degrades to a no-op | ||
| // with empty output instead of failing to be created when there is no Flutter | ||
| // build for the variant. See https://github.com/flutter/flutter/issues/188785. | ||
| dependsOn(projectToAddTasksTo.tasks.matching { it.name == compileTaskName }) |
There was a problem hiding this comment.
Using tasks.matching { ... } without a type filter forces Gradle to eagerly create and configure every single task in the project to check its name. This defeats task configuration avoidance and can significantly slow down Gradle configuration time. Restricting the query with .withType(FlutterTask::class.java) ensures that only tasks of type FlutterTask are realized.
| dependsOn(projectToAddTasksTo.tasks.matching { it.name == compileTaskName }) | |
| dependsOn(projectToAddTasksTo.tasks.withType(FlutterTask::class.java).matching { it.name == compileTaskName }) |
a54cf4c
into
flutter:flutter-3.44-candidate.0
…niLibs (flutter#189075) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: flutter#189049 flutter#188785 ### Impact Description: Fixes a compile time crash of [android instrumented tests](https://developer.android.com/training/testing/instrumented-tests) (e.g. `assembleDebugAndroidTest`, which is relied upon by our packages tests and some ecosystem members such as patrol). ### Changelog Description: Fixes a breakage of [android instrumented tests](https://developer.android.com/training/testing/instrumented-tests) (e.g. `assembleDebugAndroidTest`, which is relied upon by our packages tests and some ecosystem members such as patrol). < Replace with changelog description here > [flutter/188805] Fixes a crash when running android instrumented tests. ### Workaround: No. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Explained in detail in flutter#188785 but in short, go to your flutter/packages checkout, cd to the camera example app and run ``` flutter build apk --debug --config-only cd android ./gradlew app:assembleAndroidTest -Pverbose=true ```
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#189049
#188785
Impact Description:
Fixes a compile time crash of android instrumented tests (e.g.
assembleDebugAndroidTest, which is relied upon by our packages tests and some ecosystem members such as patrol).Changelog Description:
Fixes a breakage of android instrumented tests (e.g.
assembleDebugAndroidTest, which is relied upon by our packages tests and some ecosystem members such as patrol).< Replace with changelog description here >
[flutter/188805] Fixes a crash when running android instrumented tests.
Workaround:
No.
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
Explained in detail in #188785
but in short, go to your flutter/packages checkout, cd to the camera example app and run