From 151c46939847185c6cc58dd97dbbee2e37e5fb18 Mon Sep 17 00:00:00 2001 From: YorkShen Date: Thu, 16 May 2019 17:32:14 +0800 Subject: [PATCH] [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 --- android/sdk/build.gradle | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/android/sdk/build.gradle b/android/sdk/build.gradle index 0e3183dcc9..182908f522 100755 --- a/android/sdk/build.gradle +++ b/android/sdk/build.gradle @@ -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