Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] Check weexVersion (#2451)
Browse files Browse the repository at this point in the history
* [Android] Check weexVersion

1. The version must have 4 sections.
2. The leading three section must be number, and the last section is odd number with or without suffix string.

* [Android] Add ignoreVersionCheck
  • Loading branch information
YorkShen authored and lucky-chen committed May 16, 2019
1 parent 20d075a commit 151c469
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion android/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,26 @@ checkstyle {
toolVersion = '6.9'
}

version = project.hasProperty('weexVersion')? project.getProperty('weexVersion') : "0.20.0.1"
version = project.hasProperty('weexVersion') ? project.getProperty('weexVersion') : "0.20.0.1"

//Check version, the version must have 4 sections. The leading three section must be number, and the last section is odd number with or without suffix string.
if (!project.hasProperty('ignoreVersionCheck') || !project.getProperty('ignoreVersionCheck').equals("true")) {
assert version.tokenize('.').eachWithIndex { it, i ->
if (i < 3) {
assert it.isNumber()
} else if (i == 3) {
it.split("-|_").toList().eachWithIndex { inner_it, inner_i ->
if (inner_i == 0) {
assert inner_it.isNumber() && inner_it.toInteger() % 2
} else {
assert !inner_it.isNumber()
}
}.size == 4
} else {
assert false: "Please use semantic versioning witch 4 sections, you are using ${$ { i } + 1} section instead"
}
}.size == 4
}

android {
compileSdkVersion project.compileSdkVersion
Expand Down

0 comments on commit 151c469

Please sign in to comment.