2017-04-13 11:30:54 +00:00
|
|
|
plugins {
|
|
|
|
id 'org.ajoberstar.grgit' version '1.7.1'
|
|
|
|
id 'com.palantir.git-version' version '0.7.1'
|
|
|
|
}
|
|
|
|
|
2016-11-08 08:02:01 +00:00
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
|
2017-04-13 11:30:54 +00:00
|
|
|
import org.ajoberstar.grgit.Grgit
|
|
|
|
|
2017-04-19 08:36:58 +00:00
|
|
|
// Use commit date as version code (valid up to 07/18/2036)
|
2017-04-13 11:30:54 +00:00
|
|
|
def buildVersionCode() {
|
|
|
|
def repo = Grgit.open()
|
|
|
|
def head = repo.head()
|
|
|
|
|
|
|
|
// Sanity check across git plugins
|
|
|
|
assert head.getAbbreviatedId(10) == versionDetails().gitHash : "Internal error: SHA1 mismatch!"
|
|
|
|
|
|
|
|
return head.time
|
|
|
|
}
|
|
|
|
|
|
|
|
// Derive version name from release tag and add commit SHA1
|
|
|
|
def buildVersionName() {
|
2017-04-19 08:36:58 +00:00
|
|
|
def pattern = /client_release\/\d+\.\d+\/(?<major>\d+)\.(?<minor>\d+)\.(?<revision>\d+)(?<suffix>[-_\.].*)/
|
|
|
|
def version = ': DEVELOPMENT'
|
2017-04-13 11:30:54 +00:00
|
|
|
|
2017-04-19 08:36:58 +00:00
|
|
|
def head = versionDetails()
|
|
|
|
def tag = head.lastTag
|
2017-04-13 11:30:54 +00:00
|
|
|
def match = (tag =~ pattern)
|
|
|
|
|
|
|
|
// Sanity checks for tag format
|
2017-04-19 08:36:58 +00:00
|
|
|
if(match.hasGroup() && 1 == match.size() && 5 == match[0].size() && head.commitDistance == 0) {
|
|
|
|
def major = match.group('major')
|
|
|
|
def minor = match.group('minor')
|
|
|
|
def revision = match.group('revision')
|
|
|
|
def suffix = match.group('suffix')
|
|
|
|
version = "${major}.${minor}.${revision}${suffix}"
|
|
|
|
assert !suffix.endsWith('.dirty') : "Dirty working tree detected! Preventing release build!"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println "Warning! Non-release tag or offset found: $tag (offset: $head.commitDistance)"
|
|
|
|
println "Flagging as DEVELOPMENT build..."
|
|
|
|
}
|
2017-04-13 11:30:54 +00:00
|
|
|
|
|
|
|
def commit = versionDetails().gitHash
|
|
|
|
|
2017-04-19 08:36:58 +00:00
|
|
|
return "${version} (${commit})"
|
2017-04-13 11:30:54 +00:00
|
|
|
}
|
|
|
|
|
2016-11-08 08:02:01 +00:00
|
|
|
android {
|
2016-11-08 09:36:43 +00:00
|
|
|
compileSdkVersion 23
|
2016-11-08 08:02:01 +00:00
|
|
|
buildToolsVersion "25.0.0"
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
applicationId "edu.berkeley.boinc"
|
|
|
|
minSdkVersion 16
|
2016-11-08 09:36:43 +00:00
|
|
|
targetSdkVersion 23
|
2017-04-13 11:30:54 +00:00
|
|
|
versionCode buildVersionCode()
|
|
|
|
versionName buildVersionName()
|
2016-11-08 08:02:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled false
|
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
|
|
|
}
|
2016-11-09 17:36:50 +00:00
|
|
|
debug {
|
|
|
|
minifyEnabled false
|
|
|
|
debuggable true
|
|
|
|
}
|
2016-11-08 08:02:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2016-11-08 09:36:43 +00:00
|
|
|
compile 'com.android.support:appcompat-v7:23.1.+'
|
2016-11-08 08:02:01 +00:00
|
|
|
}
|