Skip to content

Commit

Permalink
把版本名称和版本号自动化
Browse files Browse the repository at this point in the history
  • Loading branch information
taowenyin committed Aug 3, 2017
1 parent f1f9a2a commit e8e79b8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
apply plugin: 'com.android.application'

def gitCommitShortHash = 'git log -1 --pretty=%h'.execute([], project.rootDir).text.trim()
def gitCommitDate = 'git log -1 --pretty=%ci'.execute([], project.rootDir).text.trim().split()[0]
def gitShortShaDate = gitCommitShortHash + "_" + gitCommitDate

// Auto-incrementing commit count based on counting commits to HEAD (Build #543)
def gitCommitCount = Integer.parseInt('git rev-list HEAD --count'.execute([], project.rootDir).text.trim())

// I want to use git tags as my version names (1.2.2)
def gitCurrentTag = 'git describe --tags --abbrev=0'.execute([], project.rootDir).text.trim()

android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "cn.edu.siso.rlxapf"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionCode gitCommitCount
versionName gitCurrentTag
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand Down

0 comments on commit e8e79b8

Please sign in to comment.