-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 support for EnableGoogleServicesPlugin #438
Conversation
Codecov Report
@@ Coverage Diff @@
## master #438 +/- ##
=======================================
Coverage 44.16% 44.16%
=======================================
Files 17 17
Lines 1698 1698
Branches 314 314
=======================================
Hits 750 750
Misses 948 948 Continue to review full report at Codecov.
|
@@ -322,3 +323,7 @@ for (def func : cdvPluginPostBuildExtras) { | |||
if (hasProperty('postBuildExtras')) { | |||
postBuildExtras() | |||
} | |||
|
|||
if (cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) { | |||
apply plugin: 'com.google.gms.google-services' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chemerisuk I've had to make this line:
apply plugin: 'com.google.gms.googleservices.GoogleServicesPlugin'
because the class must be used instead of id(string) to be able to apply plugin from non-root gradle file. I haven't tested the PR yet but I'm assuming the reason you are using the ID is because it is a root gradle file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because this is the root Gradle file. Worked fine on my side.
For testing I commented changes from cordova-support-google-services and inserted PR code manually. Then rebuilt the project and tried to start (btw google services v15 trigger error at runtime, if ‘google.services’ was not processed properly while previously it was build time error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@infil00p wanna take a look at this? |
@@ -30,6 +30,7 @@ buildscript { | |||
|
|||
dependencies { | |||
classpath 'com.android.tools.build:gradle:3.1.0' | |||
classpath 'com.google.gms:google-services:3.2.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to wrap this classpath
in an if condition, like how the apply is done?
It would be nice to minimize the amount of downloading of build related libraries if they are not needed.
if (cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) {
classpath 'com.google.gms:google-services:3.2.1'
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the object cdvHelpers
is not available at the dependency scope. Project build failed with the error:
Could not get unknown property 'cdvHelpers' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Happens when I apply the changes you suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chemerisuk Yes, it seems cordova.gradle
would need to be applied within the scope so it becomes available.
dependencies {
apply from: '../CordovaLib/cordova.gradle'
classpath 'com.android.tools.build:gradle:3.1.0'
if(cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) {
println 'Adding classpath "com.google.gms:google-services:3.2.1"'
classpath 'com.google.gms:google-services:3.2.1'
}
}
@dpogue Would you know off-hand if something like this would be problematic? The cordova.gradle
content seems to be only helper methods. Adding it seems to solve the desire to make the classpaths conditional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know much about Gradle, and my experience consists mostly of swearing at it.
I believe you're correct that cordova.gradle
is helper methods, but I don't know anything about scoping or when it's safe to import (apply?) stuff.
@chemerisuk I would like to try and get this PR updated and merged before the upcoming major release. If possible, could you rebase the PR with master and fix the conflicting files? Also, as I proposed in a previous comment, could you wrap the The code snippet that I provided in a previous comment will work as intended. You will need to add the Lastly, since this PR was created awhile back, I had some other nice to have that could be applied with this PR, if you can do this, it will be great. If you do not have the time, I can do it in a second PR if needed.
I recall that the Actually, with this PR and the
Please let me know if you can do this or if I should create a new PR based on your changes and apply the additional changes. |
@chemerisuk I went ahead and created a second PR to be able to quickly fix the merge conflicts as well as apply the additional change request that I posted. This PR will close as soon as my PR is merged. Since I cherry-picked your commit in, it will still contain your contribution. Thank you for your contribution and sorry that it took this long to merge in your commit. |
@erisu thanks for the update. Unfortunately my current environment is a bit different now, so it will be hard to test those changes properly. So please go ahead with the PR, it's a long waited one. If you have time could you post a link to a compilation problem at |
@chemerisuk I do not have an issue ticket regarding the issues I described with the But, I pushed a PR that briefly explains changes to the plugin that will be needed to use these new preference options without having a build issue. It removed the enable google services plugin dependency. The issue the plugin had was a conflict with the new preferences enabling the Google Services in the buildscript while the enable google services plugin dependency did the same thing. Here is the PR: phonegap/phonegap-plugin-push#2873 It is currently labeled as |
Platforms affected
Android
What does this PR do?
@macdonst proposed to add new preference to the platform, that runs google services plugin.
What testing has been done on this change?
Checked locally.
Checklist