Skip to content
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

feat: Support overriding native endorsed plugins #137040

Merged
merged 27 commits into from
Jul 11, 2024

Conversation

Gustl22
Copy link
Contributor

@Gustl22 Gustl22 commented Oct 22, 2023

These changes allow to override existing native endorsed (federated & inline) plugins with e.g. non-endorsed plugin implementations via direct dependencies as described in the section Platform implementation selection in the design doc.

# pubspec.yaml
name: example
dependencies:
  my_plugin: ^0.0.1
  my_plugin_android_alternative: ^0.0.1

Closes #80374, closes #59657

Related: Override Dart plugins (#87991, #79669)

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 Oct 22, 2023
@Gustl22

This comment was marked as outdated.

@zr6328

This comment was marked as off-topic.

@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from b1121c3 to b8a1c9b Compare December 21, 2023 18:25
@stuartmorgan
Copy link
Contributor

It's hard to see what's changing here since it's mixed with some large-change refactors (most notably extracting _getPossiblePluginResolutions); pulling any purely code refactor into a simple prequel PR that doesn't also change logic would be useful in getting feedback here.

@Gustl22
Copy link
Contributor Author

Gustl22 commented Jan 9, 2024

Thanks, yes that was also my intention, I will have time in the coming week to work on it :)

auto-submit bot pushed a commit that referenced this pull request Jan 22, 2024
…141780)

Part of #137040 and #80374

- Rename _filterPluginsByPlatform to _createPluginMapOfPlatform
- Move method in chronological order
- Cleanup platform strings
auto-submit bot pushed a commit that referenced this pull request Feb 26, 2024
…42035)

Part of #137040 and #80374

