Skip to content

Commit

Permalink
Fix Java_Adopt_Jdk permissions (actions#3605)
Browse files Browse the repository at this point in the history
  • Loading branch information
al-cheb authored Jun 18, 2021
1 parent 82fa8f2 commit 0b6b04b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions images/win/scripts/Installers/Install-JavaTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,13 @@ function Install-JavaFromAdoptOpenJDK {
-and $_.binary.architecture -eq $Architecture `
-and $_.binary.image_type -eq "jdk"
}
$downloadUrl = $asset.binary.package.link
# We have to replace '+' sign in the version to '-' due to the issue with incorrect path in Android builds https://github.com/actions/virtual-environments/issues/3014
$fullJavaVersion = $asset.version.semver -replace '\+', '-'

# Download and extract java binaries to temporary folder
$downloadUrl = $asset.binary.package.link
$archivePath = Start-DownloadWithRetry -Url $downloadUrl -Name $([IO.Path]::GetFileName($downloadUrl))
$javaTempPath = Join-Path -Path $env:TEMP -ChildPath "Java_$fullJavaVersion"
Extract-7Zip -Path $archivePath -DestinationPath $javaTempPath
$javaTempBinariesPath = Join-Path -Path $javaTempPath -ChildPath "\jdk*\"

# We have to replace '+' sign in the version to '-' due to the issue with incorrect path in Android builds https://github.com/actions/virtual-environments/issues/3014
$fullJavaVersion = $asset.version.semver -replace '\+', '-'
# Create directories in toolcache path
$javaToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Java_Adopt_jdk"
$javaVersionPath = Join-Path -Path $javaToolcachePath -ChildPath $fullJavaVersion
Expand All @@ -84,8 +81,9 @@ function Install-JavaFromAdoptOpenJDK {
Write-Host "Creating Java '${fullJavaVersion}' folder in '${javaVersionPath}'"
New-Item -ItemType Directory -Path $javaVersionPath -Force | Out-Null

# Complete the installation by moving Java binaries from temporary directory to toolcache and creating the complete file
Move-Item -Path $javaTempBinariesPath -Destination $javaArchPath
# Complete the installation by extarcting Java binaries to toolcache and creating the complete file
Extract-7Zip -Path $archivePath -DestinationPath $javaVersionPath
Get-ChildItem -Path $javaVersionPath | Rename-Item -NewName $javaArchPath
New-Item -ItemType File -Path $javaVersionPath -Name "$Architecture.complete" | Out-Null
}

Expand Down

0 comments on commit 0b6b04b

Please sign in to comment.