Skip to content

Commit

Permalink
[ci] Install JetBrains OpenJDK 8, 11 (#4773)
Browse files Browse the repository at this point in the history
Context: #4567

We want to support using OpenJDK 11 to build Xamarin.Android projects.
For better or worse, we can't "change the entire world," not all at
once.  In particular, the Android Designer Integration Tests do not
currently support building with or running under JDK 11.

"Split the difference", kind of: Instead of installing Corretto JDK 8
into `$HOME/android-toolchain/jdk`, install JetBrains OpenJDK 8 and 11
into the new paths:

  * `$HOME/android-toolchain/jdk-1.8`
  * `$HOME/android-toolchain/jdk-11`

We will continue *using* JDK 1.8 by default, until PR #4567 is ready
to completely merge, at which point we'll use JDK 11 to build
Xamarin.Android, while continuing to use JDK 1.8 with the Designer.

Co-authored-by: Marek Habersack <grendel@twistedcode.net>
  • Loading branch information
jonpryor and grendello authored Jun 5, 2020
1 parent 16e971f commit c8ab455
Show file tree
Hide file tree
Showing 20 changed files with 419 additions and 229 deletions.
3 changes: 2 additions & 1 deletion build-tools/automation/azure-pipelines-oss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pr:
# Predefined variables: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
# https://dev.azure.com/xamarin/public/_apps/hub/ms.vss-ciworkflow.build-ci-hub?_a=edit-build-definition&id=48&view=Tab_Variables
variables:
XA.Jdk.Folder: jdk-1.8
XA.Build.MacOSSPool: VSEng-Xamarin-RedmondMacMojaveBuildPool-Android-OSS
XA.Build.LinuxOSSPool: Xamarin-Android-Ubuntu-Public

Expand Down Expand Up @@ -157,7 +158,7 @@ stages:
- script: echo "##vso[task.setvariable variable=HOME]$(Agent.HomeDirectory)"
displayName: set HOME to agent directory

- script: echo "##vso[task.setvariable variable=PATH]$PATH:$(Agent.HomeDirectory)/android-toolchain/jdk/bin"
- script: echo "##vso[task.setvariable variable=PATH]$PATH:$(Agent.HomeDirectory)/android-toolchain/$(XA.Jdk.Folder)/bin"
displayName: append jdk tools to PATH

- script: make jenkins V=1 PREPARE_CI_PR=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration)
Expand Down
3 changes: 2 additions & 1 deletion build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ resources:

# Global variables
variables:
XA.Jdk.Folder: jdk-1.8
NuGetArtifactName: nupkgs
InstallerArtifactName: installers
TestAssembliesArtifactName: test-assemblies
Expand Down Expand Up @@ -96,7 +97,7 @@ stages:
- checkout: self
submodules: recursive

- script: echo "##vso[task.setvariable variable=JAVA_HOME]$HOME/Library/Android/jdk"
- script: echo "##vso[task.setvariable variable=JAVA_HOME]$HOME/Library/Android/$(XA.Jdk.Folder)"
displayName: set JAVA_HOME

- template: yaml-templates/use-dot-net.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
const string JetBrainsOpenJDKOperatingSystem = "linux-x64";

partial class Urls
{
public static readonly Uri Corretto = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-linux-x64.tar.gz");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
partial class Urls
{
public static readonly Uri Corretto = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-macosx-x64.tar.gz");
}
const string JetBrainsOpenJDKOperatingSystem = "osx-x64";

partial class Defaults
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,11 @@ namespace Xamarin.Android.Prepare
{
partial class Configurables
{
partial class Urls
{
public static Uri Corretto => GetWindowsCorrettoUrl ();

public static readonly Uri Corretto64 = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-windows-x64-jdk.zip");
public static readonly Uri Corretto32 = new Uri ($"{Corretto_BaseUri}{CorrettoUrlPathVersion}/amazon-corretto-{CorrettoDistVersion}-windows-x86-jdk.zip");

static Uri GetWindowsCorrettoUrl ()
{
if (Context.Instance.OS == null)
return Corretto64;

return Context.Instance.OS.Is64Bit ? Corretto64 : Corretto32;
}
}
const string JetBrainsOpenJDKOperatingSystem = "windows-x64";

partial class Defaults
{
public const string NativeLibraryExtension = ".dll";
public static readonly Version CorrettoVersion = Version.Parse (CorrettoDistVersion);
}

partial class Paths
Expand Down
41 changes: 34 additions & 7 deletions build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,30 @@ namespace Xamarin.Android.Prepare
//
partial class Configurables
{
const string JetBrainsOpenJDK11Version = "11.0.4";
const string JetBrainsOpenJDK11Release = "546.1";
static readonly string JetBrainsOpenJDK11DownloadVersion = JetBrainsOpenJDK11Version.Replace ('.', '_');

const string JetBrainsOpenJDK8Version = "8.202";
const string JetBrainsOpenJDK8Release = "1483.37";
static readonly string JetBrainsOpenJDK8DownloadVersion = JetBrainsOpenJDK8Version.Replace ('.', 'u');

const string CorrettoDistVersion = "8.242.08.1";
const string CorrettoUrlPathVersion = CorrettoDistVersion;

static Context ctx => Context.Instance;

public static partial class Urls
{
// Keep the trailing slash here - OS-specific code assumes it's there.
public const string Corretto_BaseUri = "https://corretto.aws/downloads/resources/";
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-8u202-linux-x64-b1483.37.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-8u202-osx-x64-b1483.37.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-8u202-windows-x64-b1483.37.tar.gz
public static readonly Uri JetBrainsOpenJDK8 = new Uri ($"https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-{JetBrainsOpenJDK8DownloadVersion}-{JetBrainsOpenJDKOperatingSystem}-b{JetBrainsOpenJDK8Release}.tar.gz");

// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-linux-x64-b546.1.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
// https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-windows-x64-b546.1.tar.gz
public static readonly Uri JetBrainsOpenJDK11 = new Uri ($"https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-{JetBrainsOpenJDK11DownloadVersion}-{JetBrainsOpenJDKOperatingSystem}-b{JetBrainsOpenJDK11Release}.tar.gz");

/// <summary>
/// Base URL for all Android SDK and NDK downloads. Used in <see cref="AndroidToolchain"/>
Expand All @@ -39,6 +54,14 @@ public static partial class Defaults
{
public static readonly char[] PropertyListSeparator = new [] { ':' };

public static readonly string JdkFolder = "jdk-1.8";

public static readonly Version JetBrainsOpenJDK11Version = new Version (Configurables.JetBrainsOpenJDK11Version);
public static readonly Version JetBrainsOpenJDK11Release = new Version (Configurables.JetBrainsOpenJDK11Release);

public static readonly Version JetBrainsOpenJDK8Version = new Version (Configurables.JetBrainsOpenJDK8Version);
public static readonly Version JetBrainsOpenJDK8Release = new Version (Configurables.JetBrainsOpenJDK8Release);

// Mono runtimes
public const string DebugFileExtension = ".pdb";
public const string MonoHostMingwRuntimeNativeLibraryExtension = WindowsDLLSuffix;
Expand Down Expand Up @@ -104,9 +127,9 @@ public static partial class Defaults
public const int DefaultMaximumParallelTasks = 5;

/// <summary>
/// The maximum JDK version we support. Note: this will probably go away with Corretto
/// The maximum JDK version we support.
/// </summary>
public const int MaxJDKVersion = 8;
public static readonly Version MaxJDKVersion = new Version (11, 99, 0);

/// <summary>
/// Prefix for all the log files created by the bootstrapper.
Expand Down Expand Up @@ -314,10 +337,12 @@ public static partial class Paths
public static string Mingw32CmakePath => GetCachedPath (ref mingw32CmakePath, () => Path.Combine (BuildBinDir, "mingw-32.cmake"));
public static string Mingw64CmakePath => GetCachedPath (ref mingw64CmakePath, () => Path.Combine (BuildBinDir, "mingw-64.cmake"));

// Corretto OpenJDK
public static string CorrettoCacheDir => GetCachedPath (ref correttoCacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
public static string CorrettoInstallDir => GetCachedPath (ref correttoInstallDir, () => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainDirectory), "jdk"));
// JetBrains OpenJDK
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 OpenJDK11CacheDir => GetCachedPath (ref openJDK11CacheDir, () => ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory));
// bundle
public static string BCLTestsArchiveName = "bcl-tests.zip";

Expand Down Expand Up @@ -403,6 +428,8 @@ static string GetCachedPath (ref string? variable, Func<string> creator)
static string? monoSdksTpnExternalPath;
static string? monoSDKSIncludeDestDir;
static string? monoLlvmTpnPath;
static string? openJDK8InstallDir, openJDK11InstallDir;
static string? openJDK8CacheDir, openJDK11CacheDir;
}
}
}
2 changes: 1 addition & 1 deletion build-tools/xaprepare/xaprepare/OperatingSystems/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected virtual bool InitOS ()
JavaHome = Context.Instance.Properties.GetValue (KnownProperties.JavaSdkDirectory)?.Trim () ?? String.Empty;
if (String.IsNullOrEmpty (JavaHome)) {
var androidToolchainDirectory = Context.Instance.Properties.GetValue (KnownProperties.AndroidToolchainDirectory)?.Trim ();
JavaHome = Path.Combine (androidToolchainDirectory, "jdk");
JavaHome = Path.Combine (androidToolchainDirectory, Configurables.Defaults.JdkFolder);
}

string extension = IsWindows ? ".exe" : string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ namespace Xamarin.Android.Prepare
partial class Scenario_AndroidToolchain : ScenarioNoStandardEndSteps
{
public Scenario_AndroidToolchain ()
: base ("AndroidToolchain", "Install Android SDK, NDK and Corretto JDK.")
: base ("AndroidToolchain", "Install Android SDK, NDK and OpenJDK.")
{}

protected override void AddSteps (Context context)
{
Steps.Add (new Step_InstallCorrettoOpenJDK ());
Steps.Add (new Step_InstallJetBrainsOpenJDK8 ());
Steps.Add (new Step_InstallJetBrainsOpenJDK11 ());
Steps.Add (new Step_Android_SDK_NDK ());

// disable installation of missing programs...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ protected override void AddSteps (Context context)
throw new ArgumentNullException (nameof (context));

Steps.Add (new Step_ShowEnabledRuntimes ());
Steps.Add (new Step_InstallCorrettoOpenJDK ());
Steps.Add (new Step_InstallJetBrainsOpenJDK8 ());
Steps.Add (new Step_InstallJetBrainsOpenJDK11 ());
Steps.Add (new Step_Android_SDK_NDK ());
Steps.Add (new Step_GenerateFiles (atBuildStart: true));
Steps.Add (new Step_PrepareProps ());
Expand Down

This file was deleted.

This file was deleted.

160 changes: 0 additions & 160 deletions build-tools/xaprepare/xaprepare/Steps/Step_InstallCorrettoOpenJDK.cs

This file was deleted.

Loading

0 comments on commit c8ab455

Please sign in to comment.