Skip to content

Commit 4c2e36c

Browse files
authored
[Xamarin.Android.Tools.AndroidSdk] Eclipse Adoptium support (#132)
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 three 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-*`, not e.g. `%ProgramFiles%\AdoptOpenJDK\jdk-*`. Rename `AdoptOpenJdkLocations.cs` to `EclipseAdoptiumJdkLocations.cs`, and check for *both* the "legacy" AdoptOpenJDK and new Eclipse Adoptium paths.
1 parent eaec4e3 commit 4c2e36c

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
289289
.Concat (JdkLocations.GetPreferredJdks (logger))
290290
.Concat (XAPrepareJdkLocations.GetXAPrepareJdks (logger))
291291
.Concat (MicrosoftOpenJdkLocations.GetMicrosoftOpenJdks (logger))
292-
.Concat (AdoptOpenJdkLocations.GetAdoptOpenJdks (logger))
292+
.Concat (EclipseAdoptiumJdkLocations.GetEclipseAdoptiumJdks (logger))
293293
.Concat (AzulJdkLocations.GetAzulJdks (logger))
294294
.Concat (OracleJdkLocations.GetOracleJdks (logger))
295295
.Concat (VSAndroidJdkLocations.GetVSAndroidJdks (logger))
@@ -305,6 +305,7 @@ public static IEnumerable<JdkInfo> GetKnownSystemJdkInfos (Action<TraceLevel, st
305305
internal static IEnumerable<JdkInfo> GetPreferredJdkInfos (Action<TraceLevel, string> logger)
306306
{
307307
return MicrosoftOpenJdkLocations.GetMicrosoftOpenJdks (logger)
308+
.Concat (EclipseAdoptiumJdkLocations.GetEclipseAdoptiumJdks (logger))
308309
.Concat (MicrosoftDistJdkLocations.GetMicrosoftDistJdks (logger))
309310
;
310311
}

src/Xamarin.Android.Tools.AndroidSdk/Jdks/AdoptOpenJdkLocations.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 EclipseAdoptiumJdkLocations : JdkLocations {
11+
12+
internal static IEnumerable<JdkInfo> GetEclipseAdoptiumJdks (Action<TraceLevel, string> logger)
13+
{
14+
return GetMacOSSystemJdks ("temurin-*.jdk", logger)
15+
.Concat (GetMacOSSystemJdks ("adoptopenjdk-*.jdk", logger))
16+
.Concat (GetWindowsFileSystemJdks (Path.Combine ("AdoptOpenJDK", "jdk-*"), logger))
17+
.Concat (GetWindowsRegistryJdks (logger, @"SOFTWARE\AdoptOpenJDK\JDK", "*", @"hotspot\MSI", "Path"))
18+
.Concat (GetWindowsFileSystemJdks (Path.Combine ("Eclipse Foundation", "jdk-*"), logger))
19+
.Concat (GetWindowsRegistryJdks (logger, @"SOFTWARE\Eclipse Foundation\JDK", "*", @"hotspot\MSI", "Path"))
20+
.OrderByDescending (jdk => jdk, JdkInfoVersionComparer.Default);
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)