Building a Scala project

What This Guide Covers

This guide covers build environment and configuration topics specific to Scala projects. Please make sure to read our Getting Started and general build configuration guides first.

Scala builds are not available on the OS X environment.


Travis CI environment provides a large set of build tools for JVM languages with multiple JDKs, Ant, Gradle, Maven and sbt.

Projects using sbt

If your project has project directory or build.sbt file in the repository root, the Travis CI Scala builder will use sbt to build it.

Thanks to paulp/sbt-extras the sbt version of your project is dynamically detected and used.

Choosing Scala versions to test against

Thanks to sbt ability to perform actions against multiple Scala versions, it is possible to test your projects against different Scala versions. To specify Scala versions you want your project to be tested against, use the scala key, for example:

language: scala
   - 2.9.3
   - 2.10.4
   - 2.11.2

Default Test Command

By default, Travis CI will use


to run your test suite. This can be overridden as described in the general build configuration guide.

Dependency Management

Because Travis CI Scala builder assumes sbt dependency management is used by default, it automatically will pull down project dependencies before running tests without any effort on your side.

Custom sbt Arguments

Most of the time, Travis CI default SBT and JVM options should work fine.

If needed, you can override SBT and JVM options in many different ways by passing extra arguments to sbt. For example

  - sbt -jvm-opts travis/jvmopts.compile ... compile
  - sbt -jvm-opts travis/jvmopts.test ... test

will then run compile and test with different JVM parameters.

With sbt_args key in your .travis.yml, you also can specify extra arguments to be passed to the default build script. For example

sbt_args: -no-colors -J-Xss2m

will generate

script: sbt -no-colors -J-Xss2m ++$TRAVIS_SCALA_VERSION test

Projects Using Gradle, Maven or Ant

If your project is not configured for sbt, the build process behaves like a typical Java Project.

Testing Against Multiple JDKs

As for any JVM language, it is also possible to test against multiple JDKs.

Build Matrix

For Scala projects, env, scala, and jdk can be given as arrays to construct a build matrix.

Environment Variable

The version of Scala a job is using is available as: