-
Notifications
You must be signed in to change notification settings - Fork 29.4k
[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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3296e56
add jdk-dir config item
andrewkolos 43baf74
reformat
andrewkolos 87bfbe9
remove tests redundant with java_test.dart
andrewkolos f6c1d95
lint
andrewkolos 1d3e528
fix test fake
andrewkolos 63ce53f
remove extra new line
andrewkolos 36a4582
simplify wording
andrewkolos 8300ebb
remove extraneous call to Java.find
andrewkolos d24ac4e
Merge branch 'add-jdk-config-item' of https://github.com/andrewkolos/…
andrewkolos c995e80
within ConfigCommand.runCommand, assert argResults in non-null
andrewkolos f45814e
make machine flag test more precise
andrewkolos b01850e
remove no longer necessary parameters to AndroidLicenseValidator
andrewkolos 530805f
test Java.find after unsetting jdk-dir
andrewkolos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| import '../../src/android/android_sdk.dart'; | ||
| import '../../src/android/android_studio.dart'; | ||
| import '../android/java.dart'; | ||
| import '../base/common.dart'; | ||
| import '../convert.dart'; | ||
| import '../features.dart'; | ||
|
|
@@ -19,7 +20,12 @@ class ConfigCommand extends FlutterCommand { | |
| negatable: false, | ||
| help: 'Clear the saved development certificate choice used to sign apps for iOS device deployment.'); | ||
| argParser.addOption('android-sdk', help: 'The Android SDK directory.'); | ||
| argParser.addOption('android-studio-dir', help: 'The Android Studio install directory. If unset, flutter will search for valid installs at well-known locations.'); | ||
| argParser.addOption('android-studio-dir', help: 'The Android Studio installation directory. If unset, flutter will search for valid installations at well-known locations.'); | ||
| argParser.addOption('jdk-dir', help: 'The Java Development Kit (JDK) installation 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."); | ||
| argParser.addOption('build-dir', help: 'The relative path to override a projects build directory.', | ||
| valueHelp: 'out/'); | ||
| argParser.addFlag('machine', | ||
|
|
@@ -101,7 +107,7 @@ class ConfigCommand extends FlutterCommand { | |
|
|
||
| @override | ||
| Future<FlutterCommandResult> runCommand() async { | ||
| final List<String> rest = argResults?.rest ?? <String>[]; | ||
| final List<String> rest = argResults!.rest; | ||
| if (rest.isNotEmpty) { | ||
| throwToolExit(exitCode: 2, | ||
| 'error: flutter config: Too many arguments.\n' | ||
|
|
@@ -126,7 +132,7 @@ class ConfigCommand extends FlutterCommand { | |
| return FlutterCommandResult.success(); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('analytics') ?? false) { | ||
| if (argResults!.wasParsed('analytics')) { | ||
| final bool value = boolArg('analytics'); | ||
| // The tool sends the analytics event *before* toggling the flag | ||
| // intentionally to be sure that opt-out events are sent correctly. | ||
|
|
@@ -146,19 +152,23 @@ class ConfigCommand extends FlutterCommand { | |
| await globals.analytics.setTelemetry(value); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('android-sdk') ?? false) { | ||
| if (argResults!.wasParsed('android-sdk')) { | ||
| _updateConfig('android-sdk', stringArg('android-sdk')!); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('android-studio-dir') ?? false) { | ||
| if (argResults!.wasParsed('android-studio-dir')) { | ||
| _updateConfig('android-studio-dir', stringArg('android-studio-dir')!); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('clear-ios-signing-cert') ?? false) { | ||
| if (argResults!.wasParsed('jdk-dir')) { | ||
| _updateConfig('jdk-dir', stringArg('jdk-dir')!); | ||
| } | ||
|
|
||
| if (argResults!.wasParsed('clear-ios-signing-cert')) { | ||
| _updateConfig('ios-signing-cert', ''); | ||
| } | ||
|
|
||
| if (argResults?.wasParsed('build-dir') ?? false) { | ||
| if (argResults!.wasParsed('build-dir')) { | ||
| final String buildDir = stringArg('build-dir')!; | ||
| if (globals.fs.path.isAbsolute(buildDir)) { | ||
| throwToolExit('build-dir should be a relative path'); | ||
|
|
@@ -171,7 +181,7 @@ class ConfigCommand extends FlutterCommand { | |
| if (configSetting == null) { | ||
| continue; | ||
| } | ||
| if (argResults?.wasParsed(configSetting) ?? false) { | ||
| if (argResults!.wasParsed(configSetting)) { | ||
| final bool keyValue = boolArg(configSetting); | ||
| globals.config.setValue(configSetting, keyValue); | ||
| globals.printStatus('Setting "$configSetting" value to "$keyValue".'); | ||
|
|
@@ -203,6 +213,10 @@ class ConfigCommand extends FlutterCommand { | |
| if (results['android-sdk'] == null && androidSdk != null) { | ||
| results['android-sdk'] = androidSdk.directory.path; | ||
| } | ||
| 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 commentThe 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. |
||
| } | ||
|
|
||
| globals.printStatus(const JsonEncoder.withIndent(' ').convert(results)); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Configclass? 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.
Filed [tools] Consider adding getter methods to Config that cast values for convenience #128278