parameters:
  - name: GraalVMJdkVersion
    type: string
    default: $(GraalVMJdkVersion)

steps:
  # Non-standard JDK versions are only supported in Linux.
  # Make the assumption here Linux is being used, if it's not it's a configuration issue that needs to be fixed there.
  - task: Cache@2
    inputs:
      key: 'jdk | "${{ parameters.GraalVMJdkVersion }}" | "$(CacheSalt)" | "$(Agent.OS)"'
      path: $(Agent.BuildDirectory)/graalvm-${{ parameters.GraalVMJdkVersion }}
    displayName: 'Cache GraalVM JDK'

  - task: PowerShell@2
    displayName: 'Install GraalVM JDK'
    inputs:
      pwsh: true
      arguments: >
        -GraalVMVersion ${{ parameters.GraalVMJdkVersion }}
      workingDirectory: $(Agent.BuildDirectory)
      filePath: eng/scripts/Install-GraalVM-JDK.ps1

  - pwsh: |
      Write-Host "GraalVM JDK: $Env:JAVA_HOME"
    displayName: 'Verify GraalVM JDK Install'
