Created
February 26, 2016 02:53
-
-
Save tmelz/6f93e6a68343210043c2 to your computer and use it in GitHub Desktop.
enforce your android versionName format with a regexp
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
android { | |
defaultConfig { | |
// Version name format: A.B.C-D, with A, B, and C numbers with -D optional as either "ALPHA" | |
// or "BETA" followed by a description. Examples: "1.0.0", "1.0.0-BETA", | |
// "1.0.0-ALPHA-TACO-DELIVERY". | |
versionName "1.0.0" | |
// Enforce that the version name matches the required format. | |
if (!(versionName ==~ /\d+\.\d+\.\d+(-(ALPHA|BETA).*)?/)) { | |
throw new IllegalStateException( | |
"Invalid version name ('$versionName')! See comment in app/build.gradle") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment