Skip to content

Instantly share code, notes, and snippets.

@bholota
Created August 27, 2015 12:24
Show Gist options
  • Save bholota/caca557160d48cbd53c6 to your computer and use it in GitHub Desktop.
Save bholota/caca557160d48cbd53c6 to your computer and use it in GitHub Desktop.
gradle task dependency
// Custom tasks
/**
* This test make sure if we have everything committed (or stashed). Allows keep project clean
* and with even small change crashlytics beta upload will have different SHA1.
*/
task testGitWorkingCopy << {
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!')
}
}
/**
* This app uses multidex and it compiles faster with minimum api version 21+ (ART etc.)
* This test make us sure if we're not uploading apk with bad min api to testing pipeline.
*/
task testMinSDK << {
if(MIN_SDK != project.android.defaultConfig.minSdkVersion.mApiLevel) {
throw new GradleException('Check your minSdkVersion!')
}
}
/**
* Allow triggering custom tests before uploading to crashlytics beta.
*/
tasks.whenTaskAdded { task ->
if(task.name.startsWith("crashlyticsUpload")) {
task.dependsOn testGitWorkingCopy
task.dependsOn testMinSDK
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment