Created
February 10, 2017 10:27
-
-
Save FrancescoJo/6e46826a57bfe8bcf0a87842c50b6776 to your computer and use it in GitHub Desktop.
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
import java.util.regex.Matcher | |
import java.util.regex.Pattern | |
// ext makes method callable project wide | |
ext.getCurrentFlavor = { -> | |
Gradle gradle = getGradle() | |
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() | |
Pattern pattern; | |
if (tskReqStr.contains("assemble")) | |
pattern = Pattern.compile("assemble(\\w+)(Release|Debug)") | |
else | |
pattern = Pattern.compile("generate(\\w+)(Release|Debug)") | |
Matcher matcher = pattern.matcher(tskReqStr) | |
if (matcher.find()) { | |
return matcher.group(1).toLowerCase() | |
} else { | |
return ""; | |
} | |
} | |
ext.getCurrentBuildType = { -> | |
Gradle gradle = getGradle() | |
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() | |
if (tskReqStr.contains("Release")) { | |
return "release" | |
} else if (tskReqStr.contains("generateDebug")) { | |
return "debug" | |
} | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment