Created
July 8, 2015 12:42
-
-
Save bholota/7a8c47577a91caf1255d to your computer and use it in GitHub Desktop.
Add crashlyticsUpload tasks dependency on the fly - checking if everything is commited to git
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
//add it to your build.gradle | |
//every time when your will call task crashlyticsUploadSomethingSomething it will be called before it | |
//and it will crash if you have some uncommited changes in your working copy. | |
// | |
//I'm using this because I need git sha1 for app versioning in development versions. | |
task everythingGitCommited << { | |
def checkChanges = 'git status -uno --porcelain'.execute([], project.rootDir).text.trim() | |
if(checkChanges) { | |
throw new GradleException('Commit or shash your working copy before BETA upload!') | |
} | |
} | |
tasks.whenTaskAdded { task -> | |
if(task.name.startsWith("crashlyticsUpload")) { | |
task.dependsOn everythingGitCommited | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment