Skip to content

Commit

Permalink
fix(flavor): get properly flavor for assemble and bundle build
Browse files Browse the repository at this point in the history
  • Loading branch information
irekrog committed Aug 12, 2023
1 parent a846d04 commit cf39eb4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion android/RNKeys.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import java.util.regex.Pattern

def getCurrentFlavor() {
Gradle gradle = getGradle()
String taskName = gradle.getStartParameter().getTaskNames()[0]

// match optional modules followed by the task
// (?:.*:)* is a non-capturing group to skip any :foo:bar: if they exist
// *[a-z]+([A-Za-z]+) will capture the flavor part of the task name onward (e.g., assembleRelease --> Release)
def pattern = Pattern.compile("(?:.*:)*[a-z]+([A-Z][A-Za-z0-9]+)")

if (taskName?.startsWith("assemble") || taskName?.startsWith("bundle")) {
// e.g. if assemblestagingrelease or bundlestagingrelease then the flavor will be staging
pattern = Pattern.compile("(?:assemble|bundle)(\\w+)([Rr]elease|[Dd]ebug)")
}

def flavor = ""

gradle.getStartParameter().getTaskNames().any { name ->
Expand Down Expand Up @@ -113,4 +120,4 @@ def loadKeys() {

task keysCallCL(type: Exec) {
loadKeys();
}
}

0 comments on commit cf39eb4

Please # to comment.