Gradle: Update version name policy

This commit is contained in:
zt515
2017-10-25 23:33:36 +08:00
parent 0b1d745343
commit 1912088f4b
6 changed files with 41 additions and 4 deletions

View File

@ -9,7 +9,7 @@ dependencies {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
buildscript {
ext.kotlin_version = '1.1.4'
ext.kotlin_version = '1.1.51'
repositories {
mavenCentral()
}

View File

@ -19,8 +19,12 @@ android {
buildTypes {
release {
minifyEnabled false
versionNameSuffix "-${getGitHeadRefsSuffix()}"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
versionNameSuffix "-snatshot-${getGitHeadRefsSuffix()}"
}
}
}

View File

@ -9,7 +9,7 @@ android {
minSdkVersion 21
targetSdkVersion 26
versionCode 30
versionName "1.2.9-snapshot"
versionName "1.2.9"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "zh-rCN", "zh-rTW"
externalNativeBuild {
@ -31,6 +31,10 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile 'app/proguard-rules.pro'
versionNameSuffix "-${getGitHeadRefsSuffix()}"
}
debug {
versionNameSuffix "-snatshot-${getGitHeadRefsSuffix()}"
}
}
externalNativeBuild {

View File

@ -1,7 +1,28 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4'
ext.kotlin_version = '1.1.51'
ext.getGitHeadRefsSuffix = {
try {
def headFile = new File('.git/HEAD')
if (headFile.exists()) {
String[] strings = headFile.getText('UTF-8').split(" ");
if (strings.size() > 1) {
String refFilePath = '.git/' + strings[1];
def refFile = new File(refFilePath.replace("\n", ""));
return refFile.getText('UTF-8').substring(0, 7)
}
}
} catch (Exception e) {
e.printStackTrace()
}
return ""
}
repositories {
maven { url 'https://dl.google.com/dl/android/maven2/' }
jcenter()

View File

@ -13,6 +13,10 @@ android {
buildTypes {
release {
minifyEnabled true
versionNameSuffix "-${getGitHeadRefsSuffix()}"
}
debug {
versionNameSuffix "-snatshot-${getGitHeadRefsSuffix()}"
}
}
}

View File

@ -17,8 +17,12 @@ android {
buildTypes {
release {
minifyEnabled false
versionNameSuffix "-${getGitHeadRefsSuffix()}"
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
versionNameSuffix "-snatshot-${getGitHeadRefsSuffix()}"
}
}
compileOptions {
targetCompatibility 1.8
@ -29,7 +33,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'