version.gradle 685 B

12345678910111213141516171819202122232425262728
  1. ext {
  2. isSnapshot = !project.hasProperty('release')
  3. isSnapCi = System.getenv('SNAP_CI') != null
  4. isSnapPullRequest = System.getenv('SNAP_PULL_REQUEST_NUMBER') != null
  5. }
  6. /*
  7. * Gets the version name from the latest Git tag
  8. */
  9. def getVersionName = {
  10. def stdout = new ByteArrayOutputStream()
  11. try {
  12. exec {
  13. commandLine 'git', 'describe', '--tags'
  14. standardOutput = stdout
  15. }
  16. return stdout.toString().trim()
  17. }
  18. catch (e) {
  19. println("Can't get version from git: " + e);
  20. return "adhoc"
  21. }
  22. }
  23. allprojects {
  24. version = "${getVersionName()}${isSnapshot ? "-SNAPSHOT" : ""}"
  25. group = "org.altbeacon"
  26. }