-
-
Save MarkoMilos/35be3e1e2be3b53dd3eb to your computer and use it in GitHub Desktop.
Automatic per-variant google_services.json configurations with Gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//append code below to existing build.gradle | |
def appModuleRootFolder = '.' | |
def srcDir = 'src' | |
def googleServicesJson = 'google-services.json' | |
task switchToDebug(type: Copy) { | |
def buildType = 'debug' | |
description = 'Switches to DEBUG google-services.json' | |
from "${srcDir}/${buildType}" | |
include "$googleServicesJson" | |
into "$appModuleRootFolder" | |
} | |
task switchToRelease(type: Copy) { | |
def buildType = 'release' | |
description = 'Switches to RELEASE google-services.json' | |
from "${srcDir}/${buildType}/" | |
include "$googleServicesJson" | |
into "$appModuleRootFolder" | |
} | |
afterEvaluate { | |
processDebugGoogleServices.dependsOn switchToDebug | |
processReleaseGoogleServices.dependsOn switchToRelease | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment