Unverified Commit df90bb5f authored by Mubarak Imam's avatar Mubarak Imam Committed by GitHub

fix issue with multiple java runtimes on macOS (#52474)

parent c6665e43
......@@ -583,14 +583,13 @@ class AndroidSdk {
if (platform.isMacOS) {
try {
final String javaHomeOutput = processUtils.runSync(
<String>['/usr/libexec/java_home'],
<String>['/usr/libexec/java_home', '-v', '1.8'],
throwOnError: true,
hideStdout: true,
).stdout.trim();
if (javaHomeOutput != null) {
final List<String> javaHomeOutputSplit = javaHomeOutput.split('\n');
if ((javaHomeOutputSplit != null) && (javaHomeOutputSplit.isNotEmpty)) {
final String javaHome = javaHomeOutputSplit[0].trim();
if ((javaHomeOutput != null) && (javaHomeOutput.isNotEmpty)) {
final String javaHome = javaHomeOutput.split('\n').last.trim();
return fileSystem.path.join(javaHome, 'bin', 'java');
}
}
......
......@@ -98,7 +98,7 @@ void main() {
.thenReturn(ProcessResult(1, 0, '26.1.1\n', ''));
if (globals.platform.isMacOS) {
when(globals.processManager.runSync(
<String>['/usr/libexec/java_home'],
<String>['/usr/libexec/java_home', '-v', '1.8'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(0, 0, '', ''));
......@@ -137,7 +137,7 @@ void main() {
.thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error'));
if (globals.platform.isMacOS) {
when(globals.processManager.runSync(
<String>['/usr/libexec/java_home'],
<String>['/usr/libexec/java_home', '-v', '1.8'],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(0, 0, '', ''));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment