[go: nahoru, domu]

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

Add .flutter-plugins-dependencies to the project, which contains the app's plugin dependency graph #45379

Merged
merged 10 commits into from
Nov 22, 2019

Conversation

blasten
Copy link
@blasten blasten commented Nov 22, 2019

Description

Creates a .flutter-plugins-dependencies which contains the plugin dependency graph from pub. Then, Gradle reads this file to reconstruct the dependencies.

Related Issues

Fixes #45188

Tests

I added the following tests: unit test

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • 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 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

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added team Infra upgrades, team productivity, code health, technical debt. See also team: labels. tool Affects the "flutter" command-line tool. See also t: labels. labels Nov 22, 2019
@blasten
Copy link
Author
blasten commented Nov 22, 2019

@tvolkert This is the last thing we need to complete the plugin migration to the new embedding.

Copy link
Member
@xster xster left a comment

Choose a reason for hiding this comment

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

Implementation LGTM % tests

packages/flutter_tools/gradle/flutter.gradle Outdated Show resolved Hide resolved
packages/flutter_tools/gradle/flutter.gradle Outdated Show resolved Hide resolved
packages/flutter_tools/lib/src/plugins.dart Outdated Show resolved Hide resolved
@@ -265,29 +292,52 @@ List<Plugin> findPlugins(FlutterProject project) {
return plugins;
}

/// Returns true if .flutter-plugins has changed, otherwise returns false.
/// Returns true if .flutter-plugins or .flutter-plugins-dependencies have changed,
Copy link
Member

Choose a reason for hiding this comment

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

Ultra-nit, // instead of ///

It's not a full dart doc since it only partially describes this function (its return value). If ever this becomes a public method, it's up to that person to write a proper dart doc

Copy link
Author

Choose a reason for hiding this comment

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

/// makes the comment show up in the IDE.

@jonahwilliams
Copy link
Member

Can we put this somewhere other than the project root?

@blasten
Copy link
Author
blasten commented Nov 22, 2019

@jonahwilliams this is intended to be used by all platforms. However, this PR only implements the functionality for Android.

@xster
Copy link
Member
xster commented Nov 22, 2019

@jonahwilliams It represents a conceptual inter-dependency between plugins for all platforms. If we intend to have a different pub dependency per platform, then it might make sense to have multiple such files.

@jonahwilliams
Copy link
Member

@blasten and I spoke offline. It may need to be moved when we do platform specific plugins but I'm okay with it being here for now

@blasten blasten changed the title Support plugin platform dependencies on Android Add .flutter-plugins-dependencies to the project, which contains the app's plugin dependency graph Nov 22, 2019
@xster
Copy link
Member
xster commented Nov 22, 2019

tests LGTM

Copy link
Member
@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.

Does this handle cyclic dependencies? For example, plugin a and b depend on each other.

@blasten
Copy link
Author
blasten commented Nov 22, 2019

@jonahwilliams Here's the output (when there's a cycle):

$ flutter build apk --target-platform android-arm 
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* What went wrong:                                                      
Circular dependency between the following tasks:                        
:camera:generateReleaseRFile                                            
+--- :camera:generateReleaseRFile (*)                                   
\--- :path_provider:generateReleaseRFile                                
     +--- :camera:generateReleaseRFile (*)                              
     \--- :path_provider:generateReleaseRFile (*)                       
                                                                        
(*) - details omitted (listed previously)                               
                                                                        
                                                                        
* Try:                                                                  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
                                                                        
* Get more help at https://help.gradle.org                              
                                                                        
BUILD FAILED in 828ms                                                   
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       1.4s
Gradle task assembleRelease failed with exit code 1

@@ -250,11 +275,13 @@ Plugin _pluginFromPubspec(String name, Uri packageRoot) {
return null;
}
final String packageRootPath = fs.path.fromUri(packageRoot);
final YamlMap dependencies = pubspec['dependencies'];
Copy link
Member

Choose a reason for hiding this comment

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

This will capture direct dependencies, but not transitive dependencies - is this an issue?. Consider:

plugin A depends on package 1
package 1 depends on plugin B

.flutter-plugins will contain plugin A/plugin B while the dependencies file will not link them.

Copy link
Member

Choose a reason for hiding this comment

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

From offline discussion, this isn't a supported use case - and that platform code cannot depend on eachother. Therefore it doesn't seem like the gradle task ordering needs to take this into consideration

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
Copy link
Member
@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

Copy link
Member
@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

Is there an integration test for this using a plugin that needs this feature?

Copy link
Member
@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

lgtm w/ question

packages/flutter_tools/gradle/flutter.gradle Show resolved Hide resolved
@matthew-carroll
Copy link
Contributor

@blasten @xster I ran my maps plugin migration branch against this version of the framework and it appears to correctly link the Android code. I no longer need to use reflection. Good job :)

@blasten blasten merged commit b6e9200 into flutter:master Nov 22, 2019
@blasten blasten deleted the plugin_platform_dependencies branch November 22, 2019 23:02
@zanderso
Copy link
Member

@blasten @xster I ran my maps plugin migration branch against this version of the framework and it appears to correctly link the Android code. I no longer need to use reflection. Good job :)

Is it possible to extract an integration test from something in there?

@blasten
Copy link
Author
blasten commented Nov 25, 2019

@zanderso definitely. Once, the Google maps plugin is published, I can add an integration test. I will file an issue.

@matthew-carroll
Copy link
Contributor

FYI - I won't be publishing the migration because I was just attempting to prove that Lifecycle works with plugins. So we'll be waiting on the ecosystem team to do the public migration.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
team Infra upgrades, team productivity, code health, technical debt. See also team: 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.

[android] Platform code from transitive plugin dependencies isn't linked into the build
7 participants