[tools] use Java class for all java-searching behavior (#127354)
Fixes #124252, finishing work on the umbrella tracking issue, #126126. Essentially, after this PR, no (non-test) code should be be referencing/invoking the java home or binary paths.
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:flutter_tools/src/features.dart';
|
||||
@@ -619,15 +620,12 @@ class FakeJava extends Fake implements Java {
|
||||
FakeJava({
|
||||
this.javaHome = '/android-studio/jbr',
|
||||
String binary = '/android-studio/jbr/bin/java',
|
||||
JavaVersion? version,
|
||||
Version? version,
|
||||
bool canRun = true,
|
||||
}): binaryPath = binary,
|
||||
version = version ?? JavaVersion(
|
||||
longText: 'openjdk 19.0.2 2023-01-17',
|
||||
number: '19.0.2',
|
||||
),
|
||||
version = version ?? const Version.withText(19, 0, 2, 'openjdk 19.0.2 2023-01-17'),
|
||||
_environment = <String, String>{
|
||||
if (javaHome != null) 'JAVA_HOME': javaHome,
|
||||
if (javaHome != null) Java.javaHomeEnvironmentVariable: javaHome,
|
||||
'PATH': '/android-studio/jbr/bin',
|
||||
},
|
||||
_canRun = canRun;
|
||||
@@ -645,7 +643,7 @@ class FakeJava extends Fake implements Java {
|
||||
Map<String, String> get environment => _environment;
|
||||
|
||||
@override
|
||||
JavaVersion? version;
|
||||
Version? version;
|
||||
|
||||
@override
|
||||
bool canRun() {
|
||||
|
||||
Reference in New Issue
Block a user