[ci] Preliminary JDK11 Support (#4567)

Context: https://issuetracker.google.com/issues/150189789
Context: https://developer.android.com/preview/features#signature-scheme-v4
Context: https://developer.android.com/preview/features#incremental

Preliminary JDK 11 support.

The Android SDK Build-tools r30.0.0-rc4 package currently requires
JDK 11 in order to use `apksigner.jar`:

	Task "AndroidApkSigner"
	  Task Parameter:ApkSignerJar=C:\Users\dlab14\android-toolchain\sdk\build-tools\30.0.0-rc4\lib\apksigner.jar
	  …
	  Task Parameter:ToolPath=C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin
	  Task Parameter:ManifestFile=obj\Release\android\AndroidManifest.xml
	  C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar C:\Users\dlab14\android-toolchain\sdk\build-tools\30.0.0-rc4\lib\apksigner.jar sign --ks "C:\Users\dlab14\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 29  "C:\A\vs2019xam00000Y-1\_work\1\s\bin\TestRelease\temp\BuildAotApplication AndÜmläüts_x86_64_True_True\bin\Release\UnnamedProject.UnnamedProject-Signed.apk"
	  java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	  at java.lang.ClassLoader.defineClass1(Native Method)
	  …
	…\Xamarin.Android.Common.targets(2559,2): error MSB6006: "java.exe" exited with code 1.

This could be triggered by using the Android SDK Manager to install
Build-tools r30.0.0-rc4, then overriding the
`$(AndroidSdkBuildToolsVersion)` MSBuild property in `App.csproj`:

	<PropertyGroup>
	  <AndroidSdkBuildToolsVersion>30.0.0-rc4</AndroidSdkBuildToolsVersion>
	</PropertyGroup>

Many previous commits have added support for JDK 11, e.g. d99facb1,
dcee2c84, 4742d50d, 89f3dc15, and 895b7bc5 (among many others).

Additionally, c8ab4555 updated the build environment so that *both*
JetBrains OpenJDK 1.8 and 11 were installed, though 1.8 was still used.

Now it's time to "flip the build environment," and use JDK 11 to build
the product, installers, and run (most) unit tests:

  * Update `azure-pipelines.yaml` and `azure-pipelines-oss.yaml` so
    that JDK 11 is used to build everything.

  * Update `xaprepare` so that when `$(JavaSdkDirectory)` isn't
    overridden, JDK 11 is used by default.

  * Override the `JI_JAVA_HOME` environment variable when preparing
    `external/Java.Interop` so that it uses the desired JDK.

  * Update the default `$(LatestSupportedJavaVersion)` value to
    11.0.4, the version of the JDK we install.

  * Update the `<ValidateJavaVersions/>` task so that JDK 11 is
    required when `$(AndroidSdkBuildToolsVersion)` is >= r30.
    This will cause an XA0032 error if JDK 1.8 is used to build a
    project when `$(AndroidSdkBuildToolsVersion)` is >= r30.

  * `apksigner` from Build-tools r30 creates a new `.idsig` file
    next to the `.apk`.  This is to enable a new
    `adb install --incremental` feature.  Add the `.idsig` file
    to `@(FileWrites)`.

  * Update various unit test `.csproj` files to consistently
    `<Import/>` the `Configuration.props` file and use properties
    within it for default values.  This in particular allowed building
    e.g. `samples/HelloWorld` to implicitly use JDK 11.

  * Increase "expected" times in
    `tests/msbuild-times-reference/MSBuildDeviceIntegration.csv`
    as JDK 11 appears to be slower than JDK 1.8 (🙁).

  * *Disable* support for `@(JavaSourceJar)` when JDK 11 is used.
    JDK 11 changes the HTML generated by the `javadoc` command, and
    we need to update our HTML parser to handle it.  In the interest
    of expediency, disable this for now.

The Android Designer integration tests continue to use JDK 1.8,
as the Designer doesn't currently build under JDK 11.

TODO:

  * Fix `@(JavaSourceJar)` support:
    https://github.com/xamarin/xamarin-android/issues/4789
  * Allow Android Designer to work with JDK 11, run Designer
    integration tests using JDK 11.
  * Figure out how to not accidentally bitrot JDK 1.8 support.

Co-authored-by: Jonathan Pryor <jonpryor@vt.edu>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Jonathan Pobst <jonathan.pobst@microsoft.com>
Co-authored-by: Peter Collins <pecolli@microsoft.com>
This commit is contained in:
Marek Habersack 2020-06-09 05:57:35 +00:00 коммит произвёл GitHub
Родитель a111f6704d
Коммит 380e95e340
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
25 изменённых файлов: 216 добавлений и 55 удалений

Просмотреть файл

@ -0,0 +1,32 @@
### Preliminary JDK 11 Support
Xamarin.Android can now use JDK 11 to build libraries and applications.
JDK 11 is required in order to use Android SDK Build-tools r30,
currently a release candidate. Future versions of the Android SDK
*may* require JDK 11 for more scenarios. JDK 11 *is not required*
at this point in time.
Project authors can try switching to JDK 11 now to prepare
potential future JDK 11 requirements.
To do so:
1. Install JDK 11, for example
[JetBrains Runtime](https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime)
2. Tell Xamarin.Android to use JDK 11. This can be done within
[Visual Studio](https://docs.microsoft.com/en-us/xamarin/android/troubleshooting/questions/update-jdk?tabs=windows),
or can be done by setting the the `$(JavaSdkDirectory)` MSBuild
property to refer to the root of the JDK installation from (1).
#### Known Issues
When JDK 11 is used, the `@(JavaSourceJar)` Build action is not supported,
and binding projects will not parse Javadoc to determine parameter names.
This may result in different parameter names for existing bindings projects.
Authors of bindings projects affected by this change are recommended to
continue to use JDK 8 to build the bindings projects until this issue is
resolved.
The fix is being tracked as: https://github.com/xamarin/xamarin-android/issues/4789

Просмотреть файл

@ -17,7 +17,8 @@ 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.Jdk8.Folder: jdk-1.8
XA.Jdk11.Folder: jdk-11
XA.Build.MacOSSPool: VSEng-Xamarin-RedmondMacMojaveBuildPool-Android-OSS
XA.Build.LinuxOSSPool: Xamarin-Android-Ubuntu-Public
@ -158,7 +159,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/$(XA.Jdk.Folder)/bin"
- script: echo "##vso[task.setvariable variable=PATH]$PATH:$(Agent.HomeDirectory)/android-toolchain/$(XA.Jdk11.Folder)/bin"
displayName: append jdk tools to PATH
- script: make jenkins V=1 PREPARE_CI_PR=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration)

Просмотреть файл

@ -44,7 +44,8 @@ resources:
# Global variables
variables:
XA.Jdk.Folder: jdk-1.8
XA.Jdk8.Folder: jdk-1.8
XA.Jdk11.Folder: jdk-11
NuGetArtifactName: nupkgs
InstallerArtifactName: installers
TestAssembliesArtifactName: test-assemblies
@ -97,8 +98,8 @@ stages:
- checkout: self
submodules: recursive
- script: echo "##vso[task.setvariable variable=JAVA_HOME]$HOME/Library/Android/$(XA.Jdk.Folder)"
displayName: set JAVA_HOME
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk11.Folder)"
displayName: set JI_JAVA_HOME
- template: yaml-templates/use-dot-net.yaml
parameters:
@ -234,6 +235,10 @@ stages:
- template: yaml-templates\clean.yaml
- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
displayName: set JI_JAVA_HOME
- template: yaml-templates\use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
@ -896,7 +901,7 @@ stages:
if (("$branchName" -ne "master") -and ("$branchName" -notlike "d16*")) {
$branchName = "master"
}
Set-Location -Path $(System.DefaultWorkingDirectory)
Set-Location -Path $(System.DefaultWorkingDirectory)/designer
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update designer
@ -905,19 +910,31 @@ stages:
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)/bot-provisioning/dependencies.csx
provisioning_script: $(System.DefaultWorkingDirectory)/designer/bot-provisioning/dependencies.csx
provisioning_extra_args: -remove Xamarin.Android -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
- template: yaml-templates/run-installer.yaml
- template: yaml-templates/setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android
- script: echo "##vso[task.setvariable variable=JavaSdkDirectory]$HOME/Library/Android/$(XA.Jdk8.Folder)"
displayName: set JavaSdkDirectory
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk8.Folder)"
displayName: reset JI_JAVA_HOME for Designer
- template: designer/android-designer-build-mac.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/designer
- template: designer/android-designer-tests.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)/designer
- task: CopyFiles@2
displayName: 'Copy binlogs'
inputs:
sourceFolder: Xamarin.Designer.Android
sourceFolder: $(System.DefaultWorkingDirectory)/designer/Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs
overWrite: true
@ -960,7 +977,7 @@ stages:
if (("$branchName" -ne "master") -and ("$branchName" -notlike "d16*")) {
$branchName = "master"
}
Set-Location -Path $(System.DefaultWorkingDirectory)
Set-Location -Path $(System.DefaultWorkingDirectory)\designer
git checkout $branchName
git submodule update -q --init --recursive
displayName: Clone and update designer
@ -969,19 +986,34 @@ stages:
displayName: provision designer dependencies
inputs:
github_token: $(GitHub.Token)
provisioning_script: $(System.DefaultWorkingDirectory)\bot-provisioning\dependencies.csx
provisioning_script: $(System.DefaultWorkingDirectory)\designer\bot-provisioning\dependencies.csx
provisioning_extra_args: -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token)
- template: yaml-templates\run-installer.yaml
- template: yaml-templates\setup-test-environment.yaml
parameters:
xaSourcePath: $(System.DefaultWorkingDirectory)\xamarin-android
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk8.Folder)"
displayName: reset JI_JAVA_HOME for Designer
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))
- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk8.Folder)
displayName: reset JI_JAVA_HOME for Designer
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
- template: designer\android-designer-build-win.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\designer
- template: designer\android-designer-tests.yaml@yaml
parameters:
designerSourcePath: $(System.DefaultWorkingDirectory)\designer
- task: CopyFiles@2
displayName: 'Copy binlogs'
inputs:
sourceFolder: Xamarin.Designer.Android
sourceFolder: $(System.DefaultWorkingDirectory)/designer/Xamarin.Designer.Android
contents: '**/*.binlog'
targetFolder: $(Build.ArtifactStagingDirectory)/designer-binlogs
overWrite: true

