You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Install java via native tools in CI
The VMR doesn't have Java installed globally on the machines, but it does have it in the native tool cache. This PR updates the build scripts to use the native tool cache to install Java in CI builds. I've also updated to 11.0.22 (vs. the .3 version from 2019) and the script used to pull this from native tool assets.
Write-Host-f Magenta "Detected JDK in $localJdkPath (via local repo convention)"
321
-
$env:JAVA_HOME=$localJdkPath
322
-
}
323
-
elseif ($env:JAVA_HOME) {
324
-
if (-not (Test-Path"${env:JAVA_HOME}\bin\javac.exe")) {
325
-
Write-Error"The environment variable JAVA_HOME was set, but ${env:JAVA_HOME}\bin\javac.exe does not exist. Remove JAVA_HOME or update it to the correct location for the JDK. See https://www.bing.com/search?q=java_home for details."
326
-
}
327
-
else {
328
-
Write-Host-f Magenta "Detected JDK in ${env:JAVA_HOME} (via JAVA_HOME)"
if (-not$foundJdk-and$RunBuild-and ($All-or$BuildJava) -and-not$NoBuildJava) {
365
-
Write-Error"Could not find the JDK. Either run $PSScriptRoot\scripts\InstallJdk.ps1 to install for this repo, or install the JDK globally on your machine (see $PSScriptRoot\..\docs\BuildFromSource.md for details)."
366
-
}
367
319
368
320
# Initialize global variables need to be set before the import of Arcade is imported
Write-Host-f Magenta "Detected JDK in $localJdkPath (via local repo convention)"
354
+
$env:JAVA_HOME=$localJdkPath
355
+
}
356
+
elseif ($env:JAVA_HOME) {
357
+
if (-not (Test-Path"${env:JAVA_HOME}\bin\javac.exe")) {
358
+
Write-Error"The environment variable JAVA_HOME was set, but ${env:JAVA_HOME}\bin\javac.exe does not exist. Remove JAVA_HOME or update it to the correct location for the JDK. See https://www.bing.com/search?q=java_home for details."
359
+
}
360
+
else {
361
+
Write-Host-f Magenta "Detected JDK in ${env:JAVA_HOME} (via JAVA_HOME)"
if (-not$foundJdk-and$RunBuild-and ($All-or$BuildJava) -and-not$NoBuildJava) {
398
+
Write-Error"Could not find the JDK. Either run $PSScriptRoot\scripts\InstallJdk.ps1 to install for this repo, or install the JDK globally on your machine (see $PSScriptRoot\..\docs\BuildFromSource.md for details)."
399
+
}
400
+
}
401
+
395
402
# Add default .binlog location if not already on the command line. tools.ps1 does not handle this; it just checks
396
403
# $BinaryLog, $CI and $ExcludeCIBinarylog values for an error case. But tools.ps1 provides a nice function to help.
397
404
if ($BinaryLog) {
@@ -424,6 +431,17 @@ try {
424
431
$tmpRestore=$restore
425
432
$restore=$true
426
433
434
+
# Initialize the native tools before locating java.
435
+
if ($NativeToolsOnMachine) {
436
+
$env:NativeToolsOnMachine=$true
437
+
# Do not promote native tools except in cases where -NativeToolsOnMachine is passed.
438
+
# Currently the JDK is laid out in an incorrect pattern: https://github.com/dotnet/dnceng/issues/2185
439
+
InitializeNativeTools
440
+
}
441
+
442
+
# Locate java, now that we may have java available after initializing native tools.
0 commit comments