diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 4dbf996a2f1..3585fdcc4a6 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -153,9 +153,9 @@ extends: forceReinstallCredentialProvider: true - script: | - echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% - echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_17_X64% - displayName: set JI_JAVA_HOME, JAVA_HOME to $(JAVA_HOME_17_X64) + echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_21_X64% + echo ##vso[task.setvariable variable=JAVA_HOME]%JAVA_HOME_21_X64% + displayName: set JI_JAVA_HOME, JAVA_HOME to $(JAVA_HOME_21_X64) - script: echo "##vso[task.prependpath]C:\Windows\System32\WindowsPowerShell\v1.0\" displayName: add powershell to path diff --git a/build-tools/automation/yaml-templates/build-windows.yaml b/build-tools/automation/yaml-templates/build-windows.yaml index 0a69a37b602..3e09647a60d 100644 --- a/build-tools/automation/yaml-templates/build-windows.yaml +++ b/build-tools/automation/yaml-templates/build-windows.yaml @@ -40,8 +40,8 @@ stages: - template: /build-tools/automation/yaml-templates/clean.yaml - script: | - echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_17_X64% - displayName: set JI_JAVA_HOME to $(JAVA_HOME_17_X64) + echo ##vso[task.setvariable variable=JI_JAVA_HOME]%JAVA_HOME_21_X64% + displayName: set JI_JAVA_HOME to $(JAVA_HOME_21_X64) - 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 8fa529440f0..96bc3a3d4a2 100644 --- a/build-tools/automation/yaml-templates/commercial-build.yaml +++ b/build-tools/automation/yaml-templates/commercial-build.yaml @@ -8,7 +8,7 @@ parameters: use1ESTemplate: true steps: -- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/android-toolchain/jdk-17" +- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/android-toolchain/jdk-21" displayName: set JI_JAVA_HOME - template: /build-tools/automation/yaml-templates/use-dot-net.yaml diff --git a/build-tools/automation/yaml-templates/run-emulator-tests.yaml b/build-tools/automation/yaml-templates/run-emulator-tests.yaml index cffa60b6b04..4fe28d2e4f3 100644 --- a/build-tools/automation/yaml-templates/run-emulator-tests.yaml +++ b/build-tools/automation/yaml-templates/run-emulator-tests.yaml @@ -4,7 +4,7 @@ parameters: emulatorMSBuildArgs: '' jobName: CheckTimeZoneInfoIsCorrectNode1 jobTimeout: 360 - jdkTestFolder: $(JAVA_HOME_17_X64) + jdkTestFolder: $(JAVA_HOME_21_X64) testSteps: [] use1ESTemplate: true diff --git a/build-tools/automation/yaml-templates/setup-test-environment.yaml b/build-tools/automation/yaml-templates/setup-test-environment.yaml index 8973223431f..402cec0c70b 100644 --- a/build-tools/automation/yaml-templates/setup-test-environment.yaml +++ b/build-tools/automation/yaml-templates/setup-test-environment.yaml @@ -1,7 +1,7 @@ parameters: configuration: $(XA.Build.Configuration) xaSourcePath: $(System.DefaultWorkingDirectory) - jdkTestFolder: $(JAVA_HOME_17_X64) + jdkTestFolder: $(JAVA_HOME_21_X64) remove_dotnet: false dotnetVersion: $(DotNetSdkVersion) dotnetQuality: $(DotNetSdkQuality) diff --git a/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties b/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties index d642e7f8f76..d6e308a6378 100644 --- a/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index 103d07403fc..a9d98976692 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 MicrosoftOpenJDK21Version = "21.0.5"; + const string MicrosoftOpenJDK21Release = "21.0.5"; + const string MicrosoftOpenJDK21RootDirName = "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 MicrosoftOpenJDK21 = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDK21Version}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}"); /// /// Base URL for all Android SDK and NDK downloads. Used in @@ -43,11 +43,11 @@ 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 MicrosoftOpenJDK21Version = new Version (Configurables.MicrosoftOpenJDK21Version); + public static readonly Version MicrosoftOpenJDK21Release = new Version (Configurables.MicrosoftOpenJDK21Release); + public static readonly string MicrosoftOpenJDK21RootDirName = Configurables.MicrosoftOpenJDK21RootDirName; public const string DotNetTestRuntimeVersion = "3.1.11"; @@ -188,8 +188,8 @@ public static partial class Paths // 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 OpenJDK21InstallDir => GetCachedPath (ref openJDK21InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-21")); + public static string OpenJDK21CacheDir => GetCachedPath (ref openJDK21CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); // .NET 6 public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm")); @@ -269,8 +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? openJDK21InstallDir; + static string? openJDK21CacheDir; static string? oldOpenJDKInstallDir; static string? configurationPropsGeneratedPath; static string? windowsBinutilsInstallDir; diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 167c48515f1..bd915abb676 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.MicrosoftOpenJDK21Version.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.MicrosoftOpenJDK21Version.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 36d4190575e..a40d8e7b60e 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallAdoptOpenJDK.cs @@ -294,11 +294,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.OpenJDK21InstallDir; + protected override Version JdkVersion => Configurables.Defaults.MicrosoftOpenJDK21Version; + protected override Version JdkRelease => Configurables.Defaults.MicrosoftOpenJDK21Release; + protected override Uri JdkUrl => Configurables.Urls.MicrosoftOpenJDK21; + protected override string JdkCacheDir => Configurables.Paths.OpenJDK21CacheDir; + protected override string RootDirName => Configurables.Defaults.MicrosoftOpenJDK21RootDirName; } } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs index 9f77364084e..63dcc025038 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs @@ -60,8 +60,13 @@ protected override string GenerateCommandLineCommands () cmd.AppendSwitchIfNotNull ("-J-Dfile.encoding=", "UTF8"); cmd.AppendFileNameIfNotNull (string.Format ("@{0}", TemporarySourceListFile)); - cmd.AppendSwitchIfNotNull ("-target ", JavacTargetVersion); - cmd.AppendSwitchIfNotNull ("-source ", JavacSourceVersion); + if (int.TryParse (JavacSourceVersion, out int sourceVersion) && + int.TryParse (JavacTargetVersion, out int targetVersion)) { + cmd.AppendSwitchIfNotNull ("--release ", Math.Max (sourceVersion, targetVersion).ToString ()); + } else { + cmd.AppendSwitchIfNotNull ("-target ", JavacTargetVersion); + cmd.AppendSwitchIfNotNull ("-source ", JavacSourceVersion); + } return cmd.ToString (); } diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in index fcebeba89f9..7ec64c69f5e 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in @@ -17,7 +17,7 @@ false true true - 17.0.99 + 21.0.99 {abi}{versionCode:D5} UpdateGeneratedFiles True diff --git a/tools/workload-dependencies/Program.cs b/tools/workload-dependencies/Program.cs index c61ab3b1d39..4ee41275a1e 100644 --- a/tools/workload-dependencies/Program.cs +++ b/tools/workload-dependencies/Program.cs @@ -14,6 +14,7 @@ var CmdlineToolsVersion = (string?) null; var BuildToolsVersion = (string?) null; var JdkVersion = (string?) null; +var JdkMaxVersion = (string?) null; var NdkVersion = (string?) null; var PlatformToolsVersion = (string?) null; var PlatformVersion = (string?) null; @@ -37,6 +38,9 @@ { "jdk-version=", "The JDK {VERSION} dotnet/android is built against.", v => JdkVersion = v }, + { "jdk-max-version=", + "The maximum JDK {VERSION} dotnet/android supports.", + v => JdkMaxVersion = v }, { "ndk-version=", "The Android NDK {VERSION} dotnet/android is built against.", v => NdkVersion = v }, @@ -160,7 +164,7 @@ JProperty CreateJdkProperty (XDocument doc) { var v = new Version (JdkVersion ?? "17.0"); var start = new Version (v.Major, v.Minor); - var end = new Version (v.Major+1, 0); + var end = GetMaxJdkVersion (v); var latestRevision = JdkVersion ?? GetLatestRevision (doc, "jdk"); var contents = new JObject ( new JProperty ("version", $"[{start},{end})")); @@ -169,6 +173,14 @@ JProperty CreateJdkProperty (XDocument doc) return new JProperty ("jdk", contents); } +string GetMaxJdkVersion (Version v) +{ + if (!string.IsNullOrEmpty (JdkMaxVersion)) { + return JdkMaxVersion; + } + return new Version (v.Major+1, 0).ToString (); +} + IEnumerable GetSupportedElements (XDocument doc, string element) { if (doc.Root == null) { diff --git a/tools/workload-dependencies/WorkloadDependencies.proj b/tools/workload-dependencies/WorkloadDependencies.proj index 5b5a1630e16..05997421ab7 100644 --- a/tools/workload-dependencies/WorkloadDependencies.proj +++ b/tools/workload-dependencies/WorkloadDependencies.proj @@ -69,6 +69,7 @@ <_WorkloadDeps Include="--build-tools-version=$(AndroidSdkBuildToolsVersion)" /> <_WorkloadDeps Include="--cmdline-tools-version=$(AndroidCommandLineToolsVersion)" /> <_WorkloadDeps Include="--jdk-version=$(JavaSdkVersion)" /> + <_WorkloadDeps Include="--jdk-max-version=$(LatestSupportedJavaVersion)" /> <_WorkloadDeps Include="--ndk-version=$(AndroidNdkVersion)" /> <_WorkloadDeps Include="--platform-tools-version=$(AndroidSdkPlatformToolsVersion)" /> <_WorkloadDeps Include="--platform-version=$(AndroidSdkPlatformVersion)" />