version: '{build}'

image: Visual Studio 2015
configuration: Release

platform:
  - x86
  - x64

environment:
  JDK8_X64: C:\Program Files\Java\jdk1.8.0
  JDK8_X86: C:\Program Files (x86)\Java\jdk1.8.0

  matrix:
    - JPY_PYTHON_HOME: C:\Python27
      JPY_JDK_HOME: '%JDK8_X86%'
    - JPY_PYTHON_HOME: C:\Python34
      JPY_JDK_HOME: '%JDK8_X86%'
    - JPY_PYTHON_HOME: C:\Python35
      JPY_JDK_HOME: '%JDK8_X86%'
    - JPY_PYTHON_HOME: C:\Python36
      JPY_JDK_HOME: '%JDK8_X86%'
    - JPY_PYTHON_HOME: C:\Python27-x64
      JPY_JDK_HOME: '%JDK8_X64%'
    - JPY_PYTHON_HOME: C:\Python34-x64
      JPY_JDK_HOME: '%JDK8_X64%'
    - JPY_PYTHON_HOME: C:\Python35-x64
      JPY_JDK_HOME: '%JDK8_X64%'
    - JPY_PYTHON_HOME: C:\Python36-x64
      JPY_JDK_HOME: '%JDK8_X64%'

matrix:
  exclude:
    - platform: x86
      JPY_JDK_HOME: '%JDK8_X64%'
    - platform: x64
      JPY_JDK_HOME: '%JDK8_X86%'

# see https://www.appveyor.com/docs/build-cache/
cache:
  - '%MAVEN_HOME% -> pom.xml'
  - '%UserProfile%\.m2 -> pom.xml'

install:
  # For Python 2.7 builds, we still get following error
  #    org.jpy.PyLib: System.load("C:\projects\jpy\build\lib.win32-2.7\jpy.pyd")
  #    java.lang.UnsatisfiedLinkError: C:\projects\jpy\build\lib.win32-2.7\jpy.pyd: Can't find dependent libraries
  # The following did NOT help at all:
  #- copy C:\Windows\SysWOW64\python27.dll C:\Python27
  #- copy C:\Windows\System32\python27.dll C:\Python27-x64
  #- copy C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387_none_5094ca96bcb6b2bb\msvcr90.dll C:\Python27
  #- copy C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.8387_none_08e793bfa83a89b5\msvcr90.dll C:\Python27-x64
  #- ps: Get-ChildItem -Path $env:JPY_PYTHON_HOME
  #- ps: Get-ChildItem -Path $env:JPY_PYTHON_HOME -Filter *.dll -Recurse
  - call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /%PLATFORM%
  - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
  - set JDK_HOME=%JPY_JDK_HOME%
  # JAVA_HOME is used by Maven
  - set JAVA_HOME=%JPY_JDK_HOME%
  - set
  - call "%JPY_JDK_HOME%\bin\java.exe" -XshowSettings:properties -version
  - call "%JPY_PYTHON_HOME%\Scripts\pip.exe" install wheel
  - call "%JPY_PYTHON_HOME%\Scripts\pip.exe" install psutil
  - call "%JPY_PYTHON_HOME%\python.exe" ci\appveyor\dump-dlls.py

build_script:
  - set PATH=%JPY_PYTHON_HOME%;%JPY_PYTHON_HOME%\DLLs;%JPY_JDK_HOME%;%JPY_JDK_HOME%\bin;%PATH%
  - call "%JPY_PYTHON_HOME%\python.exe" setup.py --maven bdist_wheel
