Skip to content

Commit cfbed4f

Browse files
stuartmorgan-gfotiDim
authored andcommitted
[flutter_plugin_tools] Use -version with java (flutter#4171)
1 parent 6b4ae35 commit cfbed4f

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

script/tool/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 0.4.1
22

33
- Improved `license-check` output.
4+
- Use `java -version` rather than `java --version`, for compatibility with more
5+
versions of Java.
46

57
## 0.4.0
68

script/tool/lib/src/format_command.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,12 @@ class FormatCommand extends PluginCommand {
244244

245245
/// Returns true if [command] can be run successfully.
246246
Future<bool> _hasDependency(String command) async {
247+
// Some versions of Java accept both -version and --version, but some only
248+
// accept -version.
249+
final String versionFlag = command == 'java' ? '-version' : '--version';
247250
try {
248251
final io.ProcessResult result =
249-
await processRunner.run(command, <String>['--version']);
252+
await processRunner.run(command, <String>[versionFlag]);
250253
if (result.exitCode != 0) {
251254
return false;
252255
}

script/tool/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_plugin_tools
22
description: Productivity utils for flutter/plugins and flutter/packages
33
repository: https://github.com/flutter/plugins/tree/master/script/tool
4-
version: 0.4.0
4+
version: 0.4.1
55

66
dependencies:
77
args: ^2.1.0

script/tool/test/format_command_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void main() {
146146
expect(
147147
processRunner.recordedCalls,
148148
orderedEquals(<ProcessCall>[
149-
const ProcessCall('java', <String>['--version'], null),
149+
const ProcessCall('java', <String>['-version'], null),
150150
ProcessCall(
151151
'java',
152152
<String>[

0 commit comments

Comments
 (0)