[Xamarin.Android.Build.Tests] Workaround broken lint.bat (#994)

Context: https://issuetracker.google.com/issues/68753324

The Windows' SDK tools v26 `lint.bat` tool installed to
`$(AndroidToolchainDirectory)\sdk\tools\bin` appears to be broken, so
a all tests which use it are failing.

This can be worked around -- allowing the `lint`-based tests to pass
on Windows -- by setting the `%JAVA_OPTS%` environment variable.
Hopefully this is a temporary workaround until a new version of the
SDK tools comes out that fixes this issue.

One other thing to note here is that the Android SDK installed by
Visual Studio uses the SDK tools version 25.x, which does not appear
to have this issue on windows.
This commit is contained in:
Jonathan Peppers 2017-11-06 20:44:52 -06:00 коммит произвёл Jonathan Pryor
Родитель 73121ee699
Коммит b10508aa25
1 изменённых файлов: 19 добавлений и 0 удалений

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

@ -890,9 +890,26 @@ namespace App1
}
}
/// <summary>
/// Works around a bug in lint.bat on Windows: https://issuetracker.google.com/issues/68753324
/// - We may want to remove this if a future Android SDK tools, no longer has this issue
/// </summary>
void FixLintOnWindows ()
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
var userProfile = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile);
var androidSdkTools = Path.Combine (userProfile, "android-toolchain", "sdk", "tools");
if (Directory.Exists (androidSdkTools)) {
Environment.SetEnvironmentVariable ("JAVA_OPTS", $"\"-Dcom.android.tools.lint.bindir={androidSdkTools}\"", EnvironmentVariableTarget.Process);
}
}
}
[Test]
public void CheckLintErrorsAndWarnings ()
{
FixLintOnWindows ();
var proj = new XamarinAndroidApplicationProject ();
proj.UseLatestPlatformSdk = true;
proj.SetProperty ("AndroidLintEnabled", true.ToString ());
@ -917,6 +934,8 @@ namespace App1
[Test]
public void CheckLintConfigMerging ()
{
FixLintOnWindows ();
var proj = new XamarinAndroidApplicationProject ();
proj.SetProperty ("AndroidLintEnabled", true.ToString ());
proj.OtherBuildItems.Add (new AndroidItem.AndroidLintConfig ("lint1.xml") {