-
Notifications
You must be signed in to change notification settings - Fork 29.7k
[tools] allow explicitly specifying the JDK to use via a new config setting #128264
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
Conversation
| argParser.addOption('jdk-dir', help: 'The Java Development Kit (JDK) install/home directory. ' | ||
| 'If unset, flutter will search for one in the following order:\n' | ||
| ' 1) the JDK bundled with the latest installation of Android Studio,\n' | ||
| ' 2) the JDK found at the directory found in the JAVA_HOME environment variable, and\n' | ||
| " 3) the directory containing the java binary found in the user's path."); |
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'd like to get this ordered list to be indented, but I couldn't find a way to do this. Indenting with spaces or using \t doesn't seem to work as this seems to get removed in the output. (The spaces currently here are there to satisfy args_test.dart). Here is the output from flutter config:
--android-sdk The Android SDK directory.
--android-studio-dir The Android Studio install directory. If unset, flutter will search for valid installs at well-known locations.
--jdk-dir The Java Development Kit (JDK) install/home directory. If unset, flutter will search for one in the following order:
1) the JDK bundled with the latest installation of Android Studio,
2) the JDK found at the directory found in the JAVA_HOME environment variable, and
3) the directory containing the java binary found in the user's path.
--build-dir=<out/> The relative path to override a projects build directory.
--[no-]enable-web Enable or disable Flutter for web.
| }) { | ||
| final Object? configured = config.getValue('jdk-dir'); | ||
| if (configured != null) { | ||
| return configured as String; |
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, doesn't need to be in this PR, but should we move these casts to be methods on the Config class? That way it will be easier and more obvious how to refactor.
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.
Co-authored-by: Christopher Fujino <[email protected]>
| _updateConfig('android-studio-dir', stringArg('android-studio-dir')!); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('jdk-dir') ?? false) { |
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 here (and throughout this function) we should just cast argResults to a non-nullable value and get rid of all the nullable fallbacks.
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. I used non-null assertions. See commit within ConfigCommand.runCommand, assert argResults in non-null [sic.]
| } | ||
| final Java? java = globals.java; | ||
| if (results['jdk-dir'] == null && java != null) { | ||
| results['jdk-dir'] = java.javaHome; |
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 actually surprising to me, but I suppose we shouldn't break this.
| expect(jsonObject['android-sdk'], isNotNull); | ||
|
|
||
| expect(jsonObject.containsKey('jdk-dir'), true); | ||
| expect(jsonObject['jdk-dir'], isNotNull); |
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.
for these and the other isNotNull expectations in this test, can we expect on the actual value, to verify we're not letting the real implementations leak through?
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 with commit make machine flag test more precise.
This made me realize the inconsistency with some of these fields. AndroidStudio.directory is a string, AndroidSdk.directory is a Directory, and Java.javaHome doesn't fit into the <class>.directory scheme.
| }, | ||
| ); | ||
|
|
||
| final Java? java = Java.find( |
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.
Can you actually call Java.find() twice in this test, once before config.setValue('jdk-dir', ...) and once after, expecting the results are different?
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.
Isn't this already implicitly covered by the other tests?
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.
We can only rely on other tests verifying the exact setup of this test if we know that now and forever this test and the dependent test are set up in exactly the same way. Also that that other test is never deleted.
In other words, I would say that this test is not completely verifying that Java.find() is finding java.javaHome via the Config (it could be now or in the future across refactors accidentally getting the right answer from the local configuration).
christopherfujino
left a comment
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
Roll Flutter from 0b74153 to 8a5c22e (46 revisions) flutter/flutter@0b74153...8a5c22e 2023-06-07 [email protected] Super tiny MediaQuery doc update (flutter/flutter#127904) 2023-06-07 [email protected] Revert "Make inspector weakly referencing the inspected objects." (flutter/flutter#128436) 2023-06-07 [email protected] Update menu API docs to help developers migrate to m3 (flutter/flutter#128351) 2023-06-07 [email protected] [tools] allow explicitly specifying the JDK to use via a new config setting (flutter/flutter#128264) 2023-06-07 [email protected] Roll Flutter Engine from 6f9df0f988c1 to 59d5444cf06c (3 revisions) (flutter/flutter#128376) 2023-06-07 [email protected] Do not try to load main/default asset image if only higher-res variants exist (flutter/flutter#128143) 2023-06-07 [email protected] Addressed Ambiguity in transform.scale constructor docs (flutter/flutter#128182) 2023-06-07 [email protected] Super tiny fix of dead link (flutter/flutter#128160) 2023-06-07 [email protected] Refactor tests (flutter/flutter#128371) 2023-06-07 [email protected] Make inspector weakly referencing the inspected objects. (flutter/flutter#128095) 2023-06-07 [email protected] Add viewId to PointerEvents (flutter/flutter#128287) 2023-06-07 [email protected] Show error message in release mode when box is not laid out without losing performance (flutter/flutter#126302) 2023-06-06 [email protected] Roll Flutter Engine from ca499463ec2e to 6f9df0f988c1 (1 revision) (flutter/flutter#128363) 2023-06-06 [email protected] Update Draggable YouTube video link (flutter/flutter#128078) 2023-06-06 [email protected] Remove more rounding hacks from TextPainter (flutter/flutter#127826) 2023-06-06 [email protected] Roll Flutter Engine from 4571695f9e76 to ca499463ec2e (1 revision) (flutter/flutter#128356) 2023-06-06 [email protected] [Android] Update plugin and module templates to use Flutter constant for `compileSdkVersion` (flutter/flutter#128073) 2023-06-06 [email protected] handleSelectWord in MultiSelectableSelectionContainerDelegate should handle rects inside of rects (flutter/flutter#127478) 2023-06-06 [email protected] [flutter_tools] never tree shake 0x20 (space) font codepoints on web (flutter/flutter#128302) 2023-06-06 [email protected] Remove `textScaleFactor` dependent logic from `AppBar` (flutter/flutter#128112) 2023-06-06 [email protected] Roll Flutter Engine from b6d37f8f74ad to 4571695f9e76 (6 revisions) (flutter/flutter#128350) 2023-06-06 [email protected] Fix `Null check operator used on a null value` on TextField with contextMenuBuilder (flutter/flutter#128114) 2023-06-06 [email protected] Roll Packages from db4e5c2 to da72219 (10 revisions) (flutter/flutter#128348) 2023-06-06 [email protected] Updating cirrus docker image to ubuntu focal. (flutter/flutter#128291) 2023-06-06 [email protected] Adding example for migrating to navigation drawer (flutter/flutter#128295) 2023-06-06 [email protected] Roll Flutter Engine from 722aad83e5fe to b6d37f8f74ad (2 revisions) (flutter/flutter#128341) 2023-06-06 [email protected] Clean-up viewId casts in flutter_test (flutter/flutter#128256) 2023-06-06 [email protected] Update cherry-pick issue template to more uniform labels. (flutter/flutter#128333) 2023-06-06 [email protected] Use Material3 in the 2D viewport tests (flutter/flutter#128155) 2023-06-06 [email protected] Use a `show` over a `hide` for `test_api` exports (flutter/flutter#128298) 2023-06-06 [email protected] Roll Flutter Engine from aaa7574375a6 to 722aad83e5fe (1 revision) (flutter/flutter#128307) 2023-06-06 [email protected] Migration guide for moving from BottomNavigationBar to NavigationBar (flutter/flutter#128263) 2023-06-06 [email protected] [web] Use 'Uri' instead of 'dart:html' to extract pathname (flutter/flutter#127983) 2023-06-06 [email protected] Roll Flutter Engine from 2b353ae90731 to aaa7574375a6 (4 revisions) (flutter/flutter#128301) 2023-06-05 [email protected] Roll Flutter Engine from 220ece4d9faa to 2b353ae90731 (1 revision) (flutter/flutter#128293) 2023-06-05 49699333+dependabot[bot]@users.noreply.github.com Bump actions/labeler from 4.0.4 to 4.1.0 (flutter/flutter#128290) 2023-06-05 [email protected] Roll Flutter Engine from 7f12e3497428 to 220ece4d9faa (6 revisions) (flutter/flutter#128282) 2023-06-05 [email protected] [framework] attempt non-key solution (flutter/flutter#128273) 2023-06-05 [email protected] [labeler] Fix adding labels when name is directory (flutter/flutter#128243) 2023-06-05 [email protected] Remove scrollbar deprecations isAlwaysShown and hoverThickness (flutter/flutter#127351) 2023-06-05 [email protected] Fix update drag error that made NestedScrollView un-scrollable (flutter/flutter#127718) 2023-06-05 [email protected] Roll Flutter Engine from f9f72388a4da to 7f12e3497428 (4 revisions) (flutter/flutter#128271) 2023-06-05 [email protected] Migrate SemanticsBinding to onSemanticsActionEvent (flutter/flutter#128254) 2023-06-05 [email protected] Roll Flutter Engine from c838a1b05924 to f9f72388a4da (19 revisions) (flutter/flutter#128252) 2023-06-05 [email protected] [framework] force flexible space background to rebuild. (flutter/flutter#128138) 2023-06-05 [email protected] Roll Packages from 75085ed to db4e5c2 (4 revisions) (flutter/flutter#128246) ...
Closes #106416.
This PR adds a new
flutter configsetting namedjdk-dir. When set, the tool will use the JDK found at this location for all Java-dependent tool operations such as building Android apps via gradle and running Android SDK tools.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.