Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] Use -version with java #4171

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion script/tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 4 additions & 1 deletion script/tool/lib/src/format_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion script/tool/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion script/tool/test/format_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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>[
Expand Down