Skip to content

Instantly share code, notes, and snippets.

@Jween
Last active August 29, 2015 14:04
Show Gist options
  • Save Jween/039f4625b69d598b856d to your computer and use it in GitHub Desktop.
Save Jween/039f4625b69d598b856d to your computer and use it in GitHub Desktop.
determine gradle version
// returns true if greater, null if equal, false otherwise
def gradleAfter = {
[
gradle.gradleVersion.tokenize('.')*.toInteger(),
it.toString().tokenize('.')*.toInteger()
].transpose().inject(null){ result, item ->
result != null ?:
(item[0] > item[1] ?: item[0] == item[1] ? null : false);
}
}
@Jween
Copy link
Author

Jween commented Jul 18, 2014

when you need to use a new method in a later gradle version, try as follow:

if (gradleAfter(1.8) ) {
    // TODO invoke newly added methods
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment