Skip to content

Commit c5732a0

Browse files
committed
[Xamarin.Android.Tools.AndroidSdk] Support Microsoft Dist JDK (#117)
Partially reverts commit 237642c. The plan to remove support for the obsolete `microsoft_dist_openjdk_` JDK distribution has hit a few "snags", and thus we cannot remove support for the legacy `microsoft_dist_openjdk_` package as quickly as we had hoped. Re-introduce support for the `microsoft_dist_openjdk_` JDK installation location.
1 parent 52ef989 commit c5732a0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
292292
.Concat (AzulJdkLocations.GetAzulJdks (logger))
293293
.Concat (OracleJdkLocations.GetOracleJdks (logger))
294294
.Concat (VSAndroidJdkLocations.GetVSAndroidJdks (logger))
295+
.Concat (MicrosoftDistJdkLocations.GetMicrosoftDistJdks (logger))
295296
.Concat (GetEnvironmentVariableJdks ("JAVA_HOME", logger))
296297
.Concat (GetPathEnvironmentJdks (logger))
297298
.Concat (GetLibexecJdks (logger))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
8+
namespace Xamarin.Android.Tools {
9+
10+
class MicrosoftDistJdkLocations : JdkLocations {
11+
12+
internal static IEnumerable<JdkInfo> GetMicrosoftDistJdks (Action<TraceLevel, string> logger)
13+
{
14+
return FromPaths (GetMacOSMicrosoftDistJdkPaths (), logger, "$HOME/Library/Developer/Xamarin/jdk")
15+
.Concat (GetWindowsFileSystemJdks (Path.Combine ("Android", "jdk", "microsoft_dist_openjdk_*"), logger, locator: "legacy microsoft_dist_openjdk"))
16+
.OrderByDescending (jdk => jdk, JdkInfoVersionComparer.Default);
17+
}
18+
19+
static IEnumerable<string> GetMacOSMicrosoftDistJdkPaths ()
20+
{
21+
var jdks = AppDomain.CurrentDomain.GetData ($"GetMacOSMicrosoftJdkPaths jdks override! {typeof (JdkInfo).AssemblyQualifiedName}")
22+
?.ToString ();
23+
if (jdks == null) {
24+
var home = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
25+
jdks = Path.Combine (home, "Library", "Developer", "Xamarin", "jdk");
26+
}
27+
if (!Directory.Exists (jdks))
28+
return Enumerable.Empty <string> ();
29+
30+
return Directory.EnumerateDirectories (jdks);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)