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
 - ps: |
 Add-Type -AssemblyName System.IO.Compression.FileSystem
 if (!(Test-Path -Path "C:\sbt" )) {
 (new-object System.Net.WebClient).DownloadFile(
 [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\", "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
 - sbt clean compile
 - sbt test
 - sbt "scripted windows/*"
 - 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.