mirror of https://github.com/BOINC/boinc.git
Merge pull request #1866 from brevilo/android-versioning
Android: use dynamic versioning instead of hard-coded values
This commit is contained in:
commit
f923ac905d
|
@ -1,5 +1,45 @@
|
|||
plugins {
|
||||
id 'org.ajoberstar.grgit' version '1.7.1'
|
||||
id 'com.palantir.git-version' version '0.7.1'
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
import org.ajoberstar.grgit.Grgit
|
||||
|
||||
// Use commit date as version code
|
||||
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() {
|
||||
def pattern = /client_release\/\d+\.\d+\/(?<major>\d+)\.(?<minor>\d+)\.(?<revision>\d+)(?<suffix>[-_].*)/
|
||||
def message = 'Invalid release tag encountered:'
|
||||
|
||||
def tag = versionDetails().lastTag
|
||||
def match = (tag =~ pattern)
|
||||
|
||||
// Sanity checks for tag format
|
||||
assert match.hasGroup() : "$message $tag"
|
||||
assert 1 == match.size() : "$message $tag"
|
||||
assert 5 == match[0].size() : "$message $tag"
|
||||
|
||||
def major = match.group('major')
|
||||
def minor = match.group('minor')
|
||||
def revision = match.group('revision')
|
||||
def suffix = match.group('suffix')
|
||||
def commit = versionDetails().gitHash
|
||||
|
||||
return "${major}.${minor}.${revision}${suffix} (${commit})"
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "25.0.0"
|
||||
|
@ -8,6 +48,8 @@ android {
|
|||
applicationId "edu.berkeley.boinc"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 23
|
||||
versionCode buildVersionCode()
|
||||
versionName buildVersionName()
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="edu.berkeley.boinc"
|
||||
android:installLocation="internalOnly"
|
||||
android:versionCode="72"
|
||||
android:versionName="7.5.0"> <!-- installation on SD card would break boot receiver -->
|
||||
android:installLocation="internalOnly"> <!-- installation on SD card would break boot receiver -->
|
||||
|
||||
<!-- Add Google Play store metadata informing the store we can run on tablets and other large screen devices -->
|
||||
<supports-screens
|
||||
|
|
Loading…
Reference in New Issue