This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-android.git


The following commit(s) were added to refs/heads/master by this push:
     new a951793  feat: add google services support (#893)
a951793 is described below

commit a95179343142318ee64a043f5b5a03063d7b016d
Author: エリス <[email protected]>
AuthorDate: Thu Jan 16 08:40:54 2020 +0900

    feat: add google services support (#893)
    
    * feat: Add support for GoogleServicesEnabled preference option
    * fix: wrap google-services classpath with GoogleServicesEnabled flag
    * chore: bump google-services version to 4.2.0
    * feat: Add support for GoogleServicesVersion preference option
    
    Co-authored-by: Maksim Chemerisuk <[email protected]>
---
 bin/templates/project/app/build.gradle | 25 +++++++++++++++++++++++++
 framework/cordova.gradle               |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/bin/templates/project/app/build.gradle 
b/bin/templates/project/app/build.gradle
index ea26195..47cef0d 100644
--- a/bin/templates/project/app/build.gradle
+++ b/bin/templates/project/app/build.gradle
@@ -27,7 +27,28 @@ buildscript {
     }
 
     dependencies {
+        apply from: '../CordovaLib/cordova.gradle'
+
         classpath 'com.android.tools.build:gradle:3.3.0'
+
+        if(cdvHelpers.getConfigPreference('GoogleServicesEnabled', 
'false').toBoolean()) {
+            String defaultGoogleServiceVersion = '4.2.0'
+
+            /**
+             * Fetches the user's defined Google Services Plugin Version from 
config.xml.
+             * If the version is not set or invalid, it will default to the 
${defaultGoogleServiceVersion}
+             */
+            String googleServicesVersion = 
cdvHelpers.getConfigPreference('GoogleServicesVersion', 
defaultGoogleServiceVersion)
+            if(!cdvHelpers.isVersionValid(googleServicesVersion)) {
+                println("The defined Google Services plugin version 
(${googleServicesVersion}) does not appear to be a valid version. Falling back 
to version: ${defaultGoogleServiceVersion}.")
+                googleServicesVersion = defaultGoogleServiceVersion
+            }
+
+            // Create the Google Services classpath and set it.
+            String googleServicesClassPath = 
"com.google.gms:google-services:${googleServicesVersion}"
+            println "Adding classpath: ${googleServicesClassPath}"
+            classpath googleServicesClassPath
+        }
     }
 }
 
@@ -356,3 +377,7 @@ for (def func : cdvPluginPostBuildExtras) {
 if (hasProperty('postBuildExtras')) {
     postBuildExtras()
 }
+
+if (cdvHelpers.getConfigPreference('GoogleServicesEnabled', 
'false').toBoolean()) {
+    apply plugin: 'com.google.gms.google-services'
+}
diff --git a/framework/cordova.gradle b/framework/cordova.gradle
index 5a06ea7..0fb476c 100644
--- a/framework/cordova.gradle
+++ b/framework/cordova.gradle
@@ -48,6 +48,10 @@ Version[] getAvailableBuildTools() {
         .sort { a, b -> a.isHigherThan(b) ? -1 : 1 }
 }
 
+Boolean isVersionValid(version) {
+    return !(new Version(version)).isEqual('0.0.0')
+}
+
 String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
     def availableBuildToolsVersions
     try {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to