From 33f1e376b804c11e0da1049594992f44e8778fa6 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Wed, 10 May 2023 15:13:15 -0400 Subject: [PATCH 1/4] [xaprepare] Provision Microsoft OpenJDK 17.0.7 Context: https://web.archive.org/web/20230507035529/https://developer.android.com/studio/releases/#jdk-17 > Starting from Android Studio Flamingo Canary 3, the Studio IDE is > bundled with JDK 17. Does .NET Android work with JDK 17? Update `xaprepare` to provision Microsoft OpenJDK 17.0.7, and let's see if everything works! --- .../xaprepare/xaprepare/ConfigAndData/Configurables.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index c26df75a5e1..48146658c7a 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_15.0.7-5.0.3"; - const string MicrosoftOpenJDK11Version = "11.0.16"; + const string MicrosoftOpenJDK11Version = "17.0.7"; const string MicrosoftOpenJDK11Release = "8.1"; - const string MicrosoftOpenJDK11RootDirName = "jdk-11.0.16+8"; + const string MicrosoftOpenJDK11RootDirName = "jdk-17.0.7+7"; const string AdoptOpenJDKRelease = "8.0"; // build_number.0 static readonly string AdoptOpenJDKUrlVersion = $"8u{AdoptOpenJDKUpdate}{AdoptOpenJDKBuild}"; @@ -35,9 +35,9 @@ public static partial class Urls // https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u345-b01/OpenJDK8U-jdk_x64_windows_hotspot_8u345b01.zip public static readonly Uri AdoptOpenJDK8 = new Uri ($"https://github.com/adoptium/temurin8-binaries/releases/download/{AdoptOpenJDKTag}/OpenJDK8U-jdk_{AdoptOpenJDKOperatingSystem}_hotspot_{AdoptOpenJDKUrlVersion}.{AdoptOpenJDKArchiveExtension}"); - // https://aka.ms/download-jdk/microsoft-jdk-11.0.16-linux-x64.tar.gz - // https://aka.ms/download-jdk/microsoft-jdk-11.0.16-macOS-x64.tar.gz - // https://aka.ms/download-jdk/microsoft-jdk-11.0.16-windows-x64.zip + // https://aka.ms/download-jdk/microsoft-jdk-17.0.7-linux-x64.tar.gz + // https://aka.ms/download-jdk/microsoft-jdk-17.0.7-macOS-x64.tar.gz + // https://aka.ms/download-jdk/microsoft-jdk-17.0.7-windows-x64.zip public static readonly Uri MicrosoftOpenJDK11 = new Uri ($"https://aka.ms/download-jdk/microsoft-jdk-{MicrosoftOpenJDK11Version}-{MicrosoftOpenJDKOperatingSystem}.{MicrosoftOpenJDKFileExtension}"); /// From 67d642f8ea43200ae85f809304dd2230a1cba7b1 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Thu, 11 May 2023 17:22:46 -0400 Subject: [PATCH 2/4] Try xamarin/java.interop#1108 Java.Interop needs JDK-17 support first! --- .gitmodules | 4 ++-- .../gradle/gradle/wrapper/gradle-wrapper.properties | 2 +- build-tools/scripts/DotNet.targets | 8 +++++++- .../xaprepare/Application/GeneratedMonodroidCmakeFiles.cs | 6 +++--- .../xaprepare/xaprepare/ConfigAndData/Configurables.cs | 4 ++-- external/Java.Interop | 2 +- external/Java.Interop.override.props | 1 + src/manifestmerger/build.gradle | 8 ++++---- src/monodroid/monodroid.targets | 5 ++++- src/r8/build.gradle | 8 ++++---- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.gitmodules b/.gitmodules index ab79ccab656..2bdccfa5e08 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,8 +8,8 @@ branch = main [submodule "external/Java.Interop"] path = external/Java.Interop - url = https://github.com/xamarin/java.interop.git - branch = main + url = https://github.com/jonpryor/java.interop.git + branch = jonp-allow-jdk-17 [submodule "external/lz4"] path = external/lz4 url = https://github.com/lz4/lz4.git diff --git a/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties b/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties index 6b3851a8ad2..fae08049a6f 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-5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/build-tools/scripts/DotNet.targets b/build-tools/scripts/DotNet.targets index e11b2042001..37d4391b740 100644 --- a/build-tools/scripts/DotNet.targets +++ b/build-tools/scripts/DotNet.targets @@ -10,8 +10,14 @@ /> + + <_JIPrepArg Include=""-p:Jdks8Root=$(Java8SdkDirectory)"" /> + <_JIPrepArg Include=""-p:Jdks11Root=$(JavaSdkDirectory)"" /> + <_JIPrepArg Include=""-p:DotnetToolPath=$(DotNetPreviewTool)"" /> + <_JIPrepArg Include=""-bl:$(_BinlogPathPrefix)-prepare-java-interop.binlog"" /> + diff --git a/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs b/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs index 746f3f50d89..b58a065490b 100644 --- a/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs +++ b/build-tools/xaprepare/xaprepare/Application/GeneratedMonodroidCmakeFiles.cs @@ -84,12 +84,12 @@ void GenerateShellConfig (Context context, StreamWriter sw) AddReplacements (commonReplacements, hostRuntimeReplacements); string monodroidObjDir = Path.Combine (Configurables.Paths.MonodroidSourceDir, "obj", context.Configuration); - string jdkInfoPropsPath = Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "bin", $"Build{context.Configuration}", "JdkInfo.props"); + string jdkInfoPropsPath = Path.Combine (Configurables.Paths.ExternalJavaInteropDir, "bin", $"Build{context.Configuration}", "JdkInfo-11.props"); sw.WriteLine ("# This is a bash(1) script"); sw.WriteLine (); sw.WriteLine ($"CMAKE=\"{context.Properties.GetRequiredValue(KnownProperties.CMakePath)}\""); - sw.WriteLine ($"JDK_INCLUDE_PATH=\"$(grep JdkIncludePath {jdkInfoPropsPath} | cut -d '\"' -f 2 | tr '\\n' ' ')\""); + sw.WriteLine ($"JDK_INCLUDE_PATH=\"$(grep Jdk11IncludePath {jdkInfoPropsPath} | cut -d '\"' -f 2 | tr '\\n' ' ')\""); sw.WriteLine ($"MONO_SOURCE_PATH=\"{Configurables.Paths.MonoSourceFullPath}\""); sw.WriteLine ($"MONODROID_OBJ_DIR=\"{monodroidObjDir}\""); sw.WriteLine ($"MONODROID_SOURCE_DIR=\"{Configurables.Paths.MonodroidSourceDir}\""); @@ -341,7 +341,7 @@ void GenerateMonodroidTargets (Context context, StreamWriter sw) var hostRuntimeReplacements = new Dictionary (StringComparer.Ordinal) { { "@CmakeHostFlags@", "%(_HostRuntime.CmakeFlags)" }, - { "@JdkIncludePath@", "@(JdkIncludePath->'%(Identity)', ' ')" }, + { "@JdkIncludePath@", "@(Jdk11IncludePath->'%(Identity)', ' ')" }, { "@OUTPUT_DIRECTORY@", "" }, }; diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index 48146658c7a..6a5b47e7bc0 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -57,7 +57,7 @@ public static partial class Defaults public static readonly string BinutilsVersion = Configurables.BinutilsVersion; public static readonly char[] PropertyListSeparator = new [] { ':' }; - public static readonly string JdkFolder = "jdk-11"; + public static readonly string JdkFolder = "jdk-17"; public static readonly Version MicrosoftOpenJDK11Version = new Version (Configurables.MicrosoftOpenJDK11Version); public static readonly Version MicrosoftOpenJDK11Release = new Version (Configurables.MicrosoftOpenJDK11Release); @@ -307,7 +307,7 @@ public static partial class Paths public static string OpenJDK8InstallDir => GetCachedPath (ref openJDK8InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-1.8")); public static string OpenJDK8CacheDir => GetCachedPath (ref openJDK8CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); - public static string OpenJDK11InstallDir => GetCachedPath (ref openJDK11InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk-11")); + public static string OpenJDK11InstallDir => GetCachedPath (ref openJDK11InstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), Defaults.JdkFolder)); public static string OpenJDK11CacheDir => GetCachedPath (ref openJDK11CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory)); // bundle public static string BCLTestsArchiveName = "bcl-tests.zip"; diff --git a/external/Java.Interop b/external/Java.Interop index 6aedf1ca0ba..4d69b727a91 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 6aedf1ca0baaeece6d2ef75deb19a077e8fc78f0 +Subproject commit 4d69b727a916f7038774c0fa2875ddad42f68565 diff --git a/external/Java.Interop.override.props b/external/Java.Interop.override.props index 8cbac6945cf..2abaaf493cd 100644 --- a/external/Java.Interop.override.props +++ b/external/Java.Interop.override.props @@ -2,6 +2,7 @@ $(MSBuildThisFileDirectory)xamarin-android-tools + 17.99.0 diff --git a/src/manifestmerger/build.gradle b/src/manifestmerger/build.gradle index 1cc1f13b018..63849a3d59f 100644 --- a/src/manifestmerger/build.gradle +++ b/src/manifestmerger/build.gradle @@ -19,7 +19,7 @@ repositories { dependencies { // https://mvnrepository.com/artifact/com.android.tools.build/manifest-merger - compile group: 'com.android.tools.build', name: 'manifest-merger', version: '30.3.1' + implementation 'com.android.tools.build:manifest-merger:30.3.1' } sourceSets { @@ -36,10 +36,10 @@ jar { attributes 'Main-Class': 'com.xamarin.manifestmerger.Main' } from { - configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } { // Exclude native jnidispatch content to simplify installer signing and notarization exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'com/sun/jna/**/*jnidispatch*' } - archiveName 'manifestmerger.jar' -} \ No newline at end of file + archiveFileName.set('manifestmerger.jar') +} diff --git a/src/monodroid/monodroid.targets b/src/monodroid/monodroid.targets index 08a94631e20..acddbbdf098 100644 --- a/src/monodroid/monodroid.targets +++ b/src/monodroid/monodroid.targets @@ -1,6 +1,9 @@ - + diff --git a/src/r8/build.gradle b/src/r8/build.gradle index 89ac931666a..988379d9be0 100644 --- a/src/r8/build.gradle +++ b/src/r8/build.gradle @@ -15,7 +15,7 @@ repositories { } dependencies { - compile group: 'com.android.tools', name: 'r8', version: '8.0.40' + implementation 'com.android.tools:r8:8.0.40' } jar { @@ -24,7 +24,7 @@ jar { attributes 'Main-Class': 'com.android.tools.r8.R8' } from { - configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - archiveName 'r8.jar' -} \ No newline at end of file + archiveFileName.set('r8.jar') +} From f8ab57aaee364303e523379ee460cabc12bfcedc Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 12 May 2023 19:56:40 -0400 Subject: [PATCH 3/4] `$(LatestSupportedJavaVersion)`=17.0.99! We got to the point of running unit tests on CI (yay!), which promptly started erroring out because of XA0030! error XA0030: Building with JDK version `17.0.7` is not supported. Please install JDK version `11.0`. See https://aka.ms/xamarin/jdk9-errors Update `$(LatestSupportedJavaVersion)` so that tests *can* run. --- src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 cb87a070127..6f24d0e127d 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.props.in @@ -9,7 +9,7 @@ false true true - 11.0.99 + 17.0.99 1.6.0 {abi}{versionCode:D5} UpdateGeneratedFiles From 39cb7511377e828f8c7af8339a796b7118f39c74 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Fri, 12 May 2023 22:16:42 -0400 Subject: [PATCH 4/4] Bump to newer xamarin/Java.Interop#1108 --- external/Java.Interop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Java.Interop b/external/Java.Interop index 4d69b727a91..cb29a4bd729 160000 --- a/external/Java.Interop +++ b/external/Java.Interop @@ -1 +1 @@ -Subproject commit 4d69b727a916f7038774c0fa2875ddad42f68565 +Subproject commit cb29a4bd729722e5a9301d22785095ada225af2f