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 <chemerisuk@users.noreply.github.com>
This commit is contained in:
エリス 2020-01-16 08:40:54 +09:00 committed by GitHub
parent f4b8f44d4a
commit a951793431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -27,7 +27,28 @@ buildscript {
} }
dependencies { dependencies {
apply from: '../CordovaLib/cordova.gradle'
classpath 'com.android.tools.build:gradle:3.3.0' 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')) { if (hasProperty('postBuildExtras')) {
postBuildExtras() postBuildExtras()
} }
if (cdvHelpers.getConfigPreference('GoogleServicesEnabled', 'false').toBoolean()) {
apply plugin: 'com.google.gms.google-services'
}

View File

@ -48,6 +48,10 @@ Version[] getAvailableBuildTools() {
.sort { a, b -> a.isHigherThan(b) ? -1 : 1 } .sort { a, b -> a.isHigherThan(b) ? -1 : 1 }
} }
Boolean isVersionValid(version) {
return !(new Version(version)).isEqual('0.0.0')
}
String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) { String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) {
def availableBuildToolsVersions def availableBuildToolsVersions
try { try {