Skip to content

Commit

Permalink
fix: automatic latest build tools finding
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed Jul 26, 2021
1 parent 38ca895 commit a79e834
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions framework/cordova.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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())
Expand Down

0 comments on commit a79e834

Please sign in to comment.