-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Add template for setting JAVA_HOME vars (#9671)
Adds a `setup-jdk-variables.yaml` template to set the `JAVA_HOME` and `JI_JAVA_HOME` variables from a single script location. A new `JI_JAVA_HOME_DEFAULT` variable will also be set to point to a current JDK that can be used to run various Android SDK tools as needed. Consolidating this logic should make it easier to update the default JDK version we install and/or test against in the future. Build jobs and some test jobs that run on custom agents will use the default android-toolchain path that xaprepare installs into. Most other test jobs will attempt to use the value of a preinstalled JDK found at `$JAVA_HOME_$(JAVA_VERSION)_$(OS_ARCH)` if it is defined.
- Loading branch information
Showing
11 changed files
with
61 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
build-tools/automation/yaml-templates/setup-jdk-variables.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
parameters: | ||
jdkMajorVersion: $(DefaultJavaSdkMajorVersion) | ||
useAgentJdkPath: true | ||
|
||
steps: | ||
- pwsh: | | ||
$agentOS="$(Agent.OS)" | ||
$agentArch="$(Agent.OSArchitecture)" | ||
$jdkMajorVersion="${{ parameters.jdkMajorVersion }}" | ||
$xaPrepareJdkPath="$env:HOME/android-toolchain/jdk-$jdkMajorVersion" | ||
if ("$agentOS" -eq "Windows_NT") { | ||
$xaPrepareJdkPath="$env:USERPROFILE\android-toolchain\jdk-$jdkMajorVersion" | ||
} | ||
$jdkHomePath=$xaPrepareJdkPath | ||
if ("${{ parameters.useAgentJdkPath }}" -eq "true") { | ||
$defaultJdkHomeVarName="JAVA_HOME_$(DefaultJavaSdkMajorVersion)_${agentArch}" | ||
$defaultJdkHomePath=(Get-Item -Path "env:$defaultJdkHomeVarName").Value | ||
$jdkHomeVarName="JAVA_HOME_${jdkMajorVersion}_${agentArch}" | ||
$jdkHomePath=(Get-Item -Path "env:$jdkHomeVarName").Value | ||
} | ||
Write-Host "Setting variable 'JI_JAVA_HOME_DEFAULT' to '$defaultJdkHomePath'" | ||
Write-Host "##vso[task.setvariable variable=JI_JAVA_HOME_DEFAULT]$defaultJdkHomePath" | ||
Write-Host "Setting variable 'JAVA_HOME' and 'JI_JAVA_HOME' to '$jdkHomePath'" | ||
Write-Host "##vso[task.setvariable variable=JAVA_HOME]$jdkHomePath" | ||
Write-Host "##vso[task.setvariable variable=JI_JAVA_HOME]$jdkHomePath" | ||
displayName: set JAVA_HOME and JI_JAVA_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters