Skip to content

Commit

Permalink
Let gradle derive version name and version code from Git. Implements #…
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfs authored Jul 4, 2017
1 parent 8656e51 commit 903a6b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ buildscript {
}
}

def gitVersion = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags'
standardOutput = stdout
}
return stdout.toString().trim()
}

allprojects {
version gitVersion()

repositories {
jcenter()
maven { url "https://jitpack.io" }
Expand Down
14 changes: 12 additions & 2 deletions opentasks/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
apply plugin: 'com.android.application'

// commit number is only relevant to the application project
def gitCommitNo = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--count', 'master'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}

android {
compileSdkVersion COMPILE_SDK_VERSION.toInteger()
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
applicationId "org.dmfs.tasks"
minSdkVersion MIN_SDK_VERSION.toInteger()
targetSdkVersion TARGET_SDK_VERSION.toInteger()
versionCode 103
versionName '1.1.8.3-pre1'
versionCode gitCommitNo()
versionName version
}
buildTypes {
release {
Expand Down

0 comments on commit 903a6b7

Please sign in to comment.