Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix failing lint : findByPath requires a specific ordering of project evaluation in aar_init_script.gradle #159301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jan 21, 2025

Conversation

AbdeMohlbi
Copy link
Contributor

@AbdeMohlbi AbdeMohlbi commented Nov 21, 2024

android studio linter is prompting this lint:
388711888-61ab84da-4941-4aa4-a42e-fac4c140f4bd

Pre-launch Checklist

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

@github-actions github-actions bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. labels Nov 21, 2024
@AbdeMohlbi AbdeMohlbi changed the title Update aar_init_script.gradle fix failing lint : findByPath requires a specific ordering of project evaluation in aar_init_script.gradle Nov 25, 2024
@AbdeMohlbi AbdeMohlbi marked this pull request as ready for review November 25, 2024 21:09
@reidbaker reidbaker requested review from gmackall and jesswrd December 3, 2024 19:19
@stuartmorgan-g
Copy link
Contributor

test-exempt: Writing unit tests for this change is not possible until we deprecate the script apply and migrate build code to Kotlin

@jesswrd
Copy link
Contributor

jesswrd commented Dec 3, 2024

@AbdeMohlbi Can you link an issue and/or be more specific in the PR description? So we know what this is in the future. Thanks! 🙏

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@AbdeMohlbi
Copy link
Contributor Author

@AbdeMohlbi Can you link an issue and/or be more specific in the PR description? So we know what this is in the future. Thanks! 🙏

android studio is suggesting replacing the usage of findByPath to named .
it's not the first time see : see this

