| 1 | Add-Type -AssemblyName System.IO.Compression.FileSystem |
| 2 | |
| 3 | $dep_dir="C:\Users\appveyor\deps" |
| 4 | If (!(Test-Path $dep_dir)) { |
| 5 | Write-Host "Creating $($dep_dir)" |
| 6 | New-Item -Path $dep_dir -ItemType Directory -Force |
| 7 | } |
| 8 | |
| 9 | $apr_platform = "Win32" |
| 10 | $openssl_platform = "Win32" |
| 11 | $vc_platform = "x86" |
| 12 | $env:PYTHON="C:\Python27" |
| 13 | $env:OPENSSL_PATH="C:\OpenSSL-Win32" |
| 14 | If ($env:PLATFORM -eq "X64") { |
| 15 | $apr_platform = "x64" |
| 16 | $vc_platform = "x64" |
| 17 | $env:PYTHON="C:\Python27-x64" |
| 18 | $env:OPENSSL_PATH="C:\OpenSSL-Win64" |
| 19 | } |
| 20 | |
| 21 | $env:JAVA_HOME="C:\Program Files\Java\jdk$($env:java_version)" |
| 22 | # The configured java version to test with. |
| 23 | $env:JAVA_PLATFORM_HOME="$($env:JAVA_HOME)" |
| 24 | $env:JAVA_8_HOME="C:\Program Files\Java\jdk1.8.0" |
| 25 | $env:PATH="$($env:PYTHON);$($env:PYTHON)\Scripts;$($env:JAVA_HOME)\bin;$($env:OPENSSL_PATH)\bin;$($env:PATH)" |
| 26 | $env:CCM_PATH="$($dep_dir)\ccm" |
| 27 | |
| 28 | $apr_dist_path = "$($dep_dir)\apr" |
| 29 | # Build APR if it hasn't been previously built. |
| 30 | If (!(Test-Path $apr_dist_path)) { |
| 31 | Write-Host "Cloning APR" |
| 32 | $apr_path = "C:\Users\appveyor\apr" |
| 33 | Start-Process git -ArgumentList "clone --branch=1.5.2 --depth=1 https://github.com/apache/apr.git $($apr_path)" -Wait -nnw |
| 34 | Write-Host "Setting Visual Studio Environment to VS 2015" |
| 35 | Push-Location "$($env:VS140COMNTOOLS)\..\..\VC" |
| 36 | cmd /c "vcvarsall.bat $vc_platform & set" | |
| 37 | foreach { |
| 38 | if ($_ -match "=") { |
| 39 | $v = $_.split("="); Set-Item -force -path "ENV:\$($v[0])" -value "$($v[1])" |
| 40 | } |
| 41 | } |
| 42 | Pop-Location |
| 43 | Write-Host "Building APR (an error may be printed, but it will still build)" |
| 44 | Push-Location $($apr_path) |
| 45 | cmd /c nmake -f Makefile.win ARCH="$apr_platform Release" PREFIX=$($apr_dist_path) buildall install |
| 46 | Pop-Location |
| 47 | Write-Host "Done Building APR" |
| 48 | } |
| 49 | $env:PATH="$($apr_dist_path)\bin;$($env:PATH)" |
| 50 | |
| 51 | # Install Ant and Maven |
| 52 | $ant_base = "$($dep_dir)\ant" |
| 53 | $ant_path = "$($ant_base)\apache-ant-1.9.7" |
| 54 | If (!(Test-Path $ant_path)) { |
| 55 | Write-Host "Installing Ant" |
| 56 | $ant_url = "https://www.dropbox.com/s/lgx95x1jr6s787l/apache-ant-1.9.7-bin.zip?dl=1" |
| 57 | $ant_zip = "C:\Users\appveyor\apache-ant-1.9.7-bin.zip" |
| 58 | (new-object System.Net.WebClient).DownloadFile($ant_url, $ant_zip) |
| 59 | [System.IO.Compression.ZipFile]::ExtractToDirectory($ant_zip, $ant_base) |
| 60 | } |
| 61 | $env:PATH="$($ant_path)\bin;$($env:PATH)" |
| 62 | |
| 63 | $maven_base = "$($dep_dir)\maven" |
| 64 | $maven_path = "$($maven_base)\apache-maven-3.2.5" |
| 65 | If (!(Test-Path $maven_path)) { |
| 66 | Write-Host "Installing Maven" |
| 67 | $maven_url = "https://www.dropbox.com/s/fh9kffmexprsmha/apache-maven-3.2.5-bin.zip?dl=1" |
| 68 | $maven_zip = "C:\Users\appveyor\apache-maven-3.2.5-bin.zip" |
| 69 | (new-object System.Net.WebClient).DownloadFile($maven_url, $maven_zip) |
| 70 | [System.IO.Compression.ZipFile]::ExtractToDirectory($maven_zip, $maven_base) |
| 71 | } |
| 72 | $env:M2_HOME="$($maven_path)" |
| 73 | $env:PATH="$($maven_path)\bin;$($env:PATH)" |
| 74 | |
| 75 | $jdks = @("1.6.0", "1.7.0", "1.8.0") |
| 76 | foreach ($jdk in $jdks) { |
| 77 | $java_dir = "C:\Program Files\Java\jdk$jdk" |
| 78 | $jce_target = "$java_dir\jre\lib\security" |
| 79 | $jce_indicator = "$jce_target\README.txt" |
| 80 | # Install Java Cryptographic Extensions, needed for SSL. |
| 81 | # If this file doesn't exist we know JCE hasn't been installed. |
| 82 | If (!(Test-Path $jce_indicator)) { |
| 83 | Write-Host "Installing JCE for $jdk" |
| 84 | $zip = "$dep_dir\jce_policy-$jdk.zip" |
| 85 | $url = "https://www.dropbox.com/s/po4308hlwulpvep/UnlimitedJCEPolicyJDK7.zip?dl=1" |
| 86 | $extract_folder = "UnlimitedJCEPolicy" |
| 87 | If ($jdk -eq "1.8.0") { |
| 88 | $url = "https://www.dropbox.com/s/al1e6e92cjdv7m7/jce_policy-8.zip?dl=1" |
| 89 | $extract_folder = "UnlimitedJCEPolicyJDK8" |
| 90 | } |
| 91 | ElseIf ($jdk -eq "1.6.0") { |
| 92 | $url = "https://www.dropbox.com/s/dhrtucxcif4n11k/jce_policy-6.zip?dl=1" |
| 93 | $extract_folder = "jce" |
| 94 | } |
| 95 | # Download zip to staging area if it doesn't exist, we do this because |
| 96 | # we extract it to the directory based on the platform and we want to cache |
| 97 | # this file so it can apply to all platforms. |
| 98 | if(!(Test-Path $zip)) { |
| 99 | (new-object System.Net.WebClient).DownloadFile($url, $zip) |
| 100 | } |
| 101 | |
| 102 | [System.IO.Compression.ZipFile]::ExtractToDirectory($zip, $jce_target) |
| 103 | |
| 104 | $jcePolicyDir = "$jce_target\$extract_folder" |
| 105 | Move-Item $jcePolicyDir\* $jce_target\ -force |
| 106 | Remove-Item $jcePolicyDir |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | # Install Python Dependencies for CCM. |
| 111 | Write-Host "Installing Python Dependencies for CCM" |
| 112 | Start-Process python -ArgumentList "-m pip install psutil pyYaml six" -Wait -nnw |
| 113 | |
| 114 | # Clone ccm from git and use master. |
| 115 | If (!(Test-Path $env:CCM_PATH)) { |
| 116 | Write-Host "Cloning CCM" |
| 117 | Start-Process git -ArgumentList "clone https://github.com/pcmanus/ccm.git $($env:CCM_PATH)" -Wait -nnw |
| 118 | } |
| 119 | |
| 120 | # Copy ccm -> ccm.py so windows knows to run it. |
| 121 | If (!(Test-Path $env:CCM_PATH\ccm.py)) { |
| 122 | Copy-Item "$env:CCM_PATH\ccm" "$env:CCM_PATH\ccm.py" |
| 123 | } |
| 124 | $env:PYTHONPATH="$($env:CCM_PATH);$($env:PYTHONPATH)" |
| 125 | $env:PATH="$($env:CCM_PATH);$($env:PATH)" |
| 126 | |
| 127 | # Predownload cassandra version for CCM if it isn't already downloaded. |
| 128 | If (!(Test-Path C:\Users\appveyor\.ccm\repository\$env:cassandra_version)) { |
| 129 | Write-Host "Preinstalling C* $($env:cassandra_version)" |
| 130 | Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py create -v $($env:cassandra_version) -n 1 predownload" -Wait -nnw |
| 131 | Start-Process python -ArgumentList "$($env:CCM_PATH)\ccm.py remove predownload" -Wait -nnw |
| 132 | } |