Skip to content

Commit 9eef4c4

Browse files
committed
Merge branch 'main' into dev/grendel/clr-host
* main: [Mono.Android-Tests] Ignore "BadGateway" test failures. (#9687) [build] Build with Microsoft OpenJDK 21.0.5 (#9683)
2 parents 198acae + f9f421b commit 9eef4c4

File tree

9 files changed

+49
-31
lines changed

9 files changed

+49
-31
lines changed

build-tools/automation/azure-pipelines-nightly.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ stages:
123123
- template: /build-tools/automation/yaml-templates/setup-test-environment.yaml
124124
parameters:
125125
xaprepareScenario: EmulatorTestDependencies
126-
jdkMajorVersion: 11
126+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
127127

128128
- template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml
129129
parameters:
@@ -200,6 +200,7 @@ stages:
200200
installTestSlicer: true
201201
xaprepareScenario: EmulatorTestDependencies
202202
useAgentJdkPath: false
203+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
203204

204205
- task: DownloadPipelineArtifact@2
205206
inputs:
@@ -252,6 +253,7 @@ stages:
252253
installTestSlicer: true
253254
xaprepareScenario: EmulatorTestDependencies
254255
useAgentJdkPath: false
256+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
255257

256258
- task: DownloadPipelineArtifact@2
257259
inputs:

build-tools/automation/yaml-templates/build-linux.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ stages:
5252
# https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path
5353
- checkout: maui
5454

55+
- template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml
56+
parameters:
57+
useAgentJdkPath: false
58+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
59+
5560
- template: /build-tools/automation/yaml-templates/use-dot-net.yaml
5661
parameters:
5762
remove_dotnet: true

build-tools/automation/yaml-templates/build-windows.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ stages:
4040
- template: /build-tools/automation/yaml-templates/clean.yaml
4141

4242
- template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml
43+
parameters:
44+
useAgentJdkPath: false
45+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
4346

4447
- template: /build-tools/automation/yaml-templates/use-dot-net.yaml
4548
parameters:

build-tools/automation/yaml-templates/commercial-build.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ steps:
1111
- template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml
1212
parameters:
1313
useAgentJdkPath: false
14+
jdkMajorVersion: $(LatestJavaSdkMajorVersion)
1415

1516
- template: /build-tools/automation/yaml-templates/use-dot-net.yaml
1617
parameters:

build-tools/automation/yaml-templates/variables.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ variables:
6262
value: 35,Baklava
6363
- name: DefaultJavaSdkMajorVersion
6464
value: 17
65+
- name: LatestJavaSdkMajorVersion
66+
value: 21
6567
- name: ExcludedNightlyNUnitCategories
6668
value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization'
6769
- name: RunMAUITestJob

build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs

+13-14
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ partial class Configurables
1717
{
1818
const string BinutilsVersion = "L_18.1.6-8.0.0-1";
1919

20-
const string MicrosoftOpenJDK17Version = "17.0.12";
21-
const string MicrosoftOpenJDK17Release = "17.0.12";
22-
const string MicrosoftOpenJDK17RootDirName = "jdk-17.0.12+7";
20+
const string MicrosoftOpenJDKVersion = "21.0.5";
21+
const string MicrosoftOpenJDKRelease = "21.0.5";
22+
const string MicrosoftOpenJDKRootDirName = "jdk-21.0.5+11";
2323

2424
static Context ctx => Context.Instance;
2525

@@ -28,7 +28,7 @@ public static partial class Urls
2828
// https://aka.ms/download-jdk/microsoft-jdk-17.0.11-linux-x64.tar.gz
2929
// https://aka.ms/download-jdk/microsoft-jdk-17.0.11-macOS-x64.tar.gz or https://aka.ms/download-jdk/microsoft-jdk-17.0.11-macos-aarch64.pkg
3030
// https://aka.ms/download-jdk/microsoft-jdk-17.0.11-windows-x64.zip
31-
public static readonly Uri MicrosoftOpenJDK17 = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDK17Version}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}");
31+
public static readonly Uri MicrosoftOpenJDK = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDKVersion}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}");
3232

3333
/// <summary>
3434
/// Base URL for all Android SDK and NDK downloads. Used in <see cref="AndroidToolchain"/>
@@ -43,11 +43,12 @@ public static partial class Defaults
4343
public static readonly string BinutilsVersion = Configurables.BinutilsVersion;
4444
public static readonly char[] PropertyListSeparator = new [] { ':' };
4545

46-
public static readonly string JdkFolder = "jdk-17";
46+
public static readonly string JdkFolder = "jdk-21";
4747

48-
public static readonly Version MicrosoftOpenJDK17Version = new Version (Configurables.MicrosoftOpenJDK17Version);
49-
public static readonly Version MicrosoftOpenJDK17Release = new Version (Configurables.MicrosoftOpenJDK17Release);
50-
public static readonly string MicrosoftOpenJDK17RootDirName = Configurables.MicrosoftOpenJDK17RootDirName;
48+
public static readonly Version MicrosoftMinOpenJDKVersion = new Version (17, 0);
49+
public static readonly Version MicrosoftOpenJDKVersion = new Version (Configurables.MicrosoftOpenJDKVersion);
50+
public static readonly Version MicrosoftOpenJDKRelease = new Version (Configurables.MicrosoftOpenJDKRelease);
51+
public static readonly string MicrosoftOpenJDKRootDirName = Configurables.MicrosoftOpenJDKRootDirName;
5152

5253
public const string DotNetTestRuntimeVersion = "3.1.11";
5354

@@ -187,9 +188,8 @@ public static partial class Paths
187188
public static string InstallMSBuildDir => GetCachedPath (ref installMSBuildDir, () => ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir));
188189

189190
// OpenJDK
190-
public static string OldOpenJDKInstallDir => GetCachedPath (ref oldOpenJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-1.8"));
191-
public static string OpenJDK17InstallDir => GetCachedPath (ref openJDK17InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-17"));
192-
public static string OpenJDK17CacheDir => GetCachedPath (ref openJDK17CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
191+
public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder));
192+
public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
193193

194194
// .NET 6
195195
public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm"));
@@ -269,9 +269,8 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
269269
static string? installMSBuildDir;
270270
static string? monoAndroidFrameworksRootDir;
271271
static string? externalJavaInteropDir;
272-
static string? openJDK17InstallDir;
273-
static string? openJDK17CacheDir;
274-
static string? oldOpenJDKInstallDir;
272+
static string? openJDKInstallDir;
273+
static string? openJDKCacheDir;
275274
static string? configurationPropsGeneratedPath;
276275
static string? windowsBinutilsInstallDir;
277276
static string? hostBinutilsInstallDir;

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,13 @@ GeneratedFile Get_Configuration_OperatingSystem_props (Context context)
161161
{ "@OS_RELEASE@", context.OS.Release ?? String.Empty },
162162
{ "@HOST_CPUS@", context.OS.CPUCount.ToString () },
163163
{ "@ARCHITECTURE_BITS@", context.OS.Is64Bit ? "64" : "32" },
164-
{ "@JAVA_SDK_VERSION@", Configurables.Defaults.MicrosoftOpenJDK17Version.ToString () },
164+
{ "@JAVA_SDK_VERSION@", Configurables.Defaults.MicrosoftOpenJDKVersion.ToString () },
165165
{ "@JavaSdkDirectory@", context.OS.JavaHome },
166166
{ "@javac@", context.OS.JavaCPath },
167167
{ "@java@", context.OS.JavaPath },
168168
{ "@jar@", context.OS.JarPath },
169169
{ "@NDK_LLVM_TAG@", $"{context.OS.Type.ToLowerInvariant ()}-x86_64" },
170-
{ "@MIN_SUPPORTED_JDK_VERSION@", $"{Configurables.Defaults.MicrosoftOpenJDK17Version.Major}.0" },
170+
{ "@MIN_SUPPORTED_JDK_VERSION@", $"{Configurables.Defaults.MicrosoftMinOpenJDKVersion.Major}.0" },
171171
};
172172

