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

Commit 151c469

Browse files
YorkShenlucky-chen
authored andcommitted
[Android] Check weexVersion (#2451)
* [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
1 parent 20d075a commit 151c469

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

android/sdk/build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,26 @@ checkstyle {
6363
toolVersion = '6.9'
6464
}
6565

66-
version = project.hasProperty('weexVersion')? project.getProperty('weexVersion') : "0.20.0.1"
66+
version = project.hasProperty('weexVersion') ? project.getProperty('weexVersion') : "0.20.0.1"
67+
68+
//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.
69+
if (!project.hasProperty('ignoreVersionCheck') || !project.getProperty('ignoreVersionCheck').equals("true")) {
70+
assert version.tokenize('.').eachWithIndex { it, i ->
71+
if (i < 3) {
72+
assert it.isNumber()
73+
} else if (i == 3) {
74+
it.split("-|_").toList().eachWithIndex { inner_it, inner_i ->
75+
if (inner_i == 0) {
76+
assert inner_it.isNumber() && inner_it.toInteger() % 2
77+
} else {
78+
assert !inner_it.isNumber()
79+
}
80+
}.size == 4
81+
} else {
82+
assert false: "Please use semantic versioning witch 4 sections, you are using ${$ { i } + 1} section instead"
83+
}
84+
}.size == 4
85+
}
6786

6887
android {
6988
compileSdkVersion project.compileSdkVersion

0 commit comments

Comments
 (0)