-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[Many] Migrate non examples (and pigeon test) to java 17 #10201
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
base: main
Are you sure you want to change the base?
Conversation
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.
Code Review
This pull request migrates a number of packages to Java 17. This includes updating build.gradle
files to set Java 17 compatibility, updating pubspec.yaml
files with new SDK constraints, and adding corresponding changelog entries. The PR also updates the gradle-check
tool to enforce these new Java 17 requirements, including a check for kotlinOptions
configuration. My review focuses on improving the robustness of the updated tool script.
final bool hasCompabilityVersions = gradleLines.any((String line) => | ||
line.contains('sourceCompatibility') && !_isCommented(line)) && | ||
line.contains('sourceCompatibility = JavaVersion.VERSION_$requiredJavaVersion') && !_isCommented(line)) && | ||
// Newer toolchains default targetCompatibility to the same value as | ||
// sourceCompatibility, but older toolchains require it to be set | ||
// explicitly. The exact version cutoff (and of which piece of the | ||
// toolchain; likely AGP) is unknown; for context see | ||
// https://github.com/flutter/flutter/issues/125482 | ||
gradleLines.any((String line) => | ||
line.contains('targetCompatibility') && !_isCommented(line)); | ||
line.contains('targetCompatibility = JavaVersion.VERSION_$requiredJavaVersion') && !_isCommented(line)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
final bool kotlinOptionsUsesJavaVersion = gradleLines.any((String line) => | ||
line.contains('jvmTarget = JavaVersion.VERSION_$requiredJavaVersion') && | ||
!_isCommented(line)); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
final bool kotlinOptionsUsesJavaVersion = gradleLines.any((String line) => | ||
line.contains('jvmTarget = JavaVersion.VERSION_$requiredJavaVersion') && | ||
!_isCommented(line)); | ||
// Either does not set kotlinOptions or does and uses non-string based syntax. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
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.
LGTM
1045ced
to
5ec1943
Compare
const String errorMessage = ''' | ||
build.gradle must set an explicit Java compatibility version. | ||
const String javaErrorMessage = ''' | ||
build.gradle(.kts) must set an explicit Java compatibility version. |
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 this should say "must set an explicit Java compatibility version of $requiredJavaVersion."
With the updated check, someone who adds an incorrect compatibility version will get an error message that just says that they need to set an explicit version, which they did, so it will be confusing.
badLines += '${gradleLines[i]}\n'; | ||
} | ||
final String kotlinErrorMessage = ''' | ||
If build.gradle(.kts) sets jvmTarget then it must use JavaVersion syntax. |
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.
Similarly, if I'm reading this right, setting, say jvmTarget = JavaVersion.VERSION_21.toString()
would lead to an error message saying that they are using the wrong syntax, when the actual problem in that the version is wrong.
I think we should either detect those cases separately and have different messages, or just make the message more specific (e.g., "it must set version $requiredJavaVersion using JavaVersion syntax.")
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.
@stuartmorgan-g and I talked offline and I will make this change in my next pr. Tooling is easier to land and less likely to have a conflict and this corner case is unlikely to hit anyone in the short term.
autosubmit label was removed for flutter/packages/10201, because - The status or check suite Linux repo_checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
autosubmit label was removed for flutter/packages/10201, because - The status or check suite Linux_android android_platform_tests_shard_2 master has failed. Please fix the issues identified (or deflake) before re-applying this label. |
autosubmit label was removed for flutter/packages/10201, because - The status or check suite Linux_android android_platform_tests_shard_2 master has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Fixes flutter/flutter/issues/176027
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with an appropriate new version according to the [pub versioning philosophy], or I have commented below to indicate which [version change exemption] this PR falls under[^1].CHANGELOG.md
to add a description of the change, [following repository CHANGELOG style], or I have commented below to indicate which [CHANGELOG exemption] this PR falls under[^1].///
).