-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Convert BaseFlutterTask
From Groovy to Kotlin
#163148
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
Convert BaseFlutterTask
From Groovy to Kotlin
#163148
Conversation
6d5600d
to
8eb0bbf
Compare
6c76b81
to
4902ed0
Compare
# Conflicts: # packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
4902ed0
to
79b6933
Compare
BaseFlutterTask
From Groovy to KotlinBaseFlutterTask
From Groovy to Kotlin
fun buildBundle() { | ||
val helper = BaseFlutterTaskHelper(baseFlutterTask = this) | ||
helper.checkPreConditions() | ||
intermediateDir!!.mkdirs() |
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 dont like having a nullable intermediateDir then using !!. I thought maybe checkPreConditions would ensure that intermediateDir was not null but that does not look like the case.
I think the right thing to do here is to see if we can make intermediateDir non null and if we cant then handle null on this line. In BaseFlutterTaskHelper.getDependenciesFiles we treat the value as non null.
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 believe this was done because the original code behaved this way i.e.,
intermediateDir
took a JavaFile
, and so was nullable and- we would throw a NPE on the old line 1642 of
flutter.groovy
, ifintermediateDir
was null.
I know we had initially spoken about not making behavior changes in the conversion. Do you think we should amend that for the case of null pointer exceptions? I think that would be reasonable, but we should be explicit.
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.
@gmackall talked with some members of the flutter android team and the decision was made to file an issue to track fixing this issue and keeping the code as it was before.
There is a balance between fixing issues as we see them and introducing new behavior and the goal of this project (language conversion + unit testing) is to minimize (to the point of zero) the introduction of new behavior if possible.
Keeping an NPE we know about hurts but we are following our own principals in this project. After the conversion is done we do intend to fix many of the issues we have found.
private val extraGenSnapshotOptionsTest = "--debugger" | ||
private val splitDebugInfoTest = "/path/to/build/debug_info_directory" | ||
private val codeSizeDirectoryTest = "/path/to/build/code_size_directory" | ||
private val minSDKVersionTest = 21 |
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.
After @ash-google lands his min sdk check pr can this test use that value?
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.
done
packages/flutter_tools/gradle/src/main/kotlin/BaseFlutterTaskHelper.kt
Outdated
Show resolved
Hide resolved
baseFlutterTask.splitDebugInfo?.let { | ||
args("-dSplitDebugInfo=${baseFlutterTask.splitDebugInfo}") | ||
} | ||
if (baseFlutterTask.treeShakeIcons == true) { | ||
args("-dTreeShakeIcons=true") | ||
} | ||
if (baseFlutterTask.dartObfuscation == true) { | ||
args("-dDartObfuscation=true") | ||
} | ||
baseFlutterTask.dartDefines?.let { | ||
args("--DartDefines=${baseFlutterTask.dartDefines}") | ||
} | ||
baseFlutterTask.bundleSkSLPath?.let { | ||
args("-dBundleSkSLPath=${baseFlutterTask.bundleSkSLPath}") | ||
} | ||
baseFlutterTask.codeSizeDirectory?.let { | ||
args("-dCodeSizeDirectory=${baseFlutterTask.codeSizeDirectory}") | ||
} | ||
baseFlutterTask.flavor?.let { | ||
args("-dFlavor=${baseFlutterTask.flavor}") | ||
} | ||
baseFlutterTask.extraGenSnapshotOptions?.let { | ||
args("--ExtraGenSnapshotOptions=${baseFlutterTask.extraGenSnapshotOptions}") | ||
} | ||
baseFlutterTask.frontendServerStarterPath?.let { | ||
args("-dFrontendServerStarterPath=${baseFlutterTask.frontendServerStarterPath}") | ||
} | ||
baseFlutterTask.extraFrontEndOptions?.let { | ||
args("--ExtraFrontEndOptions=${baseFlutterTask.extraFrontEndOptions}") | ||
} |
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.
Since we're not using the parameter from .let
, let's just replace these with if null checks instead so it's a little more readable.
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.
Instead why not use the parameter from let?
baseFlutterTask.extraFrontEndOptions?.let {
args("--ExtraFrontEndOptions=$it")
}
vs
if (baseFlutterTask.extraFrontEndOptions != null) {
args("--ExtraFrontEndOptions=${baseFlutterTask.extraFrontEndOptions}")
}
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.
done. Used the parameter from let.
# Conflicts: # packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
…#8922) Manual roll Flutter from b16430b2fd57 to 1d954f4e96bd (114 revisions) Manual roll requested by [email protected] flutter/flutter@b16430b...1d954f4 2025-03-17 [email protected] Revert "[skwasm] Dynamic Threading (#164748)" (flutter/flutter#165350) 2025-03-17 [email protected] Roll Skia from fa669e2e6d12 to 52130e5c3b34 (4 revisions) (flutter/flutter#165348) 2025-03-17 [email protected] `OverlayPortal.childLayoutBuilder` should rebuild when `OverlayPortal` rebuilds. (flutter/flutter#165331) 2025-03-17 [email protected] [web][a11y]Delete _childContainerElement (flutter/flutter#163662) 2025-03-17 [email protected] Roll Skia from e45207898e60 to fa669e2e6d12 (8 revisions) (flutter/flutter#165342) 2025-03-17 [email protected] Add documentation for Java test filtering to plugins test document (flutter/flutter#165314) 2025-03-17 [email protected] Roll Fuchsia Linux SDK from SDNQgVXxHbbd0qsVw... to mPniqXmPpXqMMpM8z... (flutter/flutter#165313) 2025-03-17 [email protected] Roll Dart SDK from 9283d47199b7 to 725172afbc42 (1 revision) (flutter/flutter#165310) 2025-03-17 [email protected] feat(Tooltip): replace the height parameter with constraints (flutter/flutter#163314) 2025-03-17 [email protected] Fix arrowHeadColor breaks differentiation between states (flutter/flutter#165178) 2025-03-17 [email protected] Removes assumption that basis scalar and rounded_scalar match (flutter/flutter#165166) 2025-03-17 [email protected] Roll Skia from 69cf4c2c5db8 to e45207898e60 (1 revision) (flutter/flutter#165300) 2025-03-17 [email protected] Refactor: Move sliders value indicator shape to seperate file (flutter/flutter#162858) 2025-03-17 [email protected] Roll Skia from 3931c31032c7 to 69cf4c2c5db8 (1 revision) (flutter/flutter#165288) 2025-03-17 [email protected] Delete `docs/infra/Infra-Ticket-Queue.md` (flutter/flutter#165258) 2025-03-16 [email protected] Roll Skia from 3413a02d6fc8 to 3931c31032c7 (1 revision) (flutter/flutter#165277) 2025-03-16 [email protected] Roll Fuchsia Linux SDK from LPz5j18JDsms41r3T... to SDNQgVXxHbbd0qsVw... (flutter/flutter#165275) 2025-03-16 [email protected] Roll Dart SDK from 067560bcd521 to 9283d47199b7 (1 revision) (flutter/flutter#165269) 2025-03-16 [email protected] Roll Skia from f124daeb564d to 3413a02d6fc8 (1 revision) (flutter/flutter#165263) 2025-03-15 [email protected] Roll Dart SDK from 40bb66a945e4 to 067560bcd521 (1 revision) (flutter/flutter#165262) 2025-03-15 [email protected] Roll Fuchsia Linux SDK from efdpJgW4DIV6j1mO1... to LPz5j18JDsms41r3T... (flutter/flutter#165252) 2025-03-15 [email protected] Roll Dart SDK from f23d496f0585 to 40bb66a945e4 (1 revision) (flutter/flutter#165250) 2025-03-15 [email protected] Roll Dart SDK from 8814749ec6a4 to f23d496f0585 (1 revision) (flutter/flutter#165246) 2025-03-15 [email protected] Roll Skia from 4568e766ed0a to f124daeb564d (1 revision) (flutter/flutter#165245) 2025-03-15 [email protected] Revert "Prevent explicit roles from merging (#164732)" (flutter/flutter#165222) 2025-03-15 [email protected] Roll Skia from bac6e76abfc7 to 4568e766ed0a (5 revisions) (flutter/flutter#165241) 2025-03-14 [email protected] Roll Dart SDK from a51f1bfa0f6a to 8814749ec6a4 (2 revisions) (flutter/flutter#165227) 2025-03-14 [email protected] Roll Skia from 98b6922deecf to bac6e76abfc7 (5 revisions) (flutter/flutter#165225) 2025-03-14 [email protected] Point ktlint AS docs to the `.editorconfig` that is actually used by ci, instead of making a copy in the README (flutter/flutter#165213) 2025-03-14 [email protected] Add remaining dart fixes for Color deprecations when importing painting.dart (flutter/flutter#162609) 2025-03-14 [email protected] [Accessibility] Add required semantics flags (flutter/flutter#164585) 2025-03-14 [email protected] Roll Skia from f4467ff38f1f to 98b6922deecf (5 revisions) (flutter/flutter#165215) 2025-03-14 [email protected] Convert `BaseFlutterTask` From Groovy to Kotlin (flutter/flutter#163148) 2025-03-14 [email protected] `OverlayPortal.overlayChildLayoutBuilder` (flutter/flutter#164034) 2025-03-14 [email protected] Remove redundant `useMaterial3: true` (flutter/flutter#163376) 2025-03-14 [email protected] Roll Packages from 9cc6f37 to ff7724c (1 revision) (flutter/flutter#165197) 2025-03-14 [email protected] Changelog updates from 3.29.2 (flutter/flutter#165194) 2025-03-14 [email protected] Roll Dart SDK from 576514b2bfce to a51f1bfa0f6a (1 revision) (flutter/flutter#165191) 2025-03-14 [email protected] Roll Dart SDK from ceb58442306e to 576514b2bfce (2 revisions) (flutter/flutter#165180) 2025-03-14 [email protected] Roll Fuchsia Linux SDK from qXOLczyRJadxMW0PK... to efdpJgW4DIV6j1mO1... (flutter/flutter#165175) 2025-03-14 [email protected] [Impeller] Enable mediatek on API 34+. (flutter/flutter#165156) 2025-03-14 [email protected] Roll Dart SDK from cd06d4ba4fec to ceb58442306e (5 revisions) (flutter/flutter#165159) 2025-03-13 [email protected] [FGP conversion] Port `FlutterExtension` from Groovy to Kotlin (flutter/flutter#165143) 2025-03-13 [email protected] Prevent explicit roles from merging (flutter/flutter#164732) ...
…flutter#8922) Manual roll Flutter from b16430b2fd57 to 1d954f4e96bd (114 revisions) Manual roll requested by [email protected] flutter/flutter@b16430b...1d954f4 2025-03-17 [email protected] Revert "[skwasm] Dynamic Threading (#164748)" (flutter/flutter#165350) 2025-03-17 [email protected] Roll Skia from fa669e2e6d12 to 52130e5c3b34 (4 revisions) (flutter/flutter#165348) 2025-03-17 [email protected] `OverlayPortal.childLayoutBuilder` should rebuild when `OverlayPortal` rebuilds. (flutter/flutter#165331) 2025-03-17 [email protected] [web][a11y]Delete _childContainerElement (flutter/flutter#163662) 2025-03-17 [email protected] Roll Skia from e45207898e60 to fa669e2e6d12 (8 revisions) (flutter/flutter#165342) 2025-03-17 [email protected] Add documentation for Java test filtering to plugins test document (flutter/flutter#165314) 2025-03-17 [email protected] Roll Fuchsia Linux SDK from SDNQgVXxHbbd0qsVw... to mPniqXmPpXqMMpM8z... (flutter/flutter#165313) 2025-03-17 [email protected] Roll Dart SDK from 9283d47199b7 to 725172afbc42 (1 revision) (flutter/flutter#165310) 2025-03-17 [email protected] feat(Tooltip): replace the height parameter with constraints (flutter/flutter#163314) 2025-03-17 [email protected] Fix arrowHeadColor breaks differentiation between states (flutter/flutter#165178) 2025-03-17 [email protected] Removes assumption that basis scalar and rounded_scalar match (flutter/flutter#165166) 2025-03-17 [email protected] Roll Skia from 69cf4c2c5db8 to e45207898e60 (1 revision) (flutter/flutter#165300) 2025-03-17 [email protected] Refactor: Move sliders value indicator shape to seperate file (flutter/flutter#162858) 2025-03-17 [email protected] Roll Skia from 3931c31032c7 to 69cf4c2c5db8 (1 revision) (flutter/flutter#165288) 2025-03-17 [email protected] Delete `docs/infra/Infra-Ticket-Queue.md` (flutter/flutter#165258) 2025-03-16 [email protected] Roll Skia from 3413a02d6fc8 to 3931c31032c7 (1 revision) (flutter/flutter#165277) 2025-03-16 [email protected] Roll Fuchsia Linux SDK from LPz5j18JDsms41r3T... to SDNQgVXxHbbd0qsVw... (flutter/flutter#165275) 2025-03-16 [email protected] Roll Dart SDK from 067560bcd521 to 9283d47199b7 (1 revision) (flutter/flutter#165269) 2025-03-16 [email protected] Roll Skia from f124daeb564d to 3413a02d6fc8 (1 revision) (flutter/flutter#165263) 2025-03-15 [email protected] Roll Dart SDK from 40bb66a945e4 to 067560bcd521 (1 revision) (flutter/flutter#165262) 2025-03-15 [email protected] Roll Fuchsia Linux SDK from efdpJgW4DIV6j1mO1... to LPz5j18JDsms41r3T... (flutter/flutter#165252) 2025-03-15 [email protected] Roll Dart SDK from f23d496f0585 to 40bb66a945e4 (1 revision) (flutter/flutter#165250) 2025-03-15 [email protected] Roll Dart SDK from 8814749ec6a4 to f23d496f0585 (1 revision) (flutter/flutter#165246) 2025-03-15 [email protected] Roll Skia from 4568e766ed0a to f124daeb564d (1 revision) (flutter/flutter#165245) 2025-03-15 [email protected] Revert "Prevent explicit roles from merging (#164732)" (flutter/flutter#165222) 2025-03-15 [email protected] Roll Skia from bac6e76abfc7 to 4568e766ed0a (5 revisions) (flutter/flutter#165241) 2025-03-14 [email protected] Roll Dart SDK from a51f1bfa0f6a to 8814749ec6a4 (2 revisions) (flutter/flutter#165227) 2025-03-14 [email protected] Roll Skia from 98b6922deecf to bac6e76abfc7 (5 revisions) (flutter/flutter#165225) 2025-03-14 [email protected] Point ktlint AS docs to the `.editorconfig` that is actually used by ci, instead of making a copy in the README (flutter/flutter#165213) 2025-03-14 [email protected] Add remaining dart fixes for Color deprecations when importing painting.dart (flutter/flutter#162609) 2025-03-14 [email protected] [Accessibility] Add required semantics flags (flutter/flutter#164585) 2025-03-14 [email protected] Roll Skia from f4467ff38f1f to 98b6922deecf (5 revisions) (flutter/flutter#165215) 2025-03-14 [email protected] Convert `BaseFlutterTask` From Groovy to Kotlin (flutter/flutter#163148) 2025-03-14 [email protected] `OverlayPortal.overlayChildLayoutBuilder` (flutter/flutter#164034) 2025-03-14 [email protected] Remove redundant `useMaterial3: true` (flutter/flutter#163376) 2025-03-14 [email protected] Roll Packages from 9cc6f37 to ff7724c (1 revision) (flutter/flutter#165197) 2025-03-14 [email protected] Changelog updates from 3.29.2 (flutter/flutter#165194) 2025-03-14 [email protected] Roll Dart SDK from 576514b2bfce to a51f1bfa0f6a (1 revision) (flutter/flutter#165191) 2025-03-14 [email protected] Roll Dart SDK from ceb58442306e to 576514b2bfce (2 revisions) (flutter/flutter#165180) 2025-03-14 [email protected] Roll Fuchsia Linux SDK from qXOLczyRJadxMW0PK... to efdpJgW4DIV6j1mO1... (flutter/flutter#165175) 2025-03-14 [email protected] [Impeller] Enable mediatek on API 34+. (flutter/flutter#165156) 2025-03-14 [email protected] Roll Dart SDK from cd06d4ba4fec to ceb58442306e (5 revisions) (flutter/flutter#165159) 2025-03-13 [email protected] [FGP conversion] Port `FlutterExtension` from Groovy to Kotlin (flutter/flutter#165143) 2025-03-13 [email protected] Prevent explicit roles from merging (flutter/flutter#164732) ...
… (#8922) Manual roll Flutter from b16430b2fd57 to 1d954f4e96bd (114 revisions) Manual roll requested by [email protected] flutter/flutter@b16430b...1d954f4 2025-03-17 [email protected] Revert "[skwasm] Dynamic Threading (#164748)" (flutter/flutter#165350) 2025-03-17 [email protected] Roll Skia from fa669e2e6d12 to 52130e5c3b34 (4 revisions) (flutter/flutter#165348) 2025-03-17 [email protected] `OverlayPortal.childLayoutBuilder` should rebuild when `OverlayPortal` rebuilds. (flutter/flutter#165331) 2025-03-17 [email protected] [web][a11y]Delete _childContainerElement (flutter/flutter#163662) 2025-03-17 [email protected] Roll Skia from e45207898e60 to fa669e2e6d12 (8 revisions) (flutter/flutter#165342) 2025-03-17 [email protected] Add documentation for Java test filtering to plugins test document (flutter/flutter#165314) 2025-03-17 [email protected] Roll Fuchsia Linux SDK from SDNQgVXxHbbd0qsVw... to mPniqXmPpXqMMpM8z... (flutter/flutter#165313) 2025-03-17 [email protected] Roll Dart SDK from 9283d47199b7 to 725172afbc42 (1 revision) (flutter/flutter#165310) 2025-03-17 [email protected] feat(Tooltip): replace the height parameter with constraints (flutter/flutter#163314) 2025-03-17 [email protected] Fix arrowHeadColor breaks differentiation between states (flutter/flutter#165178) 2025-03-17 [email protected] Removes assumption that basis scalar and rounded_scalar match (flutter/flutter#165166) 2025-03-17 [email protected] Roll Skia from 69cf4c2c5db8 to e45207898e60 (1 revision) (flutter/flutter#165300) 2025-03-17 [email protected] Refactor: Move sliders value indicator shape to seperate file (flutter/flutter#162858) 2025-03-17 [email protected] Roll Skia from 3931c31032c7 to 69cf4c2c5db8 (1 revision) (flutter/flutter#165288) 2025-03-17 [email protected] Delete `docs/infra/Infra-Ticket-Queue.md` (flutter/flutter#165258) 2025-03-16 [email protected] Roll Skia from 3413a02d6fc8 to 3931c31032c7 (1 revision) (flutter/flutter#165277) 2025-03-16 [email protected] Roll Fuchsia Linux SDK from LPz5j18JDsms41r3T... to SDNQgVXxHbbd0qsVw... (flutter/flutter#165275) 2025-03-16 [email protected] Roll Dart SDK from 067560bcd521 to 9283d47199b7 (1 revision) (flutter/flutter#165269) 2025-03-16 [email protected] Roll Skia from f124daeb564d to 3413a02d6fc8 (1 revision) (flutter/flutter#165263) 2025-03-15 [email protected] Roll Dart SDK from 40bb66a945e4 to 067560bcd521 (1 revision) (flutter/flutter#165262) 2025-03-15 [email protected] Roll Fuchsia Linux SDK from efdpJgW4DIV6j1mO1... to LPz5j18JDsms41r3T... (flutter/flutter#165252) 2025-03-15 [email protected] Roll Dart SDK from f23d496f0585 to 40bb66a945e4 (1 revision) (flutter/flutter#165250) 2025-03-15 [email protected] Roll Dart SDK from 8814749ec6a4 to f23d496f0585 (1 revision) (flutter/flutter#165246) 2025-03-15 [email protected] Roll Skia from 4568e766ed0a to f124daeb564d (1 revision) (flutter/flutter#165245) 2025-03-15 [email protected] Revert "Prevent explicit roles from merging (#164732)" (flutter/flutter#165222) 2025-03-15 [email protected] Roll Skia from bac6e76abfc7 to 4568e766ed0a (5 revisions) (flutter/flutter#165241) 2025-03-14 [email protected] Roll Dart SDK from a51f1bfa0f6a to 8814749ec6a4 (2 revisions) (flutter/flutter#165227) 2025-03-14 [email protected] Roll Skia from 98b6922deecf to bac6e76abfc7 (5 revisions) (flutter/flutter#165225) 2025-03-14 [email protected] Point ktlint AS docs to the `.editorconfig` that is actually used by ci, instead of making a copy in the README (flutter/flutter#165213) 2025-03-14 [email protected] Add remaining dart fixes for Color deprecations when importing painting.dart (flutter/flutter#162609) 2025-03-14 [email protected] [Accessibility] Add required semantics flags (flutter/flutter#164585) 2025-03-14 [email protected] Roll Skia from f4467ff38f1f to 98b6922deecf (5 revisions) (flutter/flutter#165215) 2025-03-14 [email protected] Convert `BaseFlutterTask` From Groovy to Kotlin (flutter/flutter#163148) 2025-03-14 [email protected] `OverlayPortal.overlayChildLayoutBuilder` (flutter/flutter#164034) 2025-03-14 [email protected] Remove redundant `useMaterial3: true` (flutter/flutter#163376) 2025-03-14 [email protected] Roll Packages from bdb9c96 to d632936 (1 revision) (flutter/flutter#165197) 2025-03-14 [email protected] Changelog updates from 3.29.2 (flutter/flutter#165194) 2025-03-14 [email protected] Roll Dart SDK from 576514b2bfce to a51f1bfa0f6a (1 revision) (flutter/flutter#165191) 2025-03-14 [email protected] Roll Dart SDK from ceb58442306e to 576514b2bfce (2 revisions) (flutter/flutter#165180) 2025-03-14 [email protected] Roll Fuchsia Linux SDK from qXOLczyRJadxMW0PK... to efdpJgW4DIV6j1mO1... (flutter/flutter#165175) 2025-03-14 [email protected] [Impeller] Enable mediatek on API 34+. (flutter/flutter#165156) 2025-03-14 [email protected] Roll Dart SDK from cd06d4ba4fec to ceb58442306e (5 revisions) (flutter/flutter#165159) 2025-03-13 [email protected] [FGP conversion] Port `FlutterExtension` from Groovy to Kotlin (flutter/flutter#165143) 2025-03-13 [email protected] Prevent explicit roles from merging (flutter/flutter#164732) ...
Converted
BaseFlutterTask
from Groovy to Kotlin.Note: Since it looks like Gradle prevents us from instantiating and using an object that extends abstract class BaseFlutterTask, we must use principles of Test Driven Development (TDD) in order to unit test
BaseFlutterTask
.BaseFlutterTaskHelper
was created solely for unit testing to simulate the behavior of all functions in the originalBaseFlutterTask
.Fixes #162111
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.