in Tutorials

Windows Tests on AppVeyor with SBT

For SBT Native Packager we rely on travis-ci to run our tests. However travis has not yet
windows support, so we have to run these tests manually, which is not nice. Lucky there’s
another free-for-opensource continous integration server for windows name appveyor.

How to get sbt started?

The tricky part is to install sbt and let it run your tests. There is an awesome blogpost on
how to do it with maven. I took the script and changed it to work with sbt instead.

version: '{build}'
os: Windows Server 2012
install:
 - ps: |
 Add-Type -AssemblyName System.IO.Compression.FileSystem
 if (!(Test-Path -Path "C:\sbt" )) {
 (new-object System.Net.WebClient).DownloadFile(
 'https://dl.bintray.com/sbt/native-packages/sbt/0.13.7/sbt-0.13.7.zip',
 'C:\sbt-bin.zip'
 )
 [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\sbt-bin.zip", "C:\sbt")
 }
 - cmd: SET PATH=C:\sbt\sbt\bin;%JAVA_HOME%\bin;%PATH%
 - cmd: SET SBT_OPTS=-XX:MaxPermSize=2g -Xmx4g
 - cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g
build_script:
 - sbt clean compile
test_script:
 - sbt test
 - sbt "scripted windows/*"
cache:
 - C:\sbt\
 - C:\Users\appveyor\.m2
 - C:\Users\appveyor\.ivy2

This will download sbt, installs it and sets the environment variables correctly.

Why not use chocolatey?

Chocolatey is like apt-get or homebrew a packaging system to easily install packages via the cli.
There is a sbt package available in version 0.13, which is okay, as sbt is self-provisioning. However it seems the environment variables are not set correctly. Hopefully this is due to an outdate installer, which could easily be fixed.