Skip to content

Commit

Permalink
chore: Use java latest for android SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Dec 9, 2024
1 parent 043c86f commit 5b6cb6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion UnoCheck/Checkups/AndroidEmulatorCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override Task<DiagnosticResult> Examine(SharedState history)

AndroidSdk.AvdManager avdManager = null;

var javaHome = history.GetEnvironmentVariable("JAVA_HOME");
var javaHome = history.GetEnvironmentVariable("LATEST_JAVA_HOME") ?? history.GetEnvironmentVariable("JAVA_HOME");
string java = null;
if (!string.IsNullOrEmpty(javaHome) && Directory.Exists(javaHome))
java = Path.Combine(javaHome, "bin", "java" + (Util.IsWindows ? ".exe" : ""));
Expand Down
12 changes: 10 additions & 2 deletions UnoCheck/Checkups/OpenJdkCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public override Task<DiagnosticResult> Examine(SharedState history)

var jdks = xamJdks.Concat(FindJdks())
.GroupBy(j => j.Directory.FullName)
.Select(g => g.First());
.Select(g => g.First())
.OrderBy(s => s.Version);

var ok = false;

Expand Down Expand Up @@ -96,7 +97,14 @@ public override Task<DiagnosticResult> Examine(SharedState history)
ReportStatus($"{jdk.Version} ({jdk.Directory.FullName})", null);
}

if (ok)
// Setup the latest LATEST_JAVA_HOME
if (jdks.Any())
{
var latest = jdks.Last();
history.SetEnvironmentVariable("LATEST_JAVA_HOME", latest.Directory.FullName);
}

if (ok)
return Task.FromResult(DiagnosticResult.Ok(this));

if (Util.IsLinux)
Expand Down

0 comments on commit 5b6cb6f

Please sign in to comment.