Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Use Microsoft OpenJDK 21.0.5 #9651

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions build-tools/automation/yaml-templates/build-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
emulatorMSBuildArgs: ''
jobName: CheckTimeZoneInfoIsCorrectNode1
jobTimeout: 360
jdkTestFolder: $(JAVA_HOME_17_X64)
jdkTestFolder: $(JAVA_HOME_21_X64)
testSteps: []
use1ESTemplate: true

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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}");

/// <summary>
/// Base URL for all Android SDK and NDK downloads. Used in <see cref="AndroidToolchain"/>
Expand All @@ -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";

Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -269,8 +269,8 @@ static string GetCachedPath (ref string? variable, Func<string> 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;
Expand Down
4 changes: 2 additions & 2 deletions build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 7 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
<CopyNuGetImplementations Condition=" '$(CopyNuGetImplementations)' == ''">true</CopyNuGetImplementations>
<YieldDuringToolExecution Condition="'$(YieldDuringToolExecution)' == ''">true</YieldDuringToolExecution>
<LatestSupportedJavaVersion Condition="'$(LatestSupportedJavaVersion)' == ''">17.0.99</LatestSupportedJavaVersion>
<LatestSupportedJavaVersion Condition="'$(LatestSupportedJavaVersion)' == ''">21.0.99</LatestSupportedJavaVersion>
<AndroidVersionCodePattern Condition=" '$(AndroidUseLegacyVersionCode)' != 'True' And '$(AndroidVersionCodePattern)' == '' ">{abi}{versionCode:D5}</AndroidVersionCodePattern>
<AndroidResourceGeneratorTargetName>UpdateGeneratedFiles</AndroidResourceGeneratorTargetName>
<AndroidUseApkSigner Condition=" '$(AndroidUseApkSigner)' == '' ">True</AndroidUseApkSigner>
Expand Down
14 changes: 13 additions & 1 deletion tools/workload-dependencies/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 },
Expand Down Expand Up @@ -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})"));
Expand All @@ -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<XElement> GetSupportedElements (XDocument doc, string element)
{
if (doc.Root == null) {
Expand Down
1 change: 1 addition & 0 deletions tools/workload-dependencies/WorkloadDependencies.proj
Original file line number Diff line number Diff line change
Expand Up @@ -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)" />
Expand Down
Loading