@@ -175,8 +175,13 @@ projectsEvaluated {
// Configure the `assembleAar<variantName>` task for each plugin's projects and make
// the module's equivalent task depend on the plugin's task.
String variantName = variant.name.capitalize()
moduleProject.tasks.findByPath("assembleAar$variantName")
.dependsOn(pluginProject.tasks.findByPath("assembleAar$variantName"))
try {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why we are introducing a try catch here, and ignoring when we can't find the task? What are the consequences of failing to establish this dependency?

Should we instead follow the pattern of asserting that we find the task, something like

Task moduleProjectTask = moduleProject.tasks.named("assembleAar$variantName").get()
assert(moduleProjectTask != null)

Copy link
Contributor Author

@AbdeMohlbi AbdeMohlbi Dec 5, 2024

Choose a reason for hiding this comment

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

IMO it's better to add a try catch with an error message so the user can know what went wrong
something like

try{
} catch (UnknownTaskException ignored) {
println("could not find the task named assembleAar$variantName")
// println("full stacktrace ")
}

Copy link
Member

Choose a reason for hiding this comment

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

I think it is important for us to know the consequences of failing to find the task/add this dependency.

If it will always result in a build failure, just adding a log line here and then letting the build proceed will end up confusing more users (because they won't make the connection between the eventual build failure and single log line among the entire log output of the build). In this case we should assert that the tasks aren't null.

If there are some cases where failing to (find the tasks)/(add the dependency) is actually ok, then we should make sure we understand those cases and log appropriately (and in this case, catching the error might be ok).

Copy link
Contributor Author

@AbdeMohlbi AbdeMohlbi Dec 5, 2024

Choose a reason for hiding this comment

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

so i considered two things when updating this code :

moduleProject.tasks.findByPath("assembleAar$variantName")
.dependsOn(pluginProject.tasks.findByPath("assembleAar$variantName"))
  1. findByPath returns the task (if a task with the specified path does exist), else returns null , so calling depnedsOn on a null object triggers a NullPointerException wich can be confusing to users.
  2. findByPath has a suggested replacement which does the same work but throw an exception earlier to guarantee that NullPointerException would not occur and a UnknownTaskException would be throwed instead.
    So overall any good change that satisfy these two would be good i guess .
    how should i chnage it now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Friendly bump @gmackall

Copy link
Member

Choose a reason for hiding this comment

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

I think either adding asserts as mentioned in the initial comment in this chain, or using the suggested replacement mentioned in option 2 of #159301 (comment) sounds good to me.

@AbdeMohlbi AbdeMohlbi requested a review from gmackall December 13, 2024 07:18
@bkonyi
Copy link
Contributor

bkonyi commented Dec 19, 2024

@gmackall I think this is ready for another look when you have a chance.

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 21, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jan 21, 2025
Merged via the queue into flutter:master with commit 5ffb45b Jan 21, 2025
145 of 146 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 22, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 23, 2025
…8482)

Manual roll Flutter from b9e86a565f92 to b2f515f45ef5 (42 revisions)

Manual roll requested by [email protected]

flutter/flutter@b9e86a5...b2f515f

2025-01-22 [email protected] Roll Dart to Version 3.8.0-24.0.dev (flutter/flutter#162035)
2025-01-22 [email protected] `const AnimationStyle` (flutter/flutter#160564)
2025-01-22 [email protected] Add piping and bringup nodes for `_vulkan` and `_opengles` suites. (flutter/flutter#162020)
2025-01-22 [email protected] [Impeller] Migrate unit tests off of Skia geometry classes (flutter/flutter#161855)
2025-01-22 [email protected] Experiment with a `files-changed.json` per PR (flutter/flutter#161788)
2025-01-22 [email protected] Move FlKeyboardManager and FlKeyboardHandler from FlView to FlEngine. (flutter/flutter#161925)
2025-01-22 [email protected] Roll Packages from e8f1f63 to 3d3ab7b (1 revision) (flutter/flutter#162019)
2025-01-22 [email protected] Adds cupertino picker semantics test (flutter/flutter#161768)
2025-01-22 [email protected] [web] Remove deprecated web-only APIs from dart:ui (flutter/flutter#161775)
2025-01-22 [email protected] fix: Add enabled property for search anchor named constructor (flutter/flutter#161468)
2025-01-22 [email protected] Roll pub packages (flutter/flutter#162015)
2025-01-22 [email protected] [web] Remove spam from test output (flutter/flutter#161774)
2025-01-22 [email protected] Match CupertinoPageTransitionsBuilder animation duration to CupertinoPageRoute (2) (flutter/flutter#161577)
2025-01-22 [email protected] Make `font-subset` a standalone `run_tests.py` variant. (flutter/flutter#162016)
2025-01-22 [email protected] Enabled provisioning updates and device registration during building xcarchive. (flutter/flutter#159622)
2025-01-22 [email protected] [web] Remove HTML from bots, test suites and e2e tests (flutter/flutter#161537)
2025-01-22 [email protected] Expand the `.ci.yaml` and `builder.json` linter (flutter/flutter#161991)
2025-01-22 [email protected] Fix incorrect [enabled] documentation (flutter/flutter#161650)
2025-01-22 [email protected] Add `windows_host_engine_test`. (flutter/flutter#161992)
2025-01-22 [email protected] Roll Dart to version Version 3.8.0-19.0.dev (flutter/flutter#161989)
2025-01-22 [email protected] Deprecate `ThemeData.indicatorColor` in favor of `TabBarThemeData.indicatorColor` (flutter/flutter#160024)
2025-01-22 [email protected] [Impeller] disable older xclipse gpu driver. (flutter/flutter#161981)
2025-01-22 [email protected] Merge changelog for 3.27.3 release (flutter/flutter#161977)
2025-01-21 [email protected] Remove FlKeyboardViewDelegate (flutter/flutter#161705)
2025-01-21 [email protected] Fix documentation of Flow.clipBehavior (flutter/flutter#161863)
2025-01-21 [email protected] [impeller] prevent PowerVR from using Vulkan backend. (flutter/flutter#161841)
2025-01-21 [email protected] [Impeller] backfilling TextContents unit tests (flutter/flutter#161625)
2025-01-21 [email protected] Do not handle Dart isolate messages if the isolate is being shut down (flutter/flutter#161824)
2025-01-21 [email protected] fix failing lint : findByPath requires a specific ordering of project evaluation in `aar_init_script.gradle` (flutter/flutter#159301)
2025-01-21 [email protected] Get `et` working for local web engine builds. (flutter/flutter#161825)
2025-01-21 [email protected] Mark Linux_pixel_7pro flavors_test unflaky (flutter/flutter#160994)
2025-01-21 [email protected] Marks Mac_mokey run_debug_test_android to be flaky (flutter/flutter#161656)
2025-01-21 [email protected] Don't crash flutter tool if Chrome is not available (flutter/flutter#154941)
2025-01-21 [email protected] Fix DropdownMenu icon and item icon misalignment (flutter/flutter#161717)
2025-01-21 [email protected] [native assets] Cleanup dead code 2 (flutter/flutter#161916)
2025-01-21 [email protected] Update `ListTile` test to prevent log dump and test error message. (flutter/flutter#161811)
2025-01-21 [email protected] Roll pub packages (flutter/flutter#161924)
2025-01-21 [email protected] Make `PipelineOwner` a `base` class (flutter/flutter#161789)
2025-01-20 [email protected] [native assets] Cleanup dead code (flutter/flutter#161913)
2025-01-20 [email protected] Roll Packages from f73cb00 to e8f1f63 (9 revisions) (flutter/flutter#161914)
2025-01-20 [email protected] [ flutter_tool ] Fix flakiness in doctor_test.dart (flutter/flutter#161917)
2025-01-19 [email protected] Update documentation on what display information is provided. (flutter/flutter#161785)

If this roll has caused a breakage, revert this CL and stop the roller
...
Wasmund1 pushed a commit to Wasmund1/flutter that referenced this pull request Jan 24, 2025
… evaluation in `aar_init_script.gradle` (flutter#159301)

android studio linter is prompting this lint: 

![388711888-61ab84da-4941-4aa4-a42e-fac4c140f4bd](https://github.com/user-attachments/assets/e031c231-8a7e-4b3b-a4a1-1aed3d461ac7)


## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] 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 `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Gray Mackall <[email protected]>
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants