diff --git a/script/tool/CHANGELOG.md b/script/tool/CHANGELOG.md index 17b28927538d..1e447721d13f 100644 --- a/script/tool/CHANGELOG.md +++ b/script/tool/CHANGELOG.md @@ -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 diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index c67fb96d2835..d09a94b1aefe 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -244,9 +244,12 @@ class FormatCommand extends PluginCommand { /// Returns true if [command] can be run successfully. Future _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, ['--version']); + await processRunner.run(command, [versionFlag]); if (result.exitCode != 0) { return false; } diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index 7dadc598d4b4..7b2cdd4f4101 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml @@ -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 diff --git a/script/tool/test/format_command_test.dart b/script/tool/test/format_command_test.dart index 4728c3136556..b072e5d30aaf 100644 --- a/script/tool/test/format_command_test.dart +++ b/script/tool/test/format_command_test.dart @@ -146,7 +146,7 @@ void main() { expect( processRunner.recordedCalls, orderedEquals([ - const ProcessCall('java', ['--version'], null), + const ProcessCall('java', ['-version'], null), ProcessCall( 'java', [