From bfeebf78408ff9a96cc00654607e7b19c417b794 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 14 Jan 2025 15:32:07 -0500 Subject: [PATCH 1/3] [build] Build with Microsoft OpenJDK 21.0.5 Context: https://github.com/dotnet/android/pull/9651 Context: https://github.com/dotnet/android/commit/14a6bfb925c3f18c677507fe07bd171e559f458f Updates the macOS, Windows, and Linux build stages to install and build with Microsoft OpenJDK 21.0.5. The macOS MSBuild tests and nightly APK tests have also been updated to use JDK 21, while all other test jobs should continue to use JDK 17. --- .../automation/azure-pipelines-nightly.yaml | 2 +- .../yaml-templates/build-linux.yaml | 5 ++++ .../yaml-templates/build-windows.yaml | 3 +++ .../yaml-templates/commercial-build.yaml | 1 + .../yaml-templates/run-msbuild-tests.yaml | 2 ++ .../yaml-templates/stage-msbuild-tests.yaml | 3 +++ .../automation/yaml-templates/variables.yaml | 2 ++ .../xaprepare/ConfigAndData/Configurables.cs | 27 +++++++++---------- .../xaprepare/Steps/Step_GenerateFiles.cs | 4 +-- .../Steps/Step_InstallAdoptOpenJDK.cs | 17 +++++------- 10 files changed, 38 insertions(+), 28 deletions(-) diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml index 2fc23d55aff..04d47e4eb2f 100644 --- a/build-tools/automation/azure-pipelines-nightly.yaml +++ b/build-tools/automation/azure-pipelines-nightly.yaml @@ -123,7 +123,7 @@ stages: - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: xaprepareScenario: EmulatorTestDependencies - jdkMajorVersion: 11 + jdkMajorVersion: 21 - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml parameters: diff --git a/build-tools/automation/yaml-templates/build-linux.yaml b/build-tools/automation/yaml-templates/build-linux.yaml index 6e098e9bb40..260020fc832 100644 --- a/build-tools/automation/yaml-templates/build-linux.yaml +++ b/build-tools/automation/yaml-templates/build-linux.yaml @@ -52,6 +52,11 @@ stages: # https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#checkout-path - checkout: maui + - template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml + parameters: + useAgentJdkPath: false + jdkMajorVersion: $(LatestJavaSdkMajorVersion) + - template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: remove_dotnet: true diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index 52c6e17838d..95db7e69485 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -40,6 +40,9 @@ stages: - template: /build-tools/automation/yaml-templates/clean.yaml - template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml + parameters: + useAgentJdkPath: false + jdkMajorVersion: $(LatestJavaSdkMajorVersion) - template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: diff --git a/build-tools/automation/yaml-templates/commercial-build.yaml b/build-tools/automation/yaml-templates/commercial-build.yaml index 0e2ed655eee..93b4d1eb6f7 100644 --- a/build-tools/automation/yaml-templates/commercial-build.yaml +++ b/build-tools/automation/yaml-templates/commercial-build.yaml @@ -11,6 +11,7 @@ steps: - template: /build-tools/automation/yaml-templates/setup-jdk-variables.yaml parameters: useAgentJdkPath: false + jdkMajorVersion: $(LatestJavaSdkMajorVersion) - template: /build-tools/automation/yaml-templates/use-dot-net.yaml parameters: diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index 7853353e798..affd6bc8523 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -5,6 +5,7 @@ parameters: agentCount: 1 # Number of build agents to run in parallel testFilter: '' # Filter used to select tests (NUnit test selection language, not dotnet test filter language) xaSourcePath: $(System.DefaultWorkingDirectory) + jdkMajorVersion: $(DefaultJavaSdkMajorVersion) repositoryAlias: 'self' commit: '' shouldFailOnIssue: true @@ -41,6 +42,7 @@ jobs: xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} + jdkMajorVersion: ${{ parameters.jdkMajorVersion }} - task: DownloadPipelineArtifact@2 inputs: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index 434de192f42..92285d67938 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -6,6 +6,7 @@ parameters: dependsOn: mac_build stagePrefix: '' xaSourcePath: $(System.DefaultWorkingDirectory) + jdkMajorVersion: $(DefaultJavaSdkMajorVersion) repositoryAlias: 'self' commit: '' shouldFailOnIssue: true @@ -24,6 +25,7 @@ stages: jobDisplayName: macOS > Tests > MSBuild agentCount: 14 xaSourcePath: ${{ parameters.xaSourcePath }} + jdkMajorVersion: $(LatestJavaSdkMajorVersion) repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} @@ -36,6 +38,7 @@ stages: jobDisplayName: Windows > Tests > MSBuild agentCount: 6 xaSourcePath: ${{ parameters.xaSourcePath }} + jdkMajorVersion: ${{ parameters.jdkMajorVersion }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} diff --git a/build-tools/automation/yaml-templates/variables.yaml b/build-tools/automation/yaml-templates/variables.yaml index 48b60fe65f3..1691bdce4e6 100644 --- a/build-tools/automation/yaml-templates/variables.yaml +++ b/build-tools/automation/yaml-templates/variables.yaml @@ -60,6 +60,8 @@ variables: value: 35,Baklava - name: DefaultJavaSdkMajorVersion value: 17 +- name: LatestJavaSdkMajorVersion + value: 21 - name: ExcludedNightlyNUnitCategories value: 'cat != SystemApplication & cat != TimeZoneInfo & cat != Localization' - name: RunMAUITestJob diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index 103d07403fc..c52fb7c16c0 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -17,9 +17,9 @@ partial class Configurables { const string BinutilsVersion = "L_18.1.6-8.0.0-1"; - const string MicrosoftOpenJDK17Version = "17.0.12"; - const string MicrosoftOpenJDK17Release = "17.0.12"; - const string MicrosoftOpenJDK17RootDirName = "jdk-17.0.12+7"; + const string MicrosoftOpenJDKVersion = "21.0.5"; + const string MicrosoftOpenJDKRelease = "21.0.5"; + const string MicrosoftOpenJDKRootDirName = "jdk-21.0.5+11"; static Context ctx => Context.Instance; @@ -28,7 +28,7 @@ public static partial class Urls // https://aka.ms/download-jdk/microsoft-jdk-17.0.11-linux-x64.tar.gz // 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 // https://aka.ms/download-jdk/microsoft-jdk-17.0.11-windows-x64.zip - public static readonly Uri MicrosoftOpenJDK17 = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDK17Version}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}"); + public static readonly Uri MicrosoftOpenJDK = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDKVersion}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}"); /// /// Base URL for all Android SDK and NDK downloads. Used in @@ -43,11 +43,12 @@ public static partial class Defaults public static readonly string BinutilsVersion = Configurables.BinutilsVersion; public static readonly char[] PropertyListSeparator = new [] { ':' }; - public static readonly string JdkFolder = "jdk-17"; + public static readonly string JdkFolder = "jdk-21"; - public static readonly Version MicrosoftOpenJDK17Version = new Version (Configurables.MicrosoftOpenJDK17Version); - public static readonly Version MicrosoftOpenJDK17Release = new Version (Configurables.MicrosoftOpenJDK17Release); - public static readonly string MicrosoftOpenJDK17RootDirName = Configurables.MicrosoftOpenJDK17RootDirName; + public static readonly Version MicrosoftMinOpenJDKVersion = new Version (17, 0); + public static readonly Version MicrosoftOpenJDKVersion = new Version (Configurables.MicrosoftOpenJDKVersion); + public static readonly Version MicrosoftOpenJDKRelease = new Version (Configurables.MicrosoftOpenJDKRelease); + public static readonly string MicrosoftOpenJDKRootDirName = Configurables.MicrosoftOpenJDKRootDirName; public const string DotNetTestRuntimeVersion = "3.1.11"; @@ -187,9 +188,8 @@ public static partial class Paths public static string InstallMSBuildDir => GetCachedPath (ref installMSBuildDir, () => ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir)); // OpenJDK - public static string OldOpenJDKInstallDir => GetCachedPath (ref oldOpenJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-1.8")); - public static string OpenJDK17InstallDir => GetCachedPath (ref openJDK17InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-17")); - public static string OpenJDK17CacheDir => GetCachedPath (ref openJDK17CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); + public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder)); + public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); // .NET 6 public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm")); @@ -269,9 +269,8 @@ static string GetCachedPath (ref string? variable, Func creator) static string? installMSBuildDir; static string? monoAndroidFrameworksRootDir; static string? externalJavaInteropDir; - static string? openJDK17InstallDir; - static string? openJDK17CacheDir; - static string? oldOpenJDKInstallDir; + static string? openJDKInstallDir; + static string? openJDKCacheDir; static string? configurationPropsGeneratedPath; static string? windowsBinutilsInstallDir; static string? hostBinutilsInstallDir; diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 167c48515f1..af3c6cac1b6 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -156,13 +156,13 @@ GeneratedFile Get_Configuration_OperatingSystem_props (Context context) { "@OS_RELEASE@", context.OS.Release ?? String.Empty }, { "@HOST_CPUS@", context.OS.CPUCount.ToString () }, { "@ARCHITECTURE_BITS@", context.OS.Is64Bit ? "64" : "32" }, - { "@JAVA_SDK_VERSION@", Configurables.Defaults.MicrosoftOpenJDK17Version.ToString () }, + { "@JAVA_SDK_VERSION@", Configurables.Defaults.MicrosoftOpenJDKVersion.ToString () }, { "@JavaSdkDirectory@", context.OS.JavaHome }, { "@javac@", context.OS.JavaCPath }, { "@java@", context.OS.JavaPath }, { "@jar@", context.OS.JarPath }, { "@NDK_LLVM_TAG@", $"{context.OS.Type.ToLowerInvariant ()}-x86_64" }, - { "@MIN_SUPPORTED_JDK_VERSION@", $"{Configurables.Defaults.MicrosoftOpenJDK17Version.Major}.0" }, + { "@MIN_SUPPORTED_JDK_VERSION@", $"{Configurables.Defaults.MicrosoftMinOpenJDKVersion.Major}.0" }, }; return new GeneratedPlaceholdersFile ( diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs index 2d3c9e5d99e..92cacaa7c1f 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs @@ -44,11 +44,6 @@ public Step_InstallOpenJDK (string description, bool allowJIJavaHomeMatch = fals protected override async Task Execute (Context context) { - if (Directory.Exists (Configurables.Paths.OldOpenJDKInstallDir)) { - Log.DebugLine ($"Found old OpenJDK directory at {Configurables.Paths.OldOpenJDKInstallDir}, removing"); - Utilities.DeleteDirectorySilent (Configurables.Paths.OldOpenJDKInstallDir); - } - AddToInventory (); string jdkInstallDir = JdkInstallDir; @@ -291,11 +286,11 @@ public Step_InstallMicrosoftOpenJDK (bool allowJIJavaHomeMatch = false) } protected override string ProductName => _ProductName; - protected override string JdkInstallDir => Configurables.Paths.OpenJDK17InstallDir; - protected override Version JdkVersion => Configurables.Defaults.MicrosoftOpenJDK17Version; - protected override Version JdkRelease => Configurables.Defaults.MicrosoftOpenJDK17Release; - protected override Uri JdkUrl => Configurables.Urls.MicrosoftOpenJDK17; - protected override string JdkCacheDir => Configurables.Paths.OpenJDK17CacheDir; - protected override string RootDirName => Configurables.Defaults.MicrosoftOpenJDK17RootDirName; + protected override string JdkInstallDir => Configurables.Paths.OpenJDKInstallDir; + protected override Version JdkVersion => Configurables.Defaults.MicrosoftOpenJDKVersion; + protected override Version JdkRelease => Configurables.Defaults.MicrosoftOpenJDKRelease; + protected override Uri JdkUrl => Configurables.Urls.MicrosoftOpenJDK; + protected override string JdkCacheDir => Configurables.Paths.OpenJDKCacheDir; + protected override string RootDirName => Configurables.Defaults.MicrosoftOpenJDKRootDirName; } } From 37937fe4714270972612d025bf0e499c557eda8f Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 14 Jan 2025 15:44:28 -0500 Subject: [PATCH 2/3] Formatting --- build-tools/automation/azure-pipelines-nightly.yaml | 2 +- .../xaprepare/ConfigAndData/Configurables.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml index 04d47e4eb2f..8d8058d0df1 100644 --- a/build-tools/automation/azure-pipelines-nightly.yaml +++ b/build-tools/automation/azure-pipelines-nightly.yaml @@ -123,7 +123,7 @@ stages: - template: /build-tools/automation/yaml-templates/setup-test-environment.yaml parameters: xaprepareScenario: EmulatorTestDependencies - jdkMajorVersion: 21 + jdkMajorVersion: $(LatestJavaSdkMajorVersion) - template: /build-tools/automation/yaml-templates/run-dotnet-preview.yaml parameters: diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index c52fb7c16c0..9c77341f969 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -45,10 +45,10 @@ public static partial class Defaults public static readonly string JdkFolder = "jdk-21"; - public static readonly Version MicrosoftMinOpenJDKVersion = new Version (17, 0); - public static readonly Version MicrosoftOpenJDKVersion = new Version (Configurables.MicrosoftOpenJDKVersion); - public static readonly Version MicrosoftOpenJDKRelease = new Version (Configurables.MicrosoftOpenJDKRelease); - public static readonly string MicrosoftOpenJDKRootDirName = Configurables.MicrosoftOpenJDKRootDirName; + public static readonly Version MicrosoftMinOpenJDKVersion = new Version (17, 0); + public static readonly Version MicrosoftOpenJDKVersion = new Version (Configurables.MicrosoftOpenJDKVersion); + public static readonly Version MicrosoftOpenJDKRelease = new Version (Configurables.MicrosoftOpenJDKRelease); + public static readonly string MicrosoftOpenJDKRootDirName = Configurables.MicrosoftOpenJDKRootDirName; public const string DotNetTestRuntimeVersion = "3.1.11"; @@ -188,8 +188,8 @@ public static partial class Paths public static string InstallMSBuildDir => GetCachedPath (ref installMSBuildDir, () => ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftAndroidSdkOutDir)); // OpenJDK - public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder)); - public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); + public static string OpenJDKInstallDir => GetCachedPath (ref openJDKInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder)); + public static string OpenJDKCacheDir => GetCachedPath (ref openJDKCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); // .NET 6 public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm")); From 59b760967b2a77ee59ac7bd61d74e77438fac951 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 15 Jan 2025 10:10:21 -0500 Subject: [PATCH 3/3] Only use JDK 21 in nightly tests --- build-tools/automation/azure-pipelines-nightly.yaml | 2 ++ build-tools/automation/yaml-templates/run-msbuild-tests.yaml | 2 -- build-tools/automation/yaml-templates/stage-msbuild-tests.yaml | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/build-tools/automation/azure-pipelines-nightly.yaml b/build-tools/automation/azure-pipelines-nightly.yaml index 8d8058d0df1..01f5b01ae05 100644 --- a/build-tools/automation/azure-pipelines-nightly.yaml +++ b/build-tools/automation/azure-pipelines-nightly.yaml @@ -200,6 +200,7 @@ stages: installTestSlicer: true xaprepareScenario: EmulatorTestDependencies useAgentJdkPath: false + jdkMajorVersion: $(LatestJavaSdkMajorVersion) - task: DownloadPipelineArtifact@2 inputs: @@ -252,6 +253,7 @@ stages: installTestSlicer: true xaprepareScenario: EmulatorTestDependencies useAgentJdkPath: false + jdkMajorVersion: $(LatestJavaSdkMajorVersion) - task: DownloadPipelineArtifact@2 inputs: diff --git a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml index affd6bc8523..7853353e798 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-tests.yaml @@ -5,7 +5,6 @@ parameters: agentCount: 1 # Number of build agents to run in parallel testFilter: '' # Filter used to select tests (NUnit test selection language, not dotnet test filter language) xaSourcePath: $(System.DefaultWorkingDirectory) - jdkMajorVersion: $(DefaultJavaSdkMajorVersion) repositoryAlias: 'self' commit: '' shouldFailOnIssue: true @@ -42,7 +41,6 @@ jobs: xaSourcePath: ${{ parameters.xaSourcePath }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} - jdkMajorVersion: ${{ parameters.jdkMajorVersion }} - task: DownloadPipelineArtifact@2 inputs: diff --git a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml index 92285d67938..434de192f42 100644 --- a/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml +++ b/build-tools/automation/yaml-templates/stage-msbuild-tests.yaml @@ -6,7 +6,6 @@ parameters: dependsOn: mac_build stagePrefix: '' xaSourcePath: $(System.DefaultWorkingDirectory) - jdkMajorVersion: $(DefaultJavaSdkMajorVersion) repositoryAlias: 'self' commit: '' shouldFailOnIssue: true @@ -25,7 +24,6 @@ stages: jobDisplayName: macOS > Tests > MSBuild agentCount: 14 xaSourcePath: ${{ parameters.xaSourcePath }} - jdkMajorVersion: $(LatestJavaSdkMajorVersion) repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }} @@ -38,7 +36,6 @@ stages: jobDisplayName: Windows > Tests > MSBuild agentCount: 6 xaSourcePath: ${{ parameters.xaSourcePath }} - jdkMajorVersion: ${{ parameters.jdkMajorVersion }} repositoryAlias: ${{ parameters.repositoryAlias }} commit: ${{ parameters.commit }} shouldFailOnIssue: ${{ parameters.shouldFailOnIssue }}