Skip to content

Conversation

@amirh
Copy link
Contributor

@amirh amirh commented Sep 17, 2019

Description

Before this change, having an Android app depend on a plugin that has no android implementation resulted in a Gradle build failure.

This scenario is likely to become more common if we're enabling federated plugins, as the package implementing just the desktop implementation of a plugin won't have an Android implementation.

This changes the Gradle plugin to not try to build any plugins that doesn't have an android/build.gradle file.

Related Issues

#39657

Tests

I added the following tests:

  • Integration test building an apk for a Flutter app that depends on an iOS only plugin.

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 Sep 17, 2019
Properties allPlugins = readPropertiesIfExist(pluginsFile)
Properties androidPlugins = new Properties()
allPlugins.each { name, path ->
File editableAndroidProject = new File(path, 'android' + File.pathSeparator + 'build.gradle')
Copy link

Choose a reason for hiding this comment

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

nit: File.separator instead of File.pathSeparator. This should fix the tests that are failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, thanks.

allPlugins.each { name, path ->
File editableAndroidProject = new File(path, 'android' + File.pathSeparator + 'build.gradle')
if (editableAndroidProject.exists()) {
project.logger.error("$editableAndroidProject exists adding $name -> $path")
Copy link

Choose a reason for hiding this comment

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

nit: is this an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops

Copy link

@blasten blasten left a comment

Choose a reason for hiding this comment

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

LGTM

Properties androidPlugins = new Properties()
allPlugins.each { name, path ->
File editableAndroidProject = new File(path, 'android' + File.separator + 'build.gradle')
if (editableAndroidProject.exists()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we might want to print some sort of warning here. Assuming that we can fix the platform specific .flutter-plugins issue, this would still be an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what I can do as part of this CL...?

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Print a warning when? both cases (having an android/build.gradle and not having it are legit...)

Copy link
Contributor

Choose a reason for hiding this comment

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

print a warning when it is missing. You're right for now that isn't an error because it is unavoidable. Maybe leave a todo so we can revisit it in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@amirh amirh force-pushed the gradle_exclude_non_android_plugins branch from 81da48d to 8026b0e Compare September 18, 2019 20:22
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

@amirh amirh merged commit 4e108b6 into flutter:master Sep 18, 2019
@amirh amirh deleted the gradle_exclude_non_android_plugins branch September 18, 2019 23:42
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
Before this change, having an Android app depend on a plugin that has no android implementation resulted in a Gradle build failure.

This scenario is likely to become more common if we're enabling federated plugins, as the package implementing just the desktop implementation of a plugin won't have an Android implementation.

This changes the Gradle plugin to not try to build any plugins that doesn't have an android/build.gradle file.
stuartmorgan-g added a commit to stuartmorgan-g/flutter-desktop-embedding that referenced this pull request Sep 30, 2019
As of flutter/flutter#40640 these should no
longer be necessary.

Also fixes a typo in a plugin pubspec.yaml.
stuartmorgan-g added a commit to google/flutter-desktop-embedding that referenced this pull request Oct 1, 2019
As of flutter/flutter#40640 these should no
longer be necessary.

Also fixes a typo in a plugin pubspec.yaml.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 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.

5 participants