Skip to content

Commit 917b463

Browse files
committed
chore: add GoogleServicesPluginVersion support
1 parent 1f355bd commit 917b463

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

bin/templates/project/app/build.gradle

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,22 @@ buildscript {
3232
classpath 'com.android.tools.build:gradle:3.3.0'
3333

3434
if(cdvHelpers.getConfigPreference('EnableGoogleServicesPlugin', 'false').toBoolean()) {
35-
println 'Adding classpath "com.google.gms:google-services:4.1.0"'
35+
String defaultGoogleServiceVersion = '4.2.0'
36+
37+
/**
38+
* Fetches the user's defined Google Services Plugin Version from config.xml.
39+
* If the version is not set or invalid, it will default to the ${defaultGoogleServiceVersion}
40+
*/
41+
String googleServicesVersion = cdvHelpers.getConfigPreference('GoogleServicesPluginVersion', defaultGoogleServiceVersion)
42+
if(!cdvHelpers.isVersionValid(googleServicesVersion)) {
43+
println("The defined Google Services plugin version (${googleServicesVersion}) does not appear to be a valid version. Falling back to version: ${defaultGoogleServiceVersion}.")
44+
googleServicesVersion = defaultGoogleServiceVersion
45+
}
3646

37-
classpath 'com.google.gms:google-services:4.1.0'
47+
// Create the Google Services classpath and set it.
48+
String googleServicesClassPath = "com.google.gms:google-services:${googleServicesVersion}"
49+
println "Adding classpath: ${googleServicesClassPath}"
50+
classpath googleServicesClassPath
3851
}
3952
}
4053
}

framework/cordova.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Version[] getAvailableBuildTools() {
4848
.sort { a, b -> a.isHigherThan(b) ? -1 : 1 }
4949
}
5050

51+
Boolean isVersionValid(version) {
52+
return !(new Version(version)).isEqual('0.0.0')
53+
}
54+
5155
String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
5256
def availableBuildToolsVersions
5357
try {

0 commit comments

Comments
 (0)