From 022f5d503a390b2920299745cee1309a22402afb Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Tue, 17 Aug 2021 17:02:38 -0400 Subject: [PATCH] [Xamarin.Android.Tools.AndroidSdk] Eclipse Adoptium support Context: https://blog.adoptopenjdk.net/2021/03/transition-to-eclipse-an-update/ Context: https://projects.eclipse.org/projects/adoptium AdoptOpenJDK has moved to the Eclipse foundation, and made two name changes in the process: 1. The project is now known as Eclipse Adoptium. 2. The macOS installation directory now matches the file glob `temurin-*.jdk`, not `adoptopenjdk-*.jdk`. 3. The Windows installation directory now installs into e.g. `%ProgramFiles%\Eclipse Foundation\jdk-*`. Rename `AdoptOpenJdkLocations.cs` to `EclipseAdoptiumJdkLocations.cs`, and check for *both* the "legacy" AdoptOpenJDK and new EclipseAdoptium paths. --- .../JdkInfo.cs | 3 ++- .../Jdks/AdoptOpenJdkLocations.cs | 20 ---------------- .../Jdks/EclipseAdoptiumJdkLocations.cs | 23 +++++++++++++++++++ 3 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 src/Xamarin.Android.Tools.AndroidSdk/Jdks/AdoptOpenJdkLocations.cs create mode 100644 src/Xamarin.Android.Tools.AndroidSdk/Jdks/EclipseAdoptiumJdkLocations.cs diff --git a/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs b/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs index 00a0f9f..19c3253 100644 --- a/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs +++ b/src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs @@ -289,7 +289,7 @@ public static IEnumerable GetKnownSystemJdkInfos (Action GetKnownSystemJdkInfos (Action GetPreferredJdkInfos (Action logger) { return MicrosoftOpenJdkLocations.GetMicrosoftOpenJdks (logger) + .Concat (EclipseAdoptiumJdkLocations.GetEclipseAdoptiumJdks (logger)) .Concat (MicrosoftDistJdkLocations.GetMicrosoftDistJdks (logger)) ; } diff --git a/src/Xamarin.Android.Tools.AndroidSdk/Jdks/AdoptOpenJdkLocations.cs b/src/Xamarin.Android.Tools.AndroidSdk/Jdks/AdoptOpenJdkLocations.cs deleted file mode 100644 index 581033d..0000000 --- a/src/Xamarin.Android.Tools.AndroidSdk/Jdks/AdoptOpenJdkLocations.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; - -namespace Xamarin.Android.Tools { - - class AdoptOpenJdkLocations : JdkLocations { - - internal static IEnumerable GetAdoptOpenJdks (Action logger) - { - return GetMacOSSystemJdks ("adoptopenjdk-*.jdk", logger) - .Concat (GetWindowsFileSystemJdks (Path.Combine ("AdoptOpenJDK", "jdk-*"), logger)) - .Concat (GetWindowsRegistryJdks (logger, @"SOFTWARE\AdoptOpenJDK\JDK", "*", @"hotspot\MSI", "Path")) - .OrderByDescending (jdk => jdk, JdkInfoVersionComparer.Default); - } - } -} diff --git a/src/Xamarin.Android.Tools.AndroidSdk/Jdks/EclipseAdoptiumJdkLocations.cs b/src/Xamarin.Android.Tools.AndroidSdk/Jdks/EclipseAdoptiumJdkLocations.cs new file mode 100644 index 0000000..d9d9b75 --- /dev/null +++ b/src/Xamarin.Android.Tools.AndroidSdk/Jdks/EclipseAdoptiumJdkLocations.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; + +namespace Xamarin.Android.Tools { + + class EclipseAdoptiumJdkLocations : JdkLocations { + + internal static IEnumerable GetEclipseAdoptiumJdks (Action logger) + { + return GetMacOSSystemJdks ("temurin-*.jdk", logger) + .Concat (GetMacOSSystemJdks ("adoptopenjdk-*.jdk", logger)) + .Concat (GetWindowsFileSystemJdks (Path.Combine ("AdoptOpenJDK", "jdk-*"), logger)) + .Concat (GetWindowsRegistryJdks (logger, @"SOFTWARE\AdoptOpenJDK\JDK", "*", @"hotspot\MSI", "Path")) + .Concat (GetWindowsFileSystemJdks (Path.Combine ("Eclipse Foundation", "jdk-*"), logger)) + .Concat (GetWindowsRegistryJdks (logger, @"SOFTWARE\Eclipse Foundation\JDK", "*", @"hotspot\MSI", "Path")) + .OrderByDescending (jdk => jdk, JdkInfoVersionComparer.Default); + } + } +}