- Differentiate pubspec and resolution errors
- Rename platform to platformKey
- Add TODO for rework logic of flag [throwOnPluginPubspecError]
- Swap for loop: handle by platform and then by plugin
auto-submit bot pushed a commit that referenced this pull request Mar 7, 2024
…on (#144214)

Part of #137040 and #80374

The flag `throwOnPluginPubspecError` never actually was enabled during production in #79669, but only in some dart plugin tests. And in the tests the case of the error when enabling the flag was not explicitly tested. The only thing tested was, that it is not thrown when disabled.

As explained [here](#142035 (comment)) the only case, where this error could be thrown is, when a dart implementation and a native inline implementation are provided simultaneously. But throwing an exception there is a wrong behavior, as both can coexist in a plugin package, thus in the pubspec file.

Disabling the flag means, that the error is not thrown and not shown to the user. This is the case in production (contrary to the dart plugin tests), which acts like these plugin cases of implementations are just skipped. And this is what actually should be done.

In conclusion, I think the case of coexisting dart and native implementation in pubspec was just overlooked and therefore this error validation was introduced, which is not necessary or even valid.

For more discussion, see: https://discord.com/channels/608014603317936148/608022056616853515/1200194937791205436

  - This is tricky: I already added a test in #142035, which finally complies with the other tests, by removing the flag. So I think it falls in the category of "remove dead code".
  - Theoretically this is a breaking change, as removing / altering some tests. But the flag actually was never valid or used, so IDK. But this may not does fall in the category of "contributed tests".
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from 819638d to 52c9c23 Compare March 8, 2024 09:48
auto-submit bot pushed a commit that referenced this pull request Apr 5, 2024
Part of #137040 and #80374

`possibleResolutions` and `possibleResolutions` used a key containing the platform and the plugin name via `getResolutionKey`. The global list is not necessary and also confusing. It can be avoided by handling the resolution of plugins per platform. This helps to have a more self-contained plugin resolution. This also is necessary to reuse the plugin resolution logic (per platform) for #137040.
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from 39af475 to c4666d9 Compare April 5, 2024 06:58
gilnobrega pushed a commit to gilnobrega/flutter that referenced this pull request Apr 22, 2024
Part of flutter#137040 and flutter#80374

`possibleResolutions` and `possibleResolutions` used a key containing the platform and the plugin name via `getResolutionKey`. The global list is not necessary and also confusing. It can be avoided by handling the resolution of plugins per platform. This helps to have a more self-contained plugin resolution. This also is necessary to reuse the plugin resolution logic (per platform) for flutter#137040.
auto-submit bot pushed a commit that referenced this pull request May 7, 2024
…lution (#145258)

Part of #137040 and #80374

- Extracted getting plugin implementation candidates and the default implementation to its own method
- Extracted resolving the plugin implementation to its own method
- Simplify candidate selection algorithm
- Support overriding inline dart implementation for an app-facing plugin
- Throw error, if a federated plugin implements an app-facing plugin, but also references a default implementation
- Throw error, if a plugin provides an inline implementation, but also references a default implementation
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch 3 times, most recently from 71e0f47 to 738cfcb Compare May 8, 2024 21:14
@Gustl22 Gustl22 force-pushed the 80374-override-native-platform branch from f45fac5 to ad6dfb0 Compare May 13, 2024 12:48
@Gustl22 Gustl22 marked this pull request as ready for review June 30, 2024 10:17
@Gustl22
Copy link
Contributor Author

Gustl22 commented Jun 30, 2024

@stuartmorgan sorry for the delay and the continuous adaption.
In the last three commits I refactored the code so it reflects the fact for distinguishing Dart and nativeOrDart plugin resolution (in contrast to having a native only resolution, which was stated wrong). Also adapted the test for this behavior, which originally was meant to test the default plugin warning only.

…override-native-platform

# Conflicts:
#	packages/flutter_tools/test/general.shard/plugins_test.dart
Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

Minor comments to the changes, but still LGTM with those adjustments.

packages/flutter_tools/lib/src/flutter_plugins.dart Outdated Show resolved Hide resolved
packages/flutter_tools/lib/src/flutter_plugins.dart Outdated Show resolved Hide resolved
@Gustl22
Copy link
Contributor Author

Gustl22 commented Jul 8, 2024

@stuartmorgan Adapted your proposals. Thanks for the review.

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 11, 2024
@auto-submit auto-submit bot merged commit d55a5f9 into flutter:master Jul 11, 2024
129 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 11, 2024
@Gustl22 Gustl22 deleted the 80374-override-native-platform branch July 11, 2024 22:34
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
ditman added a commit to ditman/flutter-packages that referenced this pull request Jul 12, 2024
Roll Flutter from 5103d7574361 to 58068d8ea4ec (42 revisions)

flutter/flutter@5103d75...58068d8

2024-07-12 [email protected] Reland: Move all Linux Moto G4 tests to mokey in staging (flutter/flutter#151654)
2024-07-12 [email protected] Update obsolete comment in InputDecorator test (flutter/flutter#151651)
2024-07-12 [email protected] Fix `TabBar` tab indicator stretch effect (flutter/flutter#150868)
2024-07-12 [email protected] Remove workaround for a bug in dart2wasm (flutter/flutter#151603)
2024-07-12 [email protected] [native_assets] Stop running link hooks in JIT mode (flutter/flutter#151534)
2024-07-12 [email protected] Roll `Switch.adaptive` changes into `CupertinoSwitch` (flutter/flutter#149465)
2024-07-11 34871572 [email protected] Unmark java11 tests as bringup:true (flutter/flutter#151612)
2024-07-11 737941 [email protected] Add link to design document archive (flutter/flutter#151489)
2024-07-11 98614782 auto-submit[bot]@users.noreply.github.com Reverts "Move all Linux Moto G4 tests to mokey in staging (#151608)" (flutter/flutter#151620)
2024-07-11 [email protected] Move all Linux Moto G4 tests to mokey in staging (flutter/flutter#151608)
2024-07-11 [email protected] docimports for API samples (flutter/flutter#151606)
2024-07-11 [email protected] docimports for flutter_goldens, flutter_localizations, flutter_web_plugins, fuchsia_remote_debug_protocol, integration_test (flutter/flutter#151271)
2024-07-11 [email protected] Re-enable debug canvaskit e2e tests. (flutter/flutter#151565)
2024-07-11 57765714 [email protected] Fix: Submenu anchor misaligned with child panel in web (Resolved #151081) (flutter/flutter#151294)
2024-07-11 45459898 [email protected] Replaced {@tool snippet} with {@tool dartpad} in CupertinoTabController (flutter/flutter#151272)
2024-07-11 [email protected] feat: Support overriding native endorsed plugins (flutter/flutter#137040)
2024-07-11 [email protected] expose keyboardType in DropdownMenu #150894 (flutter/flutter#150896)
2024-07-11 [email protected] docimports for flutter_driver (flutter/flutter#151267)
2024-07-11 82763757 [email protected] Add `TimeOfDay` comparison methods (flutter/flutter#151233)
2024-07-11 [email protected] Roll Flutter Engine from 6534fbf3c2c1 to 36dccf7bb25c (2 revisions) (flutter/flutter#151577)
2024-07-11 [email protected] Roll Flutter Engine from 1c23c8f64076 to 6534fbf3c2c1 (3 revisions) (flutter/flutter#151572)
2024-07-11 [email protected] Use correct locale for `CupertinoDatePicker` weekday (flutter/flutter#151494)
2024-07-10 [email protected] doc imports for enum values (flutter/flutter#151548)
2024-07-10 34871572 [email protected] Reland "Upgrade template Gradle, App AGP, Module AGP, and Kotlin versions, and tests"... but no longer upgrade module AGP version (flutter/flutter#151433)
2024-07-10 [email protected] Roll Packages from 14341d1 to ea35fc6 (16 revisions) (flutter/flutter#151556)
2024-07-10 [email protected] [CupertinoActionSheet] Fix padding and font size of buttons (flutter/flutter#151199)
2024-07-10 [email protected] Roll Flutter Engine from db2b45bea2c0 to 1c23c8f64076 (2 revisions) (flutter/flutter#151550)
2024-07-10 [email protected] Add docImports for flutter_test references (flutter/flutter#151175)
2024-07-10 [email protected] Mention not @-mentioning people in commit messages in tree hygiene (flutter/flutter#151487)
2024-07-10 [email protected] Roll Flutter Engine from 371db85f33d7 to db2b45bea2c0 (8 revisions) (flutter/flutter#151522)
2024-07-10 [email protected] fix heading level absorption, diagnostics; add tests and an a11y use-case (flutter/flutter#151421)
2024-07-10 [email protected] Roll Flutter Engine from 9d943eb2b37a to 371db85f33d7 (3 revisions) (flutter/flutter#151505)
2024-07-10 [email protected] Roll Flutter Engine from d3269d5855a7 to 9d943eb2b37a (5 revisions) (flutter/flutter#151495)
2024-07-09 [email protected] Update doc of `SemanticsProperties.identifier` (flutter/flutter#149915)
2024-07-09 [email protected] Clean up leaky test. (flutter/flutter#151131)
2024-07-09 137456488 [email protected] Roll pub packages (flutter/flutter#151492)
2024-07-09 32538273 [email protected] testAdd tests for stepper.controls_builder.0.dart (flutter/flutter#150669)
2024-07-09 [email protected] Add Semantics Property `linkUrl` (flutter/flutter#150639)
2024-07-09 [email protected] Roll Flutter Engine from 4a2ac0e51a8f to d3269d5855a7 (1 revision) (flutter/flutter#151488)
2024-07-09 34871572 [email protected] Link engine docs on AS setup in flutter/flutter docs on engine contributor setup (flutter/flutter#151481)
2024-07-09 [email protected] Roll Flutter Engine from 69075e7e87d4 to 4a2ac0e51a8f (21 revisions) (flutter/flutter#151482)
2024-07-09 [email protected] Fix Material 3 `Dialog` default background color (flutter/flutter#151400)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 12, 2024
Gustl22 added a commit to Gustl22/flutter-website that referenced this pull request Jul 14, 2024
auto-submit bot pushed a commit that referenced this pull request Aug 22, 2024
Clarify that a referenced default package must also be a plugin package (one, which provides a pluginClass or a dartPluginClass).

Fixes #152037
More precisely #152037 (comment).
Introduced in #137040
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 tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
5 participants