Commit 3470539
[build] Generate $(JdkBinPath)` property
We're trying to build xamarin-android on a VSTS macOS instance which
has multiple Java JDKs installed, including JDK 9.
The problem is that the Android SDK and JDK 9 don't get along. The
`xamarin-android/tests/CodeGen-Binding/Xamarin.Android.LibraryProjectZip-LibBinding`
build invokes `gradlew`, `gradlew` uses whatever `java` is in `$PATH`,
and when using JDK 9 `gradlew` fails:
Executing: ./gradlew assembleDebug --stacktrace
...
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':library'.
...
Caused by: org.gradle.internal.event.ListenerNotificationException:
Failed to notify project evaluation listener.
...
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
...
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
(Rephrased: JDK 9 removed the type
`javax.xml.bind.annotation.XmlSchema`, which broke some dependency.)
55c56f7 was an attempt to support this environment, by *allowing*
JDK 9 to be filtered out when computing `$(JdkJvmPath)`,
`$(JavaCPath)`, and `$(JarPath)`.
Unfortunately this was inadequate: we need to override `$PATH` so that
the "right" JDK is used, not whatever happens to be first in `$PATH`.
In manual testing, this fails:
ANDROID_HOME=... ./gradlew assembleDebug --stacktrace
while this works:
ANDROID_HOME=... PATH=/path/to/jdk8/bin:$PATH ./gradlew assembleDebug --stacktrace --no-daemon
(The `--no-daemon` is needed so that we don't use some previously
launched gradle daemon under the wrong JDK.)
Thus, we want a way to easily insert the appropriate JDK path into
`$PATH` for the `gradlew` command.
Export a new `$(JdkBinPath)` MSBuild property which contains the JDK
`bin` directory. This will allow us to fix the
`Xamarin.Android.LibraryProjectZip-LibBinding` project:
<Exec
EnvironmentVariables="ANDROID_HOME=$(AndroidSdkDirectory)"
Command="PATH=$(JdkBinPath):%24PATH .\gradlew assembleDebug --stacktrace --no-daemon"
WorkingDirectory="$(MSBuildThisFileDirectory)java\JavaLib"
/>
and (hopefully) allow us to build on our VSTS bot which contains both
JDK 8 and 9.1 parent 449e5de commit 3470539
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| 82 | + | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | 88 | | |
84 | 89 | | |
85 | | - | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| 151 | + | |
146 | 152 | | |
147 | 153 | | |
148 | 154 | | |
| |||
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
0 commit comments