-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Xamarin.Android.Tools.AndroidSdk/Jdks/MicrosoftDistJdkLocations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Xamarin.Android.Tools { | ||
|
||
class MicrosoftDistJdkLocations : JdkLocations { | ||
|
||
internal static IEnumerable<JdkInfo> GetMicrosoftDistJdks (Action<TraceLevel, string> logger) | ||
{ | ||
return FromPaths (GetMacOSMicrosoftDistJdkPaths (), logger, "$HOME/Library/Developer/Xamarin/jdk") | ||
.Concat (GetWindowsFileSystemJdks (Path.Combine ("Android", "jdk", "microsoft_dist_openjdk_*"), logger, locator: "legacy microsoft_dist_openjdk")) | ||
.OrderByDescending (jdk => jdk, JdkInfoVersionComparer.Default); | ||
} | ||
|
||
static IEnumerable<string> GetMacOSMicrosoftDistJdkPaths () | ||
{ | ||
var jdks = AppDomain.CurrentDomain.GetData ($"GetMacOSMicrosoftJdkPaths jdks override! {typeof (JdkInfo).AssemblyQualifiedName}") | ||
?.ToString (); | ||
if (jdks == null) { | ||
var home = Environment.GetFolderPath (Environment.SpecialFolder.Personal); | ||
jdks = Path.Combine (home, "Library", "Developer", "Xamarin", "jdk"); | ||
} | ||
if (!Directory.Exists (jdks)) | ||
return Enumerable.Empty <string> (); | ||
|
||
return Directory.EnumerateDirectories (jdks); | ||
} | ||
} | ||
} |