Building a Scala project

What This Guide Covers #

For Language versions and other build-environment specific information visit our reference pages:

Scala builds are not available on the macOS environment.

The rest of this guide covers configuring Scala projects in Travis CI. If you’re new to Travis CI please read our Tutorial and build configuration guides first.

Overview #

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

Specifying Scala versions #

To specify Scala versions in your build:

language: scala
  - 2.9.3
  - 2.10.6
  - 2.11.11
  - 2.12.2

On Ubuntu Precise, to use Scala 2.12.X you need to enable Oracle JDK 8 by adding jdk: oraclejdk8 to your .travis.yml.

Projects using sbt #

If your project has a project directory or build.sbt file in the repository root, the Travis CI uses sbt to build it.

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

sbt Dependency Management #

Travis CI automatically pulls down sbt dependencies before running tests during the script phase of your build.

sbt Default Script Command #

The default script command is:


to run your test suite.

To use a different script command, customize the build step.

Custom sbt Arguments #

You can override sbt and JVM options by passing extra arguments to sbt.

For example, to run compile and test with different JVM parameters:

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

You can also specify extra arguments to be passed to the default build script with the sbt_args key in your .travis.yml.

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.

Using Java 10 and Up #

For testing with OpenJDK and OracleJDK 10 and up, see Java documentation.

Environment Variable #

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


Build Config Reference #

You can find more information on the build config format for Scala in our Travis CI Build Config Reference.

Examples #