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 { ...@@ -583,14 +583,13 @@ class AndroidSdk {
if (platform.isMacOS) { if (platform.isMacOS) {
try { try {
final String javaHomeOutput = processUtils.runSync( final String javaHomeOutput = processUtils.runSync(
<String>['/usr/libexec/java_home'], <String>['/usr/libexec/java_home', '-v', '1.8'],
throwOnError: true, throwOnError: true,
hideStdout: true, hideStdout: true,
).stdout.trim(); ).stdout.trim();
if (javaHomeOutput != null) { if (javaHomeOutput != null) {
final List<String> javaHomeOutputSplit = javaHomeOutput.split('\n'); if ((javaHomeOutput != null) && (javaHomeOutput.isNotEmpty)) {
if ((javaHomeOutputSplit != null) && (javaHomeOutputSplit.isNotEmpty)) { final String javaHome = javaHomeOutput.split('\n').last.trim();
final String javaHome = javaHomeOutputSplit[0].trim();
return fileSystem.path.join(javaHome, 'bin', 'java'); return fileSystem.path.join(javaHome, 'bin', 'java');
} }
} }
......
...@@ -98,7 +98,7 @@ void main() { ...@@ -98,7 +98,7 @@ void main() {
.thenReturn(ProcessResult(1, 0, '26.1.1\n', '')); .thenReturn(ProcessResult(1, 0, '26.1.1\n', ''));
if (globals.platform.isMacOS) { if (globals.platform.isMacOS) {
when(globals.processManager.runSync( when(globals.processManager.runSync(
<String>['/usr/libexec/java_home'], <String>['/usr/libexec/java_home', '-v', '1.8'],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenReturn(ProcessResult(0, 0, '', '')); )).thenReturn(ProcessResult(0, 0, '', ''));
...@@ -137,7 +137,7 @@ void main() { ...@@ -137,7 +137,7 @@ void main() {
.thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error')); .thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error'));
if (globals.platform.isMacOS) { if (globals.platform.isMacOS) {
when(globals.processManager.runSync( when(globals.processManager.runSync(
<String>['/usr/libexec/java_home'], <String>['/usr/libexec/java_home', '-v', '1.8'],
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'), environment: anyNamed('environment'),
)).thenReturn(ProcessResult(0, 0, '', '')); )).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