Browse Source

Ensure correct google-services.json is supplied vol.2

pull/63/head
Ezerous 6 years ago
parent
commit
c22fe9faef
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 26
      app/build.gradle

26
app/build.gradle

@ -41,20 +41,30 @@ android {
} }
} }
def firebaseReleaseProjectId = "mthmmy-release-3aef0"
tasks.whenTaskAdded { task -> tasks.whenTaskAdded { task ->
if (task.name.contains("assembleRelease")) { if (task.name.contains("assembleRelease")) {
task.getDependsOn().add({ task.getDependsOn().add({
def inputFile = new File("google-services.json") def googleServicesFile = new File("app/src/release/google-services.json")
def json = new JsonSlurper().parseText(inputFile.text) if(googleServicesFile.exists()){
if (json.project_info.project_id != "mthmmy-release-3aef0") def json = new JsonSlurper().parseText(googleServicesFile.text)
throw new GradleException('Please supply the correct google-services.json for release (or manually change the id above)!') if (json.project_info.project_id != firebaseReleaseProjectId)
throw new GradleException('Please supply the correct google-services.json for release in app/src/release/ directory!')
}
else
throw new GradleException('Please add the release google-services.json in app/src/release/ directory!')
}) })
} else if (task.name.contains("assembleDebug")) { } else if (task.name.contains("assembleDebug")) {
task.getDependsOn().add({ task.getDependsOn().add({
def inputFile = new File("app/google-services.json") def googleServicesFile = new File("app/src/debug/google-services.json")
def json = new JsonSlurper().parseText(inputFile.text) if(googleServicesFile.exists()){
if (json.project_info.project_id == "mthmmy-release-3aef0") def json = new JsonSlurper().parseText(googleServicesFile.text)
throw new GradleException('Please replace the release google-services.json with a debug one!') if (json.project_info.project_id == firebaseReleaseProjectId)
throw new GradleException('Please replace google-services.json in app/src/debug/ with a debug one!')
}
else
throw new GradleException('Please add a debug google-services.json in app/src/debug/ directory!')
}) })
} }
} }

Loading…
Cancel
Save