Просмотреть файл

@ -1,6 +1,7 @@
parameters:
configuration: $(XA.Build.Configuration)
provisionExtraArgs: -vv -f
xaSourcePath: $(System.DefaultWorkingDirectory)
steps:
- checkout: self
@ -11,6 +12,15 @@ steps:
parameters:
provisionExtraArgs: ${{ parameters.provisionExtraArgs }}
- script: echo "##vso[task.setvariable variable=JI_JAVA_HOME]$HOME/Library/Android/$(XA.Jdk11.Folder)"
displayName: set JI_JAVA_HOME
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))
- script: |
echo ##vso[task.setvariable variable=JI_JAVA_HOME]%USERPROFILE%\android-toolchain\$(XA.Jdk11.Folder)
displayName: set JI_JAVA_HOME
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
- template: use-dot-net.yaml
parameters:
version: $(DotNetCorePreviewVersion)
@ -33,20 +43,20 @@ steps:
- task: MSBuild@1
displayName: build xaprepare
inputs:
solution: build-tools/xaprepare/xaprepare.sln
solution: ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare.sln
configuration: ${{ parameters.configuration }}
msbuildArguments: /restore
- script: >
mono build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes --no-emoji --run-mode=CI &&
mono build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=Required --auto-provision=yes --auto-provision-uses-sudo=yes --no-emoji --run-mode=CI &&
mono build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=AndroidToolchain --no-emoji --run-mode=CI
mono ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=UpdateMono --auto-provision=yes --auto-provision-uses-sudo=yes --no-emoji --run-mode=CI &&
mono ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=Required --auto-provision=yes --auto-provision-uses-sudo=yes --no-emoji --run-mode=CI &&
mono ${{ parameters.xaSourcePath }}/build-tools/xaprepare/xaprepare/bin/${{ parameters.configuration }}/xaprepare.exe --s=AndroidToolchain --no-emoji --run-mode=CI
displayName: install test dependencies
condition: and(succeeded(), eq(variables['agent.os'], 'Darwin'))
- script: >
$(System.DefaultWorkingDirectory)\build-tools\xaprepare\xaprepare\bin\${{ parameters.configuration }}\xaprepare.exe --s=Required --auto-provision=yes --no-emoji --run-mode=CI &&
$(System.DefaultWorkingDirectory)\build-tools\xaprepare\xaprepare\bin\${{ parameters.configuration }}\xaprepare.exe --s=AndroidToolchain --no-emoji --run-mode=CI
${{ parameters.xaSourcePath }}\build-tools\xaprepare\xaprepare\bin\${{ parameters.configuration }}\xaprepare.exe --s=Required --auto-provision=yes --no-emoji --run-mode=CI &&
${{ parameters.xaSourcePath }}\build-tools\xaprepare\xaprepare\bin\${{ parameters.configuration }}\xaprepare.exe --s=AndroidToolchain --no-emoji --run-mode=CI
displayName: install test dependencies
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
@ -59,17 +69,17 @@ steps:
displayName: nuget restore Xamarin.Android.Build.Tasks.sln
inputs:
command: custom
arguments: restore Xamarin.Android.Build.Tasks.sln -ConfigFile NuGet.config
arguments: restore ${{ parameters.xaSourcePath }}/Xamarin.Android.Build.Tasks.sln -ConfigFile ${{ parameters.xaSourcePath }}/NuGet.config -Verbosity detailed
- task: NuGetCommand@2
displayName: nuget restore Xamarin.Android-Tests.sln
inputs:
command: custom
arguments: restore Xamarin.Android-Tests.sln -ConfigFile NuGet.config
arguments: restore ${{ parameters.xaSourcePath }}/Xamarin.Android-Tests.sln -ConfigFile ${{ parameters.xaSourcePath }}/NuGet.config -Verbosity detailed
- task: MSBuild@1
displayName: build Xamarin.Android.Tools.BootstrapTasks.csproj
inputs:
solution: build-tools/xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj
solution: ${{ parameters.xaSourcePath }}/build-tools/xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks.csproj
configuration: ${{ parameters.configuration }}
msbuildArguments: /restore /bl:$(System.DefaultWorkingDirectory)/bin/Test${{ parameters.configuration }}/BootstrapTasks.binlog
msbuildArguments: /restore /bl:${{ parameters.xaSourcePath }}/bin/Test${{ parameters.configuration }}/BootstrapTasks.binlog

