Created
January 12, 2016 19:34
-
-
Save codelance/bc8af631532f636d86dc to your computer and use it in GitHub Desktop.
Use different google-services.json for different app flavors on Android.
This file contains hidden or 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
def appModuleRootFolder = '.' | |
def srcDir = 'src' | |
def googleServicesJson = 'google-services.json' | |
task switchToStaging(type: Copy) { | |
outputs.upToDateWhen { false } | |
def flavor = 'staging' | |
description = "Switches to $flavor $googleServicesJson" | |
delete "$appModuleRootFolder/$googleServicesJson" | |
from "${srcDir}/$flavor/" | |
include "$googleServicesJson" | |
into "$appModuleRootFolder" | |
} | |
task switchToProduction(type: Copy) { | |
outputs.upToDateWhen { false } | |
def flavor = 'production' | |
description = "Switches to $flavor $googleServicesJson" | |
from "${srcDir}/$flavor/" | |
include "$googleServicesJson" | |
into "$appModuleRootFolder" | |
} | |
afterEvaluate { | |
processStagingDebugGoogleServices.dependsOn switchToStaging | |
processStagingReleaseGoogleServices.dependsOn switchToStaging | |
processProductionDebugGoogleServices.dependsOn switchToProduction | |
processProductionReleaseGoogleServices.dependsOn switchToProduction | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment