Skip to content

Instantly share code, notes, and snippets.

@raul782
Created December 13, 2015 23:11
Show Gist options
  • Save raul782/4a41be75ce7bd4641afb to your computer and use it in GitHub Desktop.
Save raul782/4a41be75ce7bd4641afb to your computer and use it in GitHub Desktop.
Testing Scala programs with Travis CI on OS X
language: java
env:
- SCALA_VERSION=2.11.7
os:
- osx
script:
- ./sbt "++$SCALA_VERSION" test
matrix:
include:
- env: SCALA_VERSION=2.11.7
os: linux
jdk: oraclejdk7
- env: SCALA_VERSION=2.10.5
os: linux
jdk: oraclejdk8

Testing Scala programs with Travis CI on OS X

Since a while ago, the fine folks at Travis CI offer OS X builds. Those machines also have Java installed, but just one version (1.7.0_45 at time of writing). The usual jdk_switcher mechanism is unavailable. Futhermore, Scala is not available. Luckily, it is possible to define a cross-platform (Linux and OS X) build within these constraints.

  1. Include @paulp's sbt launcher into the root of your repository. You can obtain a copy here. Alternatively, you can add an install step to your .travis.yml which fetches it before the build. (See the instructions in the README of sbt-extras.)
  2. Set the language entry in your .travis.yml to java.
  3. Remove the jdk and the scala entries.
  4. Instead, add a new top-level entry env which contains an item SCALA_VERSION=2.11.7 for each Scala version you want to test on.
  5. Add a new top-level entry os with the single item osx. It is important that it only contains osx and not linux.
  6. Add a new top-level entry matrix with sub-entry include. See the example file in this Gist for an idea what it should look like.

Real-world examples

Official documentation

For details on what exactly is available on the OS X boxes, see the official documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment