Skip to content

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented Oct 17, 2020

Description

The android (and ios) directories are incorrectly created during the plugin registrant generation step. After a flutter create the only thing in android is GeneratedPluginRegistrant.java and the only thing in ios is GeneratedPluginRegistrant.{h,m}.

if (appManifestFile == null || !appManifestFile.existsSync()) {
return AndroidEmbeddingVersion.v1;
}

is guarded by a check if the android directory exists (it did, but only contained GeneratedPluginRegistrant.java) and returned v1 because the app manifest didn't exist, and caused a confusing warning.

Avoid creating platform directories during the plugin registrant generation step, which bypasses the Android embedding version warning.

  • For flutter create -t app, generate the directories/plugins only for the requested platforms.
  • For other commands that regenerate various files (plugins, create missing template files, etc), only do so in existing platform directories.
  • Replace the checkProject concept by explicitly requesting platforms based on user flags, existing directories, and whether features are on, as appropriate.

Related Issues

Fixes #67346
Fixes #60023

Related:
#31342
#59507

Tests

Added --platform app create tests. Update existing plugin, project, cocoapods tests which already exercise these code paths.

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.

@jmagman jmagman self-assigned this Oct 17, 2020
@flutter-dashboard flutter-dashboard bot added tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Oct 17, 2020
@google-cla google-cla bot added the cla: yes label Oct 17, 2020
Copy link
Member Author

Choose a reason for hiding this comment

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

checkProjects was never actually passed in, so was always false.

@jmagman jmagman force-pushed the platform-generation branch 2 times, most recently from 74728a1 to 40b62e1 Compare October 17, 2020 02:37
Comment on lines +694 to +692
Copy link
Member Author

Choose a reason for hiding this comment

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

These templateContext values are only true if the corresponding feature is on.

web: featureFlags.isWebEnabled && platforms.contains('web'),
linux: featureFlags.isLinuxEnabled && platforms.contains('linux'),
macos: featureFlags.isMacOSEnabled && platforms.contains('macos'),
windows: featureFlags.isWindowsEnabled && platforms.contains('windows'),

@jmagman jmagman force-pushed the platform-generation branch 3 times, most recently from ae86c5c to 97a6cac Compare October 17, 2020 18:34
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to app does not include desktop or web by default

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to app does not include desktop or web by default

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to app does not include desktop or web by default

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to plugin does not include desktop or web by default

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to plugin does not include desktop or web by default

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to plugin does not include desktop or web by default

Comment on lines +240 to +241
Copy link
Member Author

Choose a reason for hiding this comment

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

@stuartmorgan I moved the TODOs scattered around to reexamine the logic to this spot. Let me know if you want it somewhere else, or need it reworded.

Copy link
Contributor

Choose a reason for hiding this comment

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

The TODO was really about figuring out what checkProjects was for and why we would ever want the checkProjects = false behavior since it seemed really bizarre, so it looks like this PR obsoletes it. But I can clean it up later.

@jmagman jmagman marked this pull request as ready for review October 19, 2020 16:18
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

Only small nits, seems like a good change.

Why were we getting the warning about the android embedding though? even if the project wasn't there or was partially created, we should probably default to not showing a warning

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment misleading now? it also re-generates for desktop+web projects if they exist

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, reworded.

@jmagman
Copy link
Member Author

jmagman commented Oct 19, 2020

Why were we getting the warning about the android embedding though? even if the project wasn't there or was partially created, we should probably default to not showing a warning

Before this PR the android (and ios directories) were incorrectly created during the plugin registrant generation step. After a flutter create the only thing in android was GeneratedPluginRegistrant.java and the only thing in ios was GeneratedPluginRegistrant.{h,m}.

if (appManifestFile == null || !appManifestFile.existsSync()) {
return AndroidEmbeddingVersion.v1;
}

is guarded by a check if the android directory exists (it did, but only contained GeneratedPluginRegistrant.java) and returned v1 because the app manifest didn't exist.

After this PR, the android directory is not created during the during the plugin registrant generation step, so the embedding version is never checked.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM with nits

@jmagman jmagman force-pushed the platform-generation branch from 97a6cac to ae8f1b9 Compare October 19, 2020 19:05
Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

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

LGTM!

@jmagman jmagman merged commit 5e17a24 into flutter:master Oct 19, 2020
@jmagman jmagman deleted the platform-generation branch October 19, 2020 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flutter create --platforms web creates incorrect error [flutter_tools] [Project.ensureReadyForPlatformSpecificTooling] should be better documented

4 participants