image:
  - Previous Visual Studio 2015

environment:
  ANDROID_HOME: "C:\\android"
  matrix:
  - nodejs_version: "4"
  - nodejs_version: "6"

init:
  - mkdir "%ANDROID_HOME%
  - cd "%ANDROID_HOME%"
  - appveyor DownloadFile "https://dl.google.com/android/repository/tools_r25.2.3-windows.zip"
  - 7z x "tools_r25.2.3-windows.zip" > nul
  - cd "C:\projects\cordova-android"

install:
  - choco install gradle -version 3.4.1
  - gradle -version
  - echo y | "%ANDROID_HOME%\tools\android.bat" --silent update sdk --no-ui --all --filter platform-tools,tools,build-tools-26.0.0,android-26,android-25,extra-google-m2repository,extra-android-m2repository
  # on windows we need to accept sublicenses for the new tooling, wee. 30 is an arbitrary number,
  # but should be the maximum number of licenses we explicitly need to type "Y ENTER" for.
  # also, the sdkmanager in all its glory leaks a bit of output to stderr, and powershell
  # and appveyor interpret that as errors, and blows up. so, when piping in our "Y ENTER"
  # responses, we invoke cmd so we can redirect stderr to stdout, and tell it to --update itself.
  - ps: for($i=0;$i -lt 30;$i++) { $response += "y`n"}; $response | cmd /c 'C:\android\tools\bin\sdkmanager.bat 2>&1' --update
  - ps: Install-Product node $env:nodejs_version
  - npm install
  # below is a workaround on using gradle installed via choco on appveyor
  - set path=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-3.4.1\bin;%path%

build: off

test_script:
  - node --version
  - npm --version
  - npm test
