diff --git a/dev/devicelab/bin/tasks/module_test.dart b/dev/devicelab/bin/tasks/module_test.dart index 1aeb86a14c..9d5f8f8137 100644 --- a/dev/devicelab/bin/tasks/module_test.dart +++ b/dev/devicelab/bin/tasks/module_test.dart @@ -450,5 +450,6 @@ Future main() async { await task(combine([ // ignore: avoid_redundant_argument_values ModuleTest('module-gradle-7.6', gradleVersion: '7.6.3').call, + ModuleTest('module-gradle-7.6', gradleVersion: '7.6-rc-2').call, ])); } diff --git a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy index 06e34e8b52..51d8218b09 100644 --- a/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy +++ b/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy @@ -1423,6 +1423,7 @@ class FlutterPlugin implements Plugin { // compareTo implementation of version strings in the format of ints and periods // Requires non null objects. + // Will not crash on RC candidate strings but considers all RC candidates the same version. static int compareVersionStrings(String firstString, String secondString) { List firstVersion = firstString.tokenize(".") List secondVersion = secondString.tokenize(".") @@ -1430,12 +1431,32 @@ class FlutterPlugin implements Plugin { def commonIndices = Math.min(firstVersion.size(), secondVersion.size()) for (int i = 0; i < commonIndices; i++) { - def firstAtIndex = firstVersion[i].toInteger() - def secondAtIndex = secondVersion[i].toInteger() + String firstAtIndex = firstVersion[i] + String secondAtIndex = secondVersion[i] + int firstInt = 0; + int secondInt = 0 + try { + if (firstAtIndex.contains("-")) { + // Strip any chars after "-". For example "8.6-rc-2" + firstAtIndex = firstAtIndex.substring(0, firstAtIndex.indexOf('-')) + } + firstInt = firstAtIndex.toInteger() + } catch (NumberFormatException nfe) { + println(nfe) + } + try { + if (firstAtIndex.contains("-")) { + // Strip any chars after "-". For example "8.6-rc-2" + secondAtIndex = secondAtIndex.substring(0, secondAtIndex.indexOf('-')) + } + secondInt = secondAtIndex.toInteger() + } catch (NumberFormatException nfe) { + println(nfe) + } - if (firstAtIndex != secondAtIndex) { + if (firstInt != secondInt) { // <=> in groovy delegates to compareTo - return firstAtIndex <=> secondAtIndex + return firstInt <=> secondInt } }