Skip to content

Instantly share code, notes, and snippets.

@dudego
Created March 11, 2021 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudego/2001bbc6c292803ee3e1116a41150653 to your computer and use it in GitHub Desktop.
Save dudego/2001bbc6c292803ee3e1116a41150653 to your computer and use it in GitHub Desktop.
def taskFlavorTypes = ["flavor1", "flavor2"] //flavors defined for apk
def taskVariant = ["debug", "release"] //variant defined for apk
// generates gradle task dynamically which can be mapped for each build flavor and variant combination defined in above variables
// for eg. tasks will be declared as "encryptFlavor1DebugConfig", "encryptFlavor1ReleaseConfig", "encryptFlavor2DebugConfig", "encryptFlavor2ReleaseConfig"
taskFlavorTypes.each { buildFlavor ->
taskVariant.each { buildVariant ->
task "encrypt${buildFlavor.capitalize()}${buildVariant.capitalize()}Config" {
outputs.upToDateWhen { false }
description = "Encrypt ${buildFlavor} ${buildVariant} Config"
doLast {
encryptfile(buildFlavor, buildVariant)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment