Skip to content

Commit

Permalink
[Xamarin.Android.Build.Tasks] Bump $(MinimumSupportedJavaVersion)=17 (#…
Browse files Browse the repository at this point in the history
…9257)

Context: #9159 (comment)

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 `<ResolveSdks/>` task are consistent;
`<ResolveSdks/>` 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 `<ResolveSdks/>` 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`:

	<PropertyGroup>
	  <MinimumSupportedJavaVersion>11.0</MinimumSupportedJavaVersion>
	</PropertyGroup>
  • Loading branch information
jonpryor authored Aug 29, 2024
1 parent 7aa8b84 commit df68c20
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<HostCpuCount Condition=" '$(HostCpuCount)' == '' ">@HOST_CPUS@</HostCpuCount>
<HostBits Condition=" '$(HostBits)' == '' ">@ARCHITECTURE_BITS@</HostBits>
<JavaSdkVersion>@JAVA_SDK_VERSION@</JavaSdkVersion>
<MinimumSupportedJavaSdkVersion>@MIN_SUPPORTED_JDK_VERSION@</MinimumSupportedJavaSdkVersion>
<JavaSdkDirectory Condition=" '$(JavaSdkDirectory)' == '' ">@JavaSdkDirectory@</JavaSdkDirectory>
<JavaCPath Condition=" '$(JavaCPath)' == '' ">@javac@</JavaCPath>
<JarPath Condition=" '$(JarPath)' == '' ">@jar@</JarPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<!-- User-facing configuration-agnostic defaults -->
<PropertyGroup>
<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">11.0</MinimumSupportedJavaVersion>
<AndroidBoundExceptionType Condition=" '$(AndroidBoundExceptionType)' == '' ">System</AndroidBoundExceptionType>
<MonoAndroidResourcePrefix Condition=" '$(MonoAndroidResourcePrefix)' == '' ">Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix Condition=" '$(MonoAndroidAssetsPrefix)' == '' ">Assets</MonoAndroidAssetsPrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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@=$(AndroidNdkPkgRevision)" /> -->
<_XACommonPropsReplacement Include="@NDK_PKG_REVISION@=26.3.11579264" />
<_XACommonPropsReplacement Include="@NDK_ARM64_V8A_API@=$(AndroidNdkApiLevel_ArmV8a)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<AndroidSdkEmulatorVersion Condition="'$(AndroidSdkEmulatorVersion)' == ''"></AndroidSdkEmulatorVersion>
<AndroidNdkVersion Condition="'$(AndroidNdkVersion)' == ''">@NDK_PKG_REVISION@</AndroidNdkVersion>
<JavaSdkVersion Condition="'$(JavaSdkVersion)' == ''">@JAVA_SDK_VERSION@</JavaSdkVersion>
<MinimumSupportedJavaVersion Condition="'$(MinimumSupportedJavaVersion)' == ''">@MIN_SUPPORTED_JDK_VERSION@</MinimumSupportedJavaVersion>
</PropertyGroup>
<PropertyGroup>
<_JavaInteropReferences>Java.Interop;System.Runtime</_JavaInteropReferences>
Expand All @@ -17,7 +18,6 @@
<CopyNuGetImplementations Condition=" '$(CopyNuGetImplementations)' == ''">true</CopyNuGetImplementations>
<YieldDuringToolExecution Condition="'$(YieldDuringToolExecution)' == ''">true</YieldDuringToolExecution>
<LatestSupportedJavaVersion Condition="'$(LatestSupportedJavaVersion)' == ''">17.0.99</LatestSupportedJavaVersion>
<MinimumSupportedJavaVersion Condition="'$(MinimumSupportedJavaVersion)' == ''">1.6.0</MinimumSupportedJavaVersion>
<AndroidVersionCodePattern Condition=" '$(AndroidUseLegacyVersionCode)' != 'True' And '$(AndroidVersionCodePattern)' == '' ">{abi}{versionCode:D5}</AndroidVersionCodePattern>
<AndroidResourceGeneratorTargetName>UpdateGeneratedFiles</AndroidResourceGeneratorTargetName>
<AndroidUseApkSigner Condition=" '$(AndroidUseApkSigner)' == '' ">True</AndroidUseApkSigner>
Expand Down

0 comments on commit df68c20

Please sign in to comment.