Skip to content

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

Merged
blasten merged 10 commits into
flutter:masterfrom
blasten:plugin_platform_dependencies
Nov 22, 2019
Merged

blasten merged 10 commits into
flutter:masterfrom
blasten:plugin_platform_dependencies

Conversation

@blasten

@blasten blasten commented Nov 22, 2019 •

Copy link
Copy Markdown

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 c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Nov 22, 2019
@blasten

blasten commented Nov 22, 2019

Copy link
Copy Markdown
Author

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

@xster xster left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Implementation LGTM % tests

Comment thread packages/flutter_tools/gradle/flutter.gradle Outdated
Comment thread packages/flutter_tools/gradle/flutter.gradle Outdated
Comment thread packages/flutter_tools/lib/src/plugins.dart Outdated

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

Can we put this somewhere other than the project root?

@blasten

blasten commented Nov 22, 2019

Copy link
Copy Markdown
Author

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

@xster

xster commented Nov 22, 2019

Copy link
Copy Markdown
Member

@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.

@blasten
blasten force-pushed the plugin_platform_dependencies branch from 9be0ea5 to 4ad2762 Compare November 22, 2019 17:22
@jonahwilliams

Copy link
Copy Markdown
Contributor

@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 force-pushed the plugin_platform_dependencies branch from f8e4bb2 to 44f9aee Compare November 22, 2019 18:18
@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

xster commented Nov 22, 2019

Copy link
Copy Markdown
Member

tests LGTM

@jonahwilliams jonahwilliams left a comment

Copy link
Copy Markdown
Contributor

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

blasten commented Nov 22, 2019 •

Copy link
Copy Markdown
Author

@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

Comment thread packages/flutter_tools/lib/src/plugins.dart Outdated
return null;
}
final String packageRootPath = fs.path.fromUri(packageRoot);
final YamlMap dependencies = pubspec['dependencies'];

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@jonahwilliams jonahwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@zanderso zanderso left a comment

Copy link
Copy Markdown
Member

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?

Comment thread packages/flutter_tools/gradle/flutter.gradle
Comment thread packages/flutter_tools/test/general.shard/plugins_test.dart Outdated
@blasten
blasten force-pushed the plugin_platform_dependencies branch from f585bae to ccd5d68 Compare November 22, 2019 21:37
@blasten
blasten requested a review from zanderso November 22, 2019 21:38

@zanderso zanderso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm w/ question

Comment thread packages/flutter_tools/gradle/flutter.gradle
@matthew-carroll

Copy link
Copy Markdown
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
Copy Markdown
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

blasten commented Nov 25, 2019

Copy link
Copy Markdown
Author

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

@matthew-carroll

Copy link
Copy Markdown
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

c: contributor-productivity Team-specific productivity, code health, technical debt. 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