Commit 9b03310
authored
[Windows] check %JAVA_HOME% for locating Jdk (#74)
* [Windows] check %JAVA_HOME% for locating Jdk
Fixes: http://feedback.devdiv.io/606218
Something has happened with Xamarin.Android builds running on Azure
DevOps recently, builds are now failing with:
ResolveSdks
...
Errors
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(721,2): error XA5300: The Java SDK Directory could not be found. Please set via /p:JavaSdkDirectory. [d:\a\1\s\Xamarin.Android.Lite\Xamarin.Android.Lite.csproj]
Azure DevOps has posted a "workaround" document:
https://github.com/microsoft/azure-pipelines-image-generation/blob/1371aa8548aa135c3be783bd854681118ca10f78/images/win/Vs2019-Server2019-Readme.md#known-issues
It suggests adding this property to MSBuild calls:
/p:JavaSdkDirectory="$(JAVA_HOME_8_X64)"
Reviewing a user's build log from ReactiveUI:
https://dev.azure.com/dotnet/ReactiveUI/_build/results?buildId=18505
/p:JavaSdkDirectory=C:/Program%20Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64
So I tried this with my own repo that has Azure DevOps configured,
sure enough a build from June 18, 2019 worked. A rebuild on July 1,
2019 failed with the reported error.
* Worked: https://jopepper.visualstudio.com/Jon%20Peppers%20OSS/_build/results?buildId=208
* Failed: https://jopepper.visualstudio.com/Jon%20Peppers%20OSS/_build/results?buildId=209
I can read from the build logs that both `JAVA_HOME` and
`JAVA_HOME_8_X64` are set to:
C:/Program Files/Java/zulu-8-azure-jdk_8.38.0.13-8.0.212-win_x64
I think this means two things:
* Microsoft Open JDK is no longer installed on the `Hosted Windows
2019 with VS2019` pool.
* Instead, *yet another JDK* called the Azul Zulu JDK is present...
https://docs.microsoft.com/en-us/java/azure/jdk/java-jdk-install?view=azure-java-stable
I think we should add a "last resort" lookup for a valid JDK within
`JAVA_HOME` on Windows. It does not currently do that.
Reviewing the code, I am somewhat confused by `JdkInfo`. Its logic is
not run on Windows, and instead we have Windows-specific JDK lookups
in `AndroidSdkWindows`. To make things work properly we can just add a
last chance lookup for `JAVA_HOME` in `AndroidSdkWindows`.
I added a new test for verifying things locally, however...
I can't actually run this test on CI, since our current CI machines have the Microsoft Open JDK installed.1 parent cb41333 commit 9b03310
File tree
2 files changed
+42
-1
lines changed- src/Xamarin.Android.Tools.AndroidSdk
- Sdks
- Tests
2 files changed
+42
-1
lines changedLines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
139 | 151 | | |
140 | 152 | | |
141 | 153 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
138 | 167 | | |
139 | 168 | | |
140 | 169 | | |
| |||
0 commit comments