-
Notifications
You must be signed in to change notification settings - Fork 28k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add migrator to upgrade gradle version when conflict with Android Studio bundled Java version is detected #124085
Conversation
…ersion, tests still todo
…p (now tested locally)
Also cc'ing @jmagman as you reviewed/authored the migrator PRs I based this on, feel free to ignore if you don't think you are the right person to review the migrator portion of this PR. |
/// | ||
/// For more info see the Gradle-Java compatibility matrix: | ||
/// https://docs.gradle.org/current/userguide/compatibility.html | ||
class GradleVersionConflictMigration extends ProjectMigrator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe GradleJavaVersionConflictMigration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a better name, will change.
logger.printTrace('Android Studio version could not be detected, ' | ||
'skipping gradle version compatibility check.'); | ||
return; | ||
} else if (_androidStudio!.version.compareTo(_androidStudioFlamingo) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we're short on time, but do we want to make this more general like comparing to a _currentAndroidStudioVersion
or something we can easily change in the future? Not sure how this sort of migrator is typically handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am open to making it more general, the key pieces of information required are a table of "for each Android Studio version, what is the bundled jdk version" and "for each java version, what is the minimum gradle version required."
The second piece is covered in this table, but I could not easily find the first piece of information.
If we think it should be more general I can try to find that info, but would also understand if the answer is "we want this migrator to do less replacing, not more."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha. Just thought I'd mention it as a possibility!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.printTrace('Android Studio version could not be detected, ' | ||
'skipping gradle version compatibility check.'); | ||
return; | ||
} else if (_androidStudio!.version.compareTo(_androidStudioFlamingo) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version
handles comparison operators
} else if (_androidStudio!.version.compareTo(_androidStudioFlamingo) < 0) { | |
} else if (_androidStudio!.version < _androidStudioFlamingo) { |
'skipping gradle version compatibility check.'); | ||
return; | ||
} else if (_androidStudio!.version.compareTo(_androidStudioFlamingo) < 0) { | ||
//Version of Android Studio is less than impacted version, no migration necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should trace
this, also makes it easier to test.
} | ||
final String existingVersionString = match[1]!; | ||
final Version existingVersion = Version.parse(existingVersionString)!; | ||
if (existingVersion.compareTo(_lowestSupportedGradleVersion) < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (existingVersion.compareTo(_lowestSupportedGradleVersion) < 0) { | |
if (existingVersion < _lowestSupportedGradleVersion) { |
final String existingVersionString = match[1]!; | ||
final Version existingVersion = Version.parse(existingVersionString)!; | ||
if (existingVersion.compareTo(_lowestSupportedGradleVersion) < 0) { | ||
logger.printTrace('Conflict detected between versions of Android Studio ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the user should see this message in non-verbose mode so they have some hint about why it's happening?
logger.printTrace('Conflict detected between versions of Android Studio ' | |
logger.printStatus('Conflict detected between versions of Android Studio ' |
if (existingVersion.compareTo(_lowestSupportedGradleVersion) < 0) { | ||
logger.printTrace('Conflict detected between versions of Android Studio ' | ||
'and gradle, upgrading gradle version from $existingVersion to 7.4'); | ||
return _newVersionFullDependency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the gradle properties files, is it possible there was leading whitespace (that mattered) before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the match so that we check for arbitrary whitespace at the start, and then so that we just replace the version number in the existing line. This will also stop us from overwriting the choice of either "bin" or "zip" at the end.
} else { | ||
//Version of gradle is already high enough, no migration necessary. | ||
return line; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
//Version of gradle is already high enough, no migration necessary. | |
return line; | |
} | |
} | |
// Version of gradle is already high enough, no migration necessary. | |
return line; |
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME | |||
distributionPath=wrapper/dists | |||
zipStoreBase=GRADLE_USER_HOME | |||
zipStorePath=wrapper/dists | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip | |||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm, you update these integration tests by letting the migrator actually run on them, not by editing it manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not - I made these changes before writing the migrator to see if it would cause any errors. I tested on some local projects, but it would be a good sanity check to let the migrator make these changes. I'll revert them locally and let the migrator handle and update with results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't get everything, but a bunch of them will be covered/migrated by running the build tests shard locally:
$ SHARD=build_tests dart dev/bots/test.dart
To save time first comment out all the _flutterBuild*
lines in _runExampleProjectBuildTests
except one of the _flutterBuildApk
lines:
Line 580 in 303d0d3
await _flutterBuildApk(examplePath, release: false, additionalArgs: additionalArgs, verifyCaching: verifyCaching); |
That way it doesn't build all the iOS, Linux, etc projects when you only need the Android ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was trying to run them 1 by 1. I downgraded the integration test gradle versions back to their original state (6.7) and ran the tests using that command, and all of the tests that ran then returned to 7.4 as expected. I also tested it out with a couple of differently formatted versions (i.e. major, minor, patch -> major, minor, etc) because these cases were all exactly 6.7 to 7.4.
I'm still working on running the ones that weren't hit by this command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can now confirm they all upgrade to what was already committed.
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter#124085)" This reverts commit eba2a52.
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…roid Studio bundled Java version is detected (flutter/flutter#124085)
…droid Studio bundled Java version is detected (#125836) This is an attempt to reland #124085. Differences from this attempt and the last: 1. Adds a check for null android studio versions and a test for this case. 2. Wraps the migrate code in a try-catch [per the suggestion here](https://github.com/flutter/flutter/pull/125728/files#r1181747899). Old PR description: This PR adds an android project migrator that checks the version of android studio and the version of gradle for conflicts, and upgrades to 7.4 if a conflict is detected. For more detail about the particular conflict, see #122376. The PR also upgrades older gradle versions being used in integration testing to 7.4. Fixes/related to: #122376 and #123636
…droid Studio bundled Java version is detected (flutter#125836) This is an attempt to reland flutter#124085. Differences from this attempt and the last: 1. Adds a check for null android studio versions and a test for this case. 2. Wraps the migrate code in a try-catch [per the suggestion here](https://github.com/flutter/flutter/pull/125728/files#r1181747899). Old PR description: This PR adds an android project migrator that checks the version of android studio and the version of gradle for conflicts, and upgrades to 7.4 if a conflict is detected. For more detail about the particular conflict, see flutter#122376. The PR also upgrades older gradle versions being used in integration testing to 7.4. Fixes/related to: flutter#122376 and flutter#123636
…droid Studio bundled Java version is detected (flutter#125836) This is an attempt to reland flutter#124085. Differences from this attempt and the last: 1. Adds a check for null android studio versions and a test for this case. 2. Wraps the migrate code in a try-catch [per the suggestion here](https://github.com/flutter/flutter/pull/125728/files#r1181747899). Old PR description: This PR adds an android project migrator that checks the version of android studio and the version of gradle for conflicts, and upgrades to 7.4 if a conflict is detected. For more detail about the particular conflict, see flutter#122376. The PR also upgrades older gradle versions being used in integration testing to 7.4. Fixes/related to: flutter#122376 and flutter#123636
This PR adds an android project migrator that checks the version of android studio and the version of gradle for conflicts, and upgrades to 7.4 if a conflict is detected. For more detail about the particular conflict, see #122376.
The PR also upgrades older gradle versions being used in integration testing to 7.4.
Fixes/related to: #122376 and #123636
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.