mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
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:
parent
f4b8f44d4a
commit
a951793431
@ -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'
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user