Просмотреть файл

@ -54,7 +54,7 @@ namespace Xamarin.Android.Prepare
{
public static readonly char[] PropertyListSeparator = new [] { ':' };
public static readonly string JdkFolder = "jdk-1.8";
public static readonly string JdkFolder = "jdk-11";
public static readonly Version JetBrainsOpenJDK11Version = new Version (Configurables.JetBrainsOpenJDK11Version);
public static readonly Version JetBrainsOpenJDK11Release = new Version (Configurables.JetBrainsOpenJDK11Release);

Просмотреть файл

@ -20,6 +20,7 @@ namespace Xamarin.Android.Prepare
"prepare",
"V=1",
$"CONFIGURATION={context.Configuration}",
$"JI_JAVA_HOME={context.OS.JavaHome}",
$"JAVA_HOME={context.OS.JavaHome}",
$"JI_MAX_JDK={Configurables.Defaults.MaxJDKVersion}",
}

Просмотреть файл

@ -13,9 +13,15 @@
<AssemblyName>HelloLibrary</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>false</AndroidApplication>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<DebugType>portable</DebugType>
</PropertyGroup>
<Import
Condition="Exists('..\..\..\Configuration.props')"
Project="..\..\..\Configuration.props"
/>
<PropertyGroup Condition="Exists('..\..\..\Configuration.props')">
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -14,8 +14,6 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v7.1</TargetFrameworkVersion>
<AndroidDexTool Condition=" '$(AndroidDexTool)' == '' ">d8</AndroidDexTool>
<DebugType>portable</DebugType>
</PropertyGroup>

