From df68c208ad02d09ebb9e6a87053343985dfc1e36 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 29 Aug 2024 15:05:47 -0400 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Bump $(MinimumSupportedJavaVersion)=17 (#9257) Context: https://github.com/dotnet/android/issues/9159#issuecomment-2317390991 Bump `$(MinimumSupportedJavaVersion)` to 17.0, and base this value on the `Configurables.Defaults.MicrosoftOpenJDK17Version` value so that if (when) we bump the JDK we build against, the major version value of `$(MinimumSupportedJavaVersion)` follows suit. Additionally, remove the `$(MinimumSupportedJavaVersion)` definition in `Microsoft.Android.Sdk.DefaultProperties.targets` so that it's only defined in one location. This change ensures that the `@(JavaDependency)` values produced by the `GetAndroidDependencies` target and the `$(JavaSdkDirectory)` value produced by the `` task are consistent; `` won't find and use JDK-11, then cause a future `InstallAndroidDependencies` target invocation to attempt to update the JDK-11 install to JDK-17. Bumping `$(MinimumSupportedJavaVersion)` will prevent `` from using a JDK that would cause `InstallAndroidDependencies` to error out. If this breaks your build, you should be able to fix it by adding the following fragment to your `.csproj`: 11.0 --- .../xaprepare/Resources/Configuration.OperatingSystem.props.in | 1 + build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs | 1 + .../targets/Microsoft.Android.Sdk.DefaultProperties.targets | 1 - .../Xamarin.Android.Build.Tasks.targets | 1 + src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in | 2 +- 5 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in b/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in index b099fa8e7bc..b266e18623a 100644 --- a/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in +++ b/build-tools/xaprepare/xaprepare/Resources/Configuration.OperatingSystem.props.in @@ -7,6 +7,7 @@ @HOST_CPUS@ @ARCHITECTURE_BITS@ @JAVA_SDK_VERSION@ + @MIN_SUPPORTED_JDK_VERSION@ @JavaSdkDirectory@ @javac@ @jar@ diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 8543f505d5a..167c48515f1 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -162,6 +162,7 @@ GeneratedFile Get_Configuration_OperatingSystem_props (Context context) { "@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" }, }; return new GeneratedPlaceholdersFile ( diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets index 54bd98fe3d4..6cfdd2141b5 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets @@ -2,7 +2,6 @@ - 11.0 System Resources Assets diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets index 0f839a03070..b809f665e28 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets @@ -199,6 +199,7 @@ <_XACommonPropsReplacement Include="@COMMAND_LINE_TOOLS_VERSION@=$(CommandLineToolsFolder)" /> <_XACommonPropsReplacement Include="@BUNDLETOOL_VERSION@=$(XABundleToolVersion)" /> <_XACommonPropsReplacement Include="@JAVA_SDK_VERSION@=$(JavaSdkVersion)" /> + <_XACommonPropsReplacement Include="@MIN_SUPPORTED_JDK_VERSION@=$(MinimumSupportedJavaSdkVersion)" /> <_XACommonPropsReplacement Include="@NDK_PKG_REVISION@=26.3.11579264" /> <_XACommonPropsReplacement Include="@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a)" /> 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 d3efc6da5a8..f1c5079ac8a 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in @@ -8,6 +8,7 @@ @NDK_PKG_REVISION@ @JAVA_SDK_VERSION@ + @MIN_SUPPORTED_JDK_VERSION@ <_JavaInteropReferences>Java.Interop;System.Runtime @@ -17,7 +18,6 @@ true true 17.0.99 - 1.6.0 {abi}{versionCode:D5} UpdateGeneratedFiles True