This guide covers configuring Scala projects on semaphore. If you’re new to semaphore we recommend reading the guided tour first.

Hello world#

The following Semaphore configuration file compiles and executes a Scala program:

# .semaphore/semaphore.yml

version: v1.0
name: Using Scala in Semaphore
    type: e1-standard-2
    os_image: ubuntu1804
  - name: Choose version
      - name: Choose Scala version
          - checkout
          - sem-version scala 2.12
          - scala hello.scala

The contents of the Scala program are as follows:

// hello.scala

object HW {
    def main(args: Array[String]) {
      println("Hello World!")

Scala Play example project#

Semaphore provides a tutorial and demo Play application with a working CI pipeline that you can use to get started quickly:

Supported Scala versions#

The supported Scala versions via the Ubuntu1804 image are:

  • 2.11.11
  • 2.12.6

Changing Scala version#

You can choose the Scala version to use with the help of the sem-version utility

Choosing Scala version 2.11 can be done with the following command:

sem-version scala 2.11

In order to go back to Scala 2.12, which is the default version of the Semaphore Virtual Machine, you should execute the following command:

sem-version scala 2.12

Dependency management#

You can use Semaphore's cache tool to store and load any files or Scala libraries that you want to reuse between jobs.

System dependencies#

Scala projects might need packages like database drivers. As you have full sudo access on each Semaphore 2.0 VM, you are free to install all required packages.

See Also#