From 5e50c1d611e762b2d6e5eceb625994353e6d1f83 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Mon, 26 Jul 2021 13:17:25 -0300 Subject: [PATCH] fix: automatic latest build tools finding (#1294) --- framework/cordova.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/cordova.gradle b/framework/cordova.gradle index 239c4cdf..6e183040 100644 --- a/framework/cordova.gradle +++ b/framework/cordova.gradle @@ -53,10 +53,13 @@ String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) { throw e } + def minBuildToolsVersion = new Version(minBuildToolsVersionString) + def maxVersion = new Version((minBuildToolsVersion.getMajor() + 1) + ".0.0") + def highestBuildToolsVersion = buildToolsDirContents .collect { new Version(it) } // Invalid inputs will be handled as 0.0.0 - .findAll { it.isHigherThan('0.0.0') } + .findAll { it.isHigherThan('0.0.0') && it.isLowerThan(maxVersion) } .max() if (highestBuildToolsVersion == null) { @@ -68,7 +71,7 @@ String doFindLatestInstalledBuildTools(String minBuildToolsVersionString) { if (highestBuildToolsVersion.isLowerThan(minBuildToolsVersionString)) { throw new RuntimeException(""" - No usable Android build tools found. Highest installed version is + No usable Android build tools found. Highest ${minBuildToolsVersion.getMajor()}.x installed version is ${highestBuildToolsVersion.getOriginalString()}; minimum version required is ${minBuildToolsVersionString}. """.replaceAll(/\s+/, ' ').trim())