Skip to content

Commit

Permalink
update:添加安卓版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed May 14, 2020
1 parent f38956b commit c1a46fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
33 changes: 31 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,29 @@ if (localPropertiesFile.exists()) {
}
}

//add by Farry
def gitVersionCode() {
def cmd = 'git rev-list HEAD --first-parent --count'
cmd.execute().text.trim().toInteger()
}

def gitVersionTag() {
def cmd = 'git describe --tags'
def version = cmd.execute().text.trim()

def pattern = "-(\\d+)-g"
def matcher = version =~ pattern

if (matcher) {
version = version.substring(0, matcher.start()) + "." + matcher[0][1]
} else {
version = version + ".0"
}

return version
}
//add end

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
Expand Down Expand Up @@ -40,8 +63,8 @@ android {
applicationId "com.iotserv.gateway"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
versionCode gitVersionCode()
versionName gitVersionTag()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -55,6 +78,12 @@ android {
}

buildTypes {
// add by Farry
debug {
// 为了不和 release 版本冲突
applicationIdSuffix ".debug"
}
// add end
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
Expand Down
Binary file modified android/app/libs/client.aar
Binary file not shown.
8 changes: 5 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,11 @@ packages:
modules:
dependency: "direct main"
description:
path: "../modules"
relative: true
source: path
path: "."
ref: HEAD
resolved-ref: b9f16ad5c3e83c42b9ebbbc84bc2de56dfee2063
url: "https://github.com/OpenIoTHub/modules"
source: git
version: "0.0.1"
open_file:
dependency: transitive
Expand Down

0 comments on commit c1a46fd

Please sign in to comment.