[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

@ -1,6 +1,8 @@
## NEXT
## 0.4.1
- Improved `license-check` output.
- Use `java -version` rather than `java --version`, for compatibility with more
versions of Java.
## 0.4.0

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;
}

View File

@ -1,7 +1,7 @@
name: flutter_plugin_tools
description: Productivity utils for flutter/plugins and flutter/packages
repository: https://github.com/flutter/plugins/tree/master/script/tool
version: 0.4.0
version: 0.4.1
dependencies:
args: ^2.1.0

View File

@ -146,7 +146,7 @@ void main() {
expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
const ProcessCall('java', <String>['--version'], null),
const ProcessCall('java', <String>['-version'], null),
ProcessCall(
'java',
<String>[