-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up JI_JAVA_TOOL env var setting.
- Loading branch information
Showing
2 changed files
with
31 additions
and
14 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
build-tools/automation/yaml-templates/setup-java-environment.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 @@ | ||
# Sets JI_JAVA_HOME to the requested Java SDK version | ||
|
||
parameters: | ||
jdkDirectory: # Explicit SDK path to use, will take precedence if specified | ||
jdkVersion: 17 # SDK version to use, valid values are 11/17/21 | ||
|
||
steps: | ||
# Use the explicit provided jdkDirectory | ||
- pwsh: | | ||
Write-Host "##vso[task.setvariable variable=JI_JAVA_HOME]${{ parameters.jdkDirectory }}" | ||
displayName: Set JI_JAVA_HOME to ${{ parameters.jdkDirectory }} | ||
condition: and(succeeded(), ne('${{ parameters.jdkDirectory }}', '')) | ||
|
||
# If an explicit Java SDK path wasn't provided, use jdkVersion | ||
- pwsh: | | ||
$arch = "variables['agent.osarchitecture']" -eq "ARM64" ? "arm64" : "X64" | ||
$env_var = "JAVA_HOME_${{ parameters.jdkVersion }}_" + $arch | ||
$env_value = [Environment]::GetEnvironmentVariable($env_var) | ||
Write-Host "Setting JI_JAVA_HOME to environment variable: '$env_var' ($env_value)" | ||
Write-Host "##vso[task.setvariable variable=JI_JAVA_HOME]$env_value" | ||
displayName: set JI_JAVA_HOME to version ${{ parameters.jdkVersion }} | ||
condition: and(succeeded(), eq('${{ parameters.jdkDirectory }}', '')) | ||
|
||
- script: | | ||
echo $(JI_JAVA_HOME) | ||
displayName: print 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