Skip to content

Commit

Permalink
Bump to xamarin/xamarin-android-tools/main@d92fc3e3 (dotnet#823)
Browse files Browse the repository at this point in the history
Context: https://developercommunity.visualstudio.com/t/illegal-character-exception-in-xamarinandroid-afte/1363149

Changes: dotnet/android-tools@554d45a...d92fc3e

  * dotnet/android-tools@d92fc3e: [Xamarin.Android.Tools.AndroidSdk] Probe for AdoptOpenJDK Locations (dotnet#115)
  * dotnet/android-tools@dca30d9: [Xamarin.Android.Tools.AndroidSdk] Probe for Zulu JDK (dotnet#114)
  * dotnet/android-tools@237642c: [Xamarin.Android.Tools.AndroidSdk] Probe for Microsoft OpenJDK dirs (dotnet#113)
  * dotnet/android-tools@e618e00: [Xamarin.Android.Tools.AndroidSdk] Fix quotes in %PATH% or %PATHEXT% (dotnet#112)

Finally, *prefer* JDK 8, as hilarious as that is, for two reasons:

 1. `gradlew` fails to execute when running under OpenJDK 14:

        [ERROR] [system.err] java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

 2. The unit tests added in 69e1b80 currently depend upon the XML
    formatting conventions of JDK 8, and the tests fail when running
    under JDK 11 because of whitespace changes in `javax.xml` output.

For now, it's currently easier to just require JDK 8.

The preferred JDK version is controlled by the new `$(MaxJdkVersion)`
YAML variable, which in turn sets `$(JI_MAX_JDK)` (55c56f7) and/or
the `$(MaxJdkVersion)` MSBuild property, which
`dotnet build -t:Prepare` uses to generate `bin/Build*/JdkInfo.props`.

Finally, *for consistency*, update `TestJVM` to look for the generated
`JdkInfo.props`.  If found, use the `$(JdkJvmPath)` value at
`/Project/Chooose/When/PropertyGroup/JdkJvmPath` instead of using
`JdkInfo.GetKnownSystemJdkInfos()`, so that the JVM that we built
against is also used for unit test execution.
  • Loading branch information
jonpryor committed Apr 20, 2021
1 parent a3de91e commit 002dea4
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 10 deletions.
9 changes: 5 additions & 4 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pr:
variables:
RunningOnCI: true
Build.Configuration: Release
MaxJdkVersion: 8
DotNetCoreVersion: 5.0.103
HostedMacImage: macOS-10.15
HostedWinVS2019: Hosted Windows 2019 with VS2019
Expand Down Expand Up @@ -108,15 +109,15 @@ jobs:

- template: templates\install-dependencies.yaml

- script: make prepare CONFIGURATION=$(Build.Configuration)
- script: make prepare CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make prepare

- script: make all CONFIGURATION=$(Build.Configuration)
- script: make all CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make all

- script: |
r=0
make run-all-tests CONFIGURATION=$(Build.Configuration) || r=$?
make run-all-tests CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion) || r=$?
jar cf xatb.jar -C tests/Xamarin.Android.Tools.Bytecode-Tests/obj/*/classes .
zip -r bin.zip bin
exit $r
Expand Down Expand Up @@ -158,7 +159,7 @@ jobs:

- template: templates\install-dependencies.yaml

- script: make prepare-core CONFIGURATION=$(Build.Configuration)
- script: make prepare-core CONFIGURATION=$(Build.Configuration) JI_MAX_JDK=$(MaxJdkVersion)
displayName: make prepare-core

- template: templates\core-build.yaml
Expand Down
2 changes: 1 addition & 1 deletion build-tools/automation/templates/core-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
displayName: Prepare Solution
inputs:
projects: Java.Interop.sln
arguments: '-c $(Build.Configuration) -target:Prepare'
arguments: '-c $(Build.Configuration) -target:Prepare -p:MaxJdkVersion=$(MaxJdkVersion)'

- task: DotNetCoreCLI@2
displayName: Build Solution
Expand Down
6 changes: 5 additions & 1 deletion build-tools/scripts/Prepare.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
<Target Name="Prepare">
<Exec Command="git submodule update --init --recursive" WorkingDirectory="$(_TopDir)" />
<MSBuild Projects="$(MSBuildThisFileDirectory)..\..\build-tools\Java.Interop.BootstrapTasks\Java.Interop.BootstrapTasks.csproj" />
<PropertyGroup>
<_MaxJdk>$(MaxJdkVersion)</_MaxJdk>
<_MaxJdk Condition=" '$(_MaxJdk)' == '' ">$(JI_MAX_JDK)</_MaxJdk>
</PropertyGroup>
<JdkInfo
JdksRoot="$(ProgramFiles)\Java"
MakeFragmentFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\JdkInfo.mk"
MaximumJdkVersion="$(JI_MAX_MDK)"
MaximumJdkVersion="$(_MaxJdk)"
PropertyFile="$(_TopDir)\bin\Build$(Configuration)\JdkInfo.props">
<Output TaskParameter="JavaHomePath" PropertyName="_JavaSdkDirectory" />
</JdkInfo>
Expand Down
2 changes: 1 addition & 1 deletion external/xamarin-android-tools
40 changes: 37 additions & 3 deletions tests/TestJVM/TestJVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using System.Threading;
using System.Text;
using System.Xml.Linq;

using Xamarin.Android.Tools;

Expand Down Expand Up @@ -47,14 +48,47 @@ static TextWriter GetLogOutput (string envVar, string prefix, Assembly caller)

static string GetJvmLibraryPath ()
{
var env = Environment.GetEnvironmentVariable ("JI_JVM_PATH");
if (!string.IsNullOrEmpty (env))
return env;
var jdkDir = ReadJavaSdkDirectoryFromJdkInfoProps ();
if (jdkDir != null) {
return jdkDir;
}
var jdk = JdkInfo.GetKnownSystemJdkInfos ()
.FirstOrDefault ();
return jdk?.JdkJvmPath;
}

static string ReadJavaSdkDirectoryFromJdkInfoProps ()
{
var location = typeof (TestJVM).Assembly.Location;
var binDir = Path.GetDirectoryName (Path.GetDirectoryName (location));
var testDir = Path.GetFileName (Path.GetDirectoryName (location));
if (!testDir.StartsWith ("Test", StringComparison.OrdinalIgnoreCase)) {
return null;
}
var buildName = testDir.Replace ("Test", "Build");
if (buildName.Contains ('-')) {
buildName = buildName.Substring (0, buildName.IndexOf ('-'));
}
var jdkPropFile = Path.Combine (binDir, buildName, "JdkInfo.props");
if (!File.Exists (jdkPropFile)) {
return null;
}

var msbuild = XNamespace.Get ("http://schemas.microsoft.com/developer/msbuild/2003");

var jdkProps = XDocument.Load (jdkPropFile);
var jdkJvmPath = jdkProps.Elements ()
.Elements (msbuild + "Choose")
.Elements (msbuild + "When")
.Elements (msbuild + "PropertyGroup")
.Elements (msbuild + "JdkJvmPath")
.FirstOrDefault ();
if (jdkJvmPath == null) {
return null;
}
return jdkJvmPath.Value;
}

Dictionary<string, Type> typeMappings;

public TestJVM (string[] jars = null, Dictionary<string, Type> typeMappings = null)
Expand Down

0 comments on commit 002dea4

Please sign in to comment.