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
|
2019-01-10 16:38:37 +00:00
|
|
|
assert head.getAbbreviatedId(10) == versionDetails().gitHash: "Internal error: SHA1 mismatch!"
|
2017-04-13 11:30:54 +00:00
|
|
|
|
|
|
|
return head.time
|
|
|
|
}
|
|
|
|
|
|
|
|
// Derive version name from release tag and add commit SHA1
|
|
|
|
def buildVersionName() {
|
2018-10-05 14:22:23 +00:00
|
|
|
def pattern = /client_release\/\d+\.\d+\/(?<major>\d+)\.(?<minor>\d+)\.(?<revision>\d+)(?<suffix>[-_\.]?.*)/
|
2017-04-19 08:36:58 +00:00
|
|
|
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
|
2019-01-10 16:38:37 +00:00
|
|
|
if (match.hasGroup() && 1L == match.size() && 5L == match[0].size() && head.commitDistance == 0) {
|
2017-04-19 08:36:58 +00:00
|
|
|
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}"
|
2019-01-10 16:38:37 +00:00
|
|
|
assert !suffix.endsWith('.dirty'): "Dirty working tree detected! Preventing release build!"
|
|
|
|
} else {
|
2017-04-19 08:36:58 +00:00
|
|
|
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 {
|
2018-12-07 21:37:43 +00:00
|
|
|
compileSdkVersion 28
|
2018-11-23 10:39:55 +00:00
|
|
|
buildToolsVersion '28.0.3'
|
2016-11-08 08:02:01 +00:00
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
applicationId "edu.berkeley.boinc"
|
2018-09-04 12:40:09 +00:00
|
|
|
minSdkVersion 19
|
2018-12-07 21:37:43 +00:00
|
|
|
targetSdkVersion 28
|
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 {
|
2018-12-07 21:37:43 +00:00
|
|
|
implementation 'com.android.support:appcompat-v7:28.0.0'
|
2016-11-08 08:02:01 +00:00
|
|
|
}
|