Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Mar 14, 2025

Creates a FlutterPluginUtils.kt object to contain static methods used by the Flutter Gradle plugin, and moves over (porting them from Groovy to Kotlin)

  1. Methods that were already static in FlutterPlugin.
  2. Methods that were not static but were only accessing the project member. These methods were made static by changing their signature to take the project as an argument.

This doesn't get all of the methods of type 2. Specifically, I'm planning on leaving functions that interact with the Android Gradle plugin for a different PR, as this PR was getting long enough and those pieces will be a lot more brittle anyways (so I'd like to be able to revert them on their own).

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 Mar 14, 2025
@gmackall gmackall marked this pull request as ready for review March 17, 2025 20:03
@gmackall gmackall requested review from a team and ash2moon March 17, 2025 20:03
// minimum version does support the replacement we can replace by changing a single line.
@JvmStatic
@Suppress("DEPRECATION")
internal fun capitalize(string: String): String = string.capitalize()
Copy link
Member Author

Choose a reason for hiding this comment

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

Open to removing this, I meant to actually make this the suggested replacement but we can't use the syntax because of our min version constraints.

* A collection of static utility functions used by the Flutter Gradle Plugin.
*/
object FlutterPluginUtils {
// Gradle properties.
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are used in other files can you add a pointer to those files? If they are used only by referencing constants can you say that in the kt doc?

Copy link
Member Author

@gmackall gmackall Mar 17, 2025

Choose a reason for hiding this comment

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

Hmm intellisense should work here for finding references, so I would prefer if we instead relied on that here (it even works cross groovy boundary). Does that make sense to you?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can talk about it in person but do think that a comment is correct. This is one of the issues with using strings. Yes tooling can find the same string in many places in code. The documentation defines where we intend the strings to match.

* Kotlin (settings.gradle.kts). This is the same behavior as Gradle 8.5.
*/
@JvmStatic
internal fun settingsGradleFile(project: Project): File {
Copy link
Contributor

Choose a reason for hiding this comment

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

On this an other methods taking in a project is a large scope/object. Consider if you can reduce what is passed in to variables that are more restricted.

For example in this method I think you can pass project.projectDir and project.logger and still have full functionality.

I think a bunch of the methods that use properties will need to stay the same here are some others I think can have reduced input scope.

  • buildGradleFile
  • shouldConfigureFlutterTask
  • pluginSupportsAndroidPlatform

Copy link
Member Author

@gmackall gmackall Mar 17, 2025

Choose a reason for hiding this comment

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

Minimized the scope of buildGradleFile and settingsGradleFile, and changed the names.

I haven't minimized the scope of the others, because I feel like it starts to leak some of the implementation out of the methods themselves

e.g. shouldConfigureFlutterTask could take a taskNames: List<String> instead of a project, but I'm not sure it's immediately obvious to a caller that you get that list with project.gradle.startParameter.taskNames, or that whether a plugin project supports Android is a function of it's projectDir.

But can reconsider if you feel strongly that those methods should also have their scope minimized

Copy link
Contributor

Choose a reason for hiding this comment

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

If there is a good reason to take a project that is fine with me. Thank you for taking a pass to see if we could reduce scope.

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 17, 2025

autosubmit label was removed for flutter/flutter/165239, because - The status or check suite Windows framework_tests_libraries has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2025
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 17, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Mar 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 26, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 27, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 28, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 30, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 31, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 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 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025
romanejaquez pushed a commit to romanejaquez/flutter that referenced this pull request Aug 14, 2025
…erPlugin` there (flutter#165239)

Creates a `FlutterPluginUtils.kt` object to contain static methods used
by the Flutter Gradle plugin, and moves over (porting them from Groovy
to Kotlin)
1. Methods that were already static in `FlutterPlugin`.
2. Methods that were not static but were only accessing the `project`
member. These methods were made static by changing their signature to
take the project as an argument.

This doesn't get all of the methods of type 2. Specifically, I'm
planning on leaving functions that interact with the Android Gradle
plugin for a different PR, as this PR was getting long enough and those
pieces will be a lot more brittle anyways (so I'd like to be able to
revert them on their own).

## 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].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] 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.
- [ ] 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]>
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.

3 participants