Просмотреть файл

@ -16,7 +16,12 @@ This file is only used by binding projects. .NET 5 can eventually use it, once `
<UsingTask TaskName="Xamarin.Android.Tasks.MDoc" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Android.Tasks.Unzip" AssemblyFile="Xamarin.Android.Build.Tasks.dll" />
<PropertyGroup>
<_JavadocSupported Condition=" $(_JdkVersion.StartsWith ('1.8')) ">True</_JavadocSupported>
</PropertyGroup>
<Target Name="_ExtractJavaDocJars"
Condition=" '$(_JavadocSupported)' == 'True' "
Inputs="@(JavaDocJar)"
Outputs="@(JavaDocJar->'$(IntermediateOutputPath)javadocs\%(FileName).stamp')">
<Unzip
@ -30,6 +35,7 @@ This file is only used by binding projects. .NET 5 can eventually use it, once `
</Target>
<Target Name="_GenerateJavaDocFromSourceJars"
Condition=" '$(_JavadocSupported)' == 'True' "
Inputs="@(JavaSourceJar)"
Outputs="@(JavaSourceJar->'$(IntermediateOutputPath)javadocs\%(FileName).stamp')">
<Unzip
@ -51,9 +57,9 @@ This file is only used by binding projects. .NET 5 can eventually use it, once `
</Target>
<Target Name="BuildDocumentation"
Condition=" '@(JavaDocIndex)' != '' And '$(_JavadocSupported)' == 'True' "
Inputs="@(JavaDocIndex);@(IntermediateAssembly->'$(IntermediateOutputPath)%(filename).xml')"
Outputs="@(IntermediateAssembly->'$(OutputPath)%(filename).xml')"
Condition=" '@(JavaDocIndex)' != '' ">
Outputs="@(IntermediateAssembly->'$(OutputPath)%(filename).xml')">
<MDoc
References="@(ReferencePath);@(ReferenceDependencyPaths)"
TargetAssembly="@(IntermediateAssembly)"

Просмотреть файл

@ -5,7 +5,7 @@
<PropertyGroup>
<UsingAndroidNETSdk>true</UsingAndroidNETSdk>
<AndroidCommandLineToolsVersion Condition=" '$(AndroidCommandLineToolsVersion)' == '' ">1.0</AndroidCommandLineToolsVersion>
<LatestSupportedJavaVersion Condition=" '$(LatestSupportedJavaVersion)' == '' ">1.8.0</LatestSupportedJavaVersion>
<LatestSupportedJavaVersion Condition=" '$(LatestSupportedJavaVersion)' == '' ">11.0.4</LatestSupportedJavaVersion>
<MinimumSupportedJavaVersion Condition=" '$(MinimumSupportedJavaVersion)' == '' ">1.8.0</MinimumSupportedJavaVersion>
<EnableDefaultOutputPaths Condition=" '$(EnableDefaultOutputPaths)' == '' And '$(OS)' != 'Windows_NT' ">false</EnableDefaultOutputPaths>
<EnableDefaultOutputPaths Condition=" '$(EnableDefaultOutputPaths)' == '' ">true</EnableDefaultOutputPaths>

Просмотреть файл

@ -48,6 +48,13 @@ namespace Xamarin.Android.Tasks.Legacy
Version GetJavaVersionForFramework ()
{
var apiLevel = MonoAndroidHelper.SupportedVersions.GetApiLevelFromFrameworkVersion (TargetFrameworkVersion);
if (apiLevel >= 30) {
// At present, it *looks like* API-R works with Build-tools r29, but
// historically API-X requires Build-tools rX, so if/when API-30
// requires Build-tools r30, it will require JDK11.
// return new Version (11, 0);
return new Version (1, 8);
}
if (apiLevel >= 24)
return new Version (1, 8);
else if (apiLevel == 23)
@ -58,10 +65,18 @@ namespace Xamarin.Android.Tasks.Legacy
Version GetJavaVersionForBuildTools ()
{
string buildToolsVersionString = AndroidSdkBuildToolsVersion;
if (buildToolsVersionString != null) {
int index = buildToolsVersionString.IndexOf ('-');
if (index != -1)
buildToolsVersionString = buildToolsVersionString.Substring (0, index);
}
Version buildTools;
if (!Version.TryParse (AndroidSdkBuildToolsVersion, out buildTools)) {
if (!Version.TryParse (buildToolsVersionString, out buildTools)) {
return Version.Parse (LatestSupportedJavaVersion);
}
if (buildTools >= new Version (30, 0, 0))
return new Version (11, 0);
if (buildTools >= new Version (24, 0, 1))
return new Version (1, 8);
return Version.Parse (MinimumSupportedJavaVersion);

Просмотреть файл

@ -445,11 +445,38 @@ namespace Foo {
BinaryContent = () => Convert.FromBase64String (InlineData.JavaSourcesJarBase64)
});
Assert.IsTrue (bindingBuilder.Build (binding), "binding build should have succeeded");
var jdkVersion = GetJdkVersion ();
if (jdkVersion > new Version (9, 0)) {
Assert.Ignore ("JDK 11 and @(JavaSourceJar) don't currently mix.");
return;
}
string xml = bindingBuilder.Output.GetIntermediaryAsText ("docs/Com.Xamarin.Android.Test.Msbuildtest/JavaSourceJarTest.xml");
Assert.IsTrue (xml.Contains ("<param name=\"name\"> - name to display.</param>"), "missing doc");
}
}
static Version GetJdkVersion ()
{
var jdkPath = AndroidSdkResolver.GetJavaSdkPath ();
var releasePath = Path.Combine (jdkPath, "release");
if (!File.Exists (releasePath))
return null;
foreach (var line in File.ReadLines (releasePath)) {
const string JavaVersionStart = "JAVA_VERSION=\"";
if (!line.StartsWith (JavaVersionStart, StringComparison.OrdinalIgnoreCase))
continue;
var value = line.Substring (JavaVersionStart.Length, line.Length - JavaVersionStart.Length - 1);
int last = 0;
for (last = 0; last < value.Length; ++last) {
if (char.IsDigit (value, last) || value [last] == '.')
continue;
break;
}
return Version.Parse (last == value.Length ? value : value.Substring (0, last));
}
return null;
}
[Test]
[TestCaseSource (nameof (ClassParseOptions))]
public void DesignTimeBuild (string classParser)

Просмотреть файл

@ -3308,13 +3308,14 @@ AAMMAAABzYW1wbGUvSGVsbG8uY2xhc3NQSwUGAAAAAAMAAwC9AAAA1gEAAAAA") });
$"TargetFrameworkRootPath={referencesPath}",
$"AndroidSdkDirectory={androidSdkPath}",
};
string buildToolsVersion = GetExpectedBuildToolsVersion ();
using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName), cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
builder.ThrowOnBuildFailure = false;
builder.Target = "GetAndroidDependencies";
Assert.True (builder.Build (proj, parameters: parameters),
string.Format ("First Build should have succeeded"));
StringAssertEx.Contains ("platforms/android-26", builder.LastBuildOutput, "platforms/android-26 should be a dependency.");
StringAssertEx.Contains ("build-tools/29.0.2", builder.LastBuildOutput, "build-tools/29.0.2 should be a dependency.");
StringAssertEx.Contains ($"build-tools/{buildToolsVersion}", builder.LastBuildOutput, $"build-tools/{buildToolsVersion} should be a dependency.");
StringAssertEx.Contains ("platform-tools", builder.LastBuildOutput, "platform-tools should be a dependency.");
}
}
@ -3341,17 +3342,30 @@ AAMMAAABzYW1wbGUvSGVsbG8uY2xhc3NQSwUGAAAAAAMAAwC9AAAA1gEAAAAA") });
$"AndroidSdkDirectory={androidSdkPath}",
};
string buildToolsVersion = GetExpectedBuildToolsVersion ();
using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName), cleanupAfterSuccessfulBuild: false, cleanupOnDispose: false)) {
builder.ThrowOnBuildFailure = false;
builder.Target = "GetAndroidDependencies";
Assert.True (builder.Build (proj, parameters: parameters),
string.Format ("First Build should have succeeded"));
StringAssertEx.Contains ("platforms/android-26", builder.LastBuildOutput, "platforms/android-26 should be a dependency.");
StringAssertEx.Contains ("build-tools/29.0.2", builder.LastBuildOutput, "build-tools/29.0.2 should be a dependency.");
StringAssertEx.Contains ($"build-tools/{buildToolsVersion}", builder.LastBuildOutput, $"build-tools/{buildToolsVersion} should be a dependency.");
StringAssertEx.Contains ("platform-tools", builder.LastBuildOutput, "platform-tools should be a dependency.");
}
}
static readonly XNamespace MSBuildXmlns = "http://schemas.microsoft.com/developer/msbuild/2003";
static string GetExpectedBuildToolsVersion ()
{
var propsPath = Path.Combine (XABuildPaths.TopDirectory, "src", "Xamarin.Android.Build.Tasks", "Xamarin.Android.Common.props.in");
var props = XElement.Load (propsPath);
var AndroidSdkBuildToolsVersion = props.Elements (MSBuildXmlns+"PropertyGroup")
.Elements (MSBuildXmlns+"AndroidSdkBuildToolsVersion")
.FirstOrDefault ();
return AndroidSdkBuildToolsVersion?.Value?.Trim ();
}
[Test]
public void ValidateUseLatestAndroid ()
{

Просмотреть файл

@ -206,7 +206,7 @@ namespace Xamarin.Android.Build.Tests
Assert.AreEqual (0, warnings.Count, "Task should have no warnings.");
Assert.AreEqual (0, task.ExitCode, "ExitCode should have been 0");
string output = string.Join (" ", messages.Select (x => x.Message));
Assert.IsTrue (output.Contains ("Certificate fingerprint (SHA1):"), "Certificate SHA1 should have been printed.");
Assert.IsTrue (output.Contains ("Certificate fingerprint (SHA"), "Certificate SHA1 or SHA-256 should have been printed.");
}
}
}

Просмотреть файл

@ -7,7 +7,7 @@
<ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
<CopyNuGetImplementations Condition=" '$(CopyNuGetImplementations)' == ''">true</CopyNuGetImplementations>
<YieldDuringToolExecution Condition="'$(YieldDuringToolExecution)' == ''">true</YieldDuringToolExecution>
<LatestSupportedJavaVersion Condition="'$(LatestSupportedJavaVersion)' == ''">1.8.0</LatestSupportedJavaVersion>
<LatestSupportedJavaVersion Condition="'$(LatestSupportedJavaVersion)' == ''">11.0.4</LatestSupportedJavaVersion>
<MinimumSupportedJavaVersion Condition="'$(MinimumSupportedJavaVersion)' == ''">1.6.0</MinimumSupportedJavaVersion>
<AndroidCommandLineToolsVersion Condition=" '$(AndroidCommandLineToolsVersion)' == '' ">1.0</AndroidCommandLineToolsVersion>
<AndroidVersionCodePattern Condition=" '$(AndroidUseLegacyVersionCode)' != 'True' And '$(AndroidVersionCodePattern)' == '' ">{abi}{versionCode:D5}</AndroidVersionCodePattern>

Просмотреть файл

@ -2734,6 +2734,7 @@ because xbuild doesn't support framework reference assemblies.
<FileWrites Include="$(_AndroidResgenFlagFile)" />
<FileWrites Include="$(IntermediateOutputPath)R.txt" />
<FileWrites Include="$(ApkFileSigned)" />
<FileWrites Include="$(ApkFileSigned).idsig" />
<FileWrites Include="$(_UploadFlagFile)" />
<FileWrites Include="@(_ModifiedResources)" />
</ItemGroup>

Просмотреть файл

@ -8,14 +8,15 @@
<OutputType>Library</OutputType>
<RootNamespace>LocalTests.NUnit</RootNamespace>
<AssemblyName>LocalTests.NUnit</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
</PropertyGroup>
<Import Project="..\..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -9,18 +9,19 @@
<OutputType>Library</OutputType>
<RootNamespace>UnitTestRunner</RootNamespace>
<AssemblyName>Xamarin.Android.Bcl_Tests</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
</PropertyGroup>
<Import Project="..\..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -8,17 +8,23 @@
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.Tests.CodeBehindBuildTests</RootNamespace>
<AssemblyName>CodeBehindBuildTests</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<AndroidGenerateLayoutBindings>True</AndroidGenerateLayoutBindings>
<DebugType>portable</DebugType>
<_ApkDebugKeyStore>debug.keystore</_ApkDebugKeyStore>
<AppendTargetFrameworkToIntermediateOutputPath>false</AppendTargetFrameworkToIntermediateOutputPath>
</PropertyGroup>
<Import
Condition="Exists('..\..\..\Configuration.props')"
Project="..\..\..\Configuration.props"
/>
<PropertyGroup Condition="Exists('..\..\..\Configuration.props')">
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>

Просмотреть файл

@ -8,16 +8,21 @@
<OutputType>Library</OutputType>
<RootNamespace>CommonSampleLibrary</RootNamespace>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AssemblyName>CommonSampleLibrary</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<DebugType>portable</DebugType>
</PropertyGroup>
<Import
Condition="Exists('..\..\..\Configuration.props')"
Project="..\..\..\Configuration.props"
/>
<PropertyGroup Condition="Exists('..\..\..\Configuration.props')">
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -17,12 +17,13 @@
<AssemblyName>Xamarin.Android.JcwGen-Tests</AssemblyName>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<Import Project="..\..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -8,15 +8,14 @@
<OutputType>Library</OutputType>
<RootNamespace>EmbeddedDSO</RootNamespace>
<AssemblyName>Xamarin.Android.EmbeddedDSO_Test</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
<AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
<AppendTargetFrameworkToIntermediateOutputPath>false</AppendTargetFrameworkToIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(UnitTestsMode)' == 'true' ">
@ -28,6 +27,9 @@
</PropertyGroup>
<Import Project="$(RelativeRootPath)\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<!-- We have to limit the supported abis to the currently enabled set, since the PR builders don't build all architectures but,

Просмотреть файл

@ -8,14 +8,15 @@
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.UnitTests.XUnit</RootNamespace>
<AssemblyName>TestRunner.xUnit</AssemblyName>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
</PropertyGroup>
<Import Project="..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -18,10 +18,11 @@
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
<TargetFrameworkVersion>v8.1</TargetFrameworkVersion>
<AndroidUseLatestPlatformSdk>true</AndroidUseLatestPlatformSdk>
</PropertyGroup>
<Import Project="..\..\..\Configuration.props" />
<PropertyGroup>
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>

Просмотреть файл

@ -2,15 +2,15 @@
# First non-comment row is human description of columns
Test Name,Time in ms (int)
# Data
Build_From_Clean_DontIncludeRestore,9500
Build_From_Clean_DontIncludeRestore,10500
Build_No_Changes,2000
Build_CSharp_Change,3250
Build_AndroidResource_Change,3000
Build_AndroidManifest_Change,3250
Build_Designer_Change,2500
Build_JLO_Change,8500
Build_CSProj_Change,9000
Build_XAML_Change,7000
Build_JLO_Change,9600
Build_CSProj_Change,10200
Build_XAML_Change,7100
Build_XAML_Change_RefAssembly,4000
Install_CSharp_Change,4000
Install_XAML_Change,5000

1 # Comments and blank lines are ignored
2 # First non-comment row is human description of columns
3 Test Name,Time in ms (int)
4 # Data
5 Build_From_Clean_DontIncludeRestore,9500 Build_From_Clean_DontIncludeRestore,10500
6 Build_No_Changes,2000
7 Build_CSharp_Change,3250
8 Build_AndroidResource_Change,3000
9 Build_AndroidManifest_Change,3250
10 Build_Designer_Change,2500
11 Build_JLO_Change,8500 Build_JLO_Change,9600
12 Build_CSProj_Change,9000 Build_CSProj_Change,10200
13 Build_XAML_Change,7000 Build_XAML_Change,7100
14 Build_XAML_Change_RefAssembly,4000
15 Install_CSharp_Change,4000
16 Install_XAML_Change,5000