[flutter_plugin_tools] Use -version with java (#4171)

This commit is contained in:
stuartmorgan
2021-07-20 10:01:07 -07:00
committed by GitHub
parent ca5e753486
commit a206782759
4 changed files with 9 additions and 4 deletions

View File

@ -244,9 +244,12 @@ class FormatCommand extends PluginCommand {
/// Returns true if [command] can be run successfully.
Future<bool> _hasDependency(String command) async {
// Some versions of Java accept both -version and --version, but some only
// accept -version.
final String versionFlag = command == 'java' ? '-version' : '--version';
try {
final io.ProcessResult result =
await processRunner.run(command, <String>['--version']);
await processRunner.run(command, <String>[versionFlag]);
if (result.exitCode != 0) {
return false;
}