From 5059756cda75017090e346573ed47a1bbb13b7cb Mon Sep 17 00:00:00 2001 From: Maksim Chemerisuk Date: Wed, 25 Apr 2018 21:29:50 +0300 Subject: [PATCH 1/6] Add support for EnableGoogleServicesPlugin --- bin/templates/project/app/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index ea26195fc6..f5245f9fdb 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -28,6 +28,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.3.0' + classpath 'com.google.gms:google-services:3.2.1' } } @@ -356,3 +357,7 @@ for (def func : cdvPluginPostBuildExtras) { if (hasProperty('postBuildExtras')) { postBuildExtras() } + +if (cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) { + apply plugin: 'com.google.gms.google-services' +} From f8ad1e076c1129208eed51ed4881df48e0239c9b Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 Jan 2020 07:19:51 +0900 Subject: [PATCH 2/6] chore: wrap google-services classpath with EnableGoogleServicesPlugin flag --- bin/templates/project/app/build.gradle | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index f5245f9fdb..d23562a380 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -27,8 +27,15 @@ buildscript { } dependencies { + apply from: '../CordovaLib/cordova.gradle' + classpath 'com.android.tools.build:gradle:3.3.0' - classpath 'com.google.gms:google-services:3.2.1' + + 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' + } } } From 4defdb02ea4921af186bfdb08d178e591cc3cfa4 Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 Jan 2020 07:20:55 +0900 Subject: [PATCH 3/6] chore: bump google-services version to 4.2.0 --- bin/templates/project/app/build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index d23562a380..f3ae9512fd 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -32,9 +32,8 @@ buildscript { classpath 'com.android.tools.build:gradle:3.3.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' + println 'Adding classpath "com.google.gms:google-services:4.2.0"' + classpath 'com.google.gms:google-services:4.2.0' } } } From 275496d4d9dd1fbf76441c4f4d4d681e7aed5818 Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 Jan 2020 08:22:17 +0900 Subject: [PATCH 4/6] chore: add GoogleServicesPluginVersion support --- bin/templates/project/app/build.gradle | 18 ++++++++++++++++-- framework/cordova.gradle | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index f3ae9512fd..aeea381641 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -32,8 +32,22 @@ buildscript { classpath 'com.android.tools.build:gradle:3.3.0' if(cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) { - println 'Adding classpath "com.google.gms:google-services:4.2.0"' - classpath 'com.google.gms:google-services:4.2.0' + 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('GoogleServicesPluginVersion', 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 } } } diff --git a/framework/cordova.gradle b/framework/cordova.gradle index 5a06ea7487..0fb476c29c 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 { From 3af5a089ccbc27371abb52cd6fcb1d186c4e08e5 Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 Jan 2020 11:29:30 +0900 Subject: [PATCH 5/6] chore: shorten preference names --- bin/templates/project/app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index aeea381641..6ecc16406f 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -31,14 +31,14 @@ buildscript { classpath 'com.android.tools.build:gradle:3.3.0' - if(cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) { + if(cdvHelpers.getConfigPreference('GoogleServicesEnable', '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('GoogleServicesPluginVersion', 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 @@ -378,6 +378,6 @@ if (hasProperty('postBuildExtras')) { postBuildExtras() } -if (cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) { +if (cdvHelpers.getConfigPreference('GoogleServicesEnable', 'false').toBoolean()) { apply plugin: 'com.google.gms.google-services' } From 8d069bc224bc6d22649f0dc6a86ae2b4cd309dbb Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 Jan 2020 23:49:25 +0900 Subject: [PATCH 6/6] chore: fix preference name tense --- bin/templates/project/app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/templates/project/app/build.gradle b/bin/templates/project/app/build.gradle index 6ecc16406f..47cef0d169 100644 --- a/bin/templates/project/app/build.gradle +++ b/bin/templates/project/app/build.gradle @@ -31,7 +31,7 @@ buildscript { classpath 'com.android.tools.build:gradle:3.3.0' - if(cdvHelpers.getConfigPreference('GoogleServicesEnable', 'false').toBoolean()) { + if(cdvHelpers.getConfigPreference('GoogleServicesEnabled', 'false').toBoolean()) { String defaultGoogleServiceVersion = '4.2.0' /** @@ -378,6 +378,6 @@ if (hasProperty('postBuildExtras')) { postBuildExtras() } -if (cdvHelpers.getConfigPreference('GoogleServicesEnable', 'false').toBoolean()) { +if (cdvHelpers.getConfigPreference('GoogleServicesEnabled', 'false').toBoolean()) { apply plugin: 'com.google.gms.google-services' }