173173
return new GeneratedPlaceholdersFile (

build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs

+6-11
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ public Step_InstallOpenJDK (string description, bool allowJIJavaHomeMatch = fals
4444

4545
protected override async Task<bool> Execute (Context context)
4646
{
47-
if (Directory.Exists (Configurables.Paths.OldOpenJDKInstallDir)) {
48-
Log.DebugLine ($"Found old OpenJDK directory at {Configurables.Paths.OldOpenJDKInstallDir}, removing");
49-
Utilities.DeleteDirectorySilent (Configurables.Paths.OldOpenJDKInstallDir);
50-
}
51-
5247
AddToInventory ();
5348

5449
string jdkInstallDir = JdkInstallDir;
@@ -291,11 +286,11 @@ public Step_InstallMicrosoftOpenJDK (bool allowJIJavaHomeMatch = false)
291286
}
292287

293288
protected override string ProductName => _ProductName;
294-
protected override string JdkInstallDir => Configurables.Paths.OpenJDK17InstallDir;
295-
protected override Version JdkVersion => Configurables.Defaults.MicrosoftOpenJDK17Version;
296-
protected override Version JdkRelease => Configurables.Defaults.MicrosoftOpenJDK17Release;
297-
protected override Uri JdkUrl => Configurables.Urls.MicrosoftOpenJDK17;
298-
protected override string JdkCacheDir => Configurables.Paths.OpenJDK17CacheDir;
299-
protected override string RootDirName => Configurables.Defaults.MicrosoftOpenJDK17RootDirName;
289+
protected override string JdkInstallDir => Configurables.Paths.OpenJDKInstallDir;
290+
protected override Version JdkVersion => Configurables.Defaults.MicrosoftOpenJDKVersion;
291+
protected override Version JdkRelease => Configurables.Defaults.MicrosoftOpenJDKRelease;
292+
protected override Uri JdkUrl => Configurables.Urls.MicrosoftOpenJDK;
293+
protected override string JdkCacheDir => Configurables.Paths.OpenJDKCacheDir;
294+
protected override string RootDirName => Configurables.Defaults.MicrosoftOpenJDKRootDirName;
300295
}
301296
}

tests/Mono.Android-Tests/Xamarin.Android.Net/AndroidClientHandlerTests.cs

+14-3
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ public void Redirect_Without_Protocol_Works()
258258
RunIgnoringNetworkIssues (() => tr.Wait (), out connectionFailed);
259259
if (connectionFailed)
260260
return;
261-
262-
tr.Result.EnsureSuccessStatusCode ();
261+
262+
EnsureSuccessStatusCode (tr.Result);
263263
Assert.AreEqual (redirectedURI, tr.Result.RequestMessage.RequestUri, "Invalid redirected URI");
264264
}
265265
}
@@ -281,10 +281,21 @@ public void Redirect_POST_With_Content_Works ()
281281
if (connectionFailed)
282282
return;
283283

284-
response.EnsureSuccessStatusCode ();
284+
EnsureSuccessStatusCode (response);
285285
Assert.AreEqual (redirectedURI, response.RequestMessage.RequestUri, "Invalid redirected URI");
286286
}
287287
}
288+
289+
void EnsureSuccessStatusCode (HttpResponseMessage response)
290+
{
291+
// If we hit a 502 (which is quite common on CI) just ignore the test
292+
if (response.StatusCode == HttpStatusCode.BadGateway) {
293+
Assert.Ignore ($"Ignoring network failure: {response.StatusCode}");
294+
return;
295+
}
296+
297+
response.EnsureSuccessStatusCode ();
298+
}
288299
}
289300

290301
[TestFixture]

0 commit comments

Comments
 (0)