Build a Scala project
For Language versions and other build-environment specific information visit our reference pages:
Scala builds are not available on the macOS environment.
This guide covers configuring Scala projects in Travis CI. If you’re new to Travis CI, please read our Onboarding and General 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.
Specify Scala versions #
To specify Scala versions in your build:
language: scala
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
.
sbt Projects #
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:
sbt ++$TRAVIS_SCALA_VERSION test
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:
script:
- 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
Gradle, Maven, or Ant Projects #
If your project is not configured for sbt, the build process behaves like a typical Java Project.
Test against Multiple JDKs #
As for any JVM language, it is also possible to test against multiple JDKs.
Use Java 10 and higher #
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:
TRAVIS_SCALA_VERSION
Build Config Reference #
You can find more information on the build config format for Scala in our Travis CI Build Config Reference.
Examples #
- twitter/scalding
- twitter/summingbird
- novus/salat
- scalaz/scalaz
- spray/spray (using a custom
.jvmopts
to override Travis CI defaults)