From fc1fd131ad73d4ec609a829e9328777a7d496fd8 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 30 Sep 2015 16:52:27 +0300 Subject: [PATCH] Fix check for Gradle version In case Gradle's version is with three numbers ("2.2.3" for example), our current check is failing and makes the doctor command unusable. Compare current gradle version with min required one only after they are in the same format. --- lib/common | 2 +- lib/services/doctor-service.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/common b/lib/common index dcdddcee7c..c8562dc52a 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit dcdddcee7c23f40e34b59840ac7f29f6d1b14539 +Subproject commit c8562dc52a6f9e051eda7de5bee9a9e2b3d458c3 diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index 5044c3f319..9fe6802a25 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -66,7 +66,7 @@ class DoctorService implements IDoctorService { result = true; } - if(sysInfo.gradleVer && helpers.versionCompare(sysInfo.gradleVer, DoctorService.MIN_SUPPORTED_GRADLE_VERSION) === -1) { + if(sysInfo.gradleVer && !this.isGradleVersionSupported(sysInfo.gradleVer)) { this.$logger.warn(`WARNING: Gradle version is lower than ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION}.`); this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL + `To be able to build for Android and run apps in the emulator or on a connected device, verify that you have at least ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION} version installed.`); @@ -106,5 +106,14 @@ class DoctorService implements IDoctorService { this.$logger.out("TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies." + EOL); } } + + private isGradleVersionSupported(gradleVersion: string): boolean { + let minSupportedVersion = DoctorService.MIN_SUPPORTED_GRADLE_VERSION; + let requiredLength = _.max([gradleVersion.split(".").length, minSupportedVersion.split(".").length]); + gradleVersion = helpers.appendZeroesToVersion(gradleVersion, requiredLength); + minSupportedVersion = helpers.appendZeroesToVersion(minSupportedVersion, requiredLength); + + return helpers.versionCompare(gradleVersion, minSupportedVersion) !== -1; + } } $injector.register("doctorService", DoctorService);