A Scala “Mill” build tool example build.sc file (multiple dependencies, ScalaTest, main class)

As another brief example of the Mill build tool, here’s a build.sc configuration file for a small Scala project I’ve been working on:

object RssAtomReader extends ScalaModule {

    def scalaVersion = "2.12.11"

    object test extends Tests {
        def ivyDeps = Agg(
            ivy"org.scalactic::scalactic:3.1.1",
            ivy"org.scalatest::scalatest:3.1.1"
        )
        def testFrameworks = Seq("org.scalatest.tools.Framework")
    }

    // `::` for scala deps, `:` for java deps
    def ivyDeps = Agg(
        ivy"org.scala-lang.modules::scala-xml:1.0.6",
        ivy"org.scalaj::scalaj-http:2.3.0",
        ivy"com.rometools:rome:1.8.1",
        ivy"org.jsoup:jsoup:1.11.2",
        ivy"com.typesafe:config:1.4.0",
        ivy"org.slf4j:slf4j-api:1.7.5",
        ivy"org.slf4j:slf4j-simple:1.7.5"
    )

    // pass a -D command-line arg to my application
    def forkArgs = Seq("-Dconfig.file=RssAtomReader/src/main/resources/application.conf")

    // with mill you need to specify the main class when you have more than one
    def mainClass = Some("hello.Hello")

}

A few important nuggets from that Mill build file:

  • It shows how to use ScalaTest with Mill
  • It shows how to add Scala and Java managed dependencies to a Mill build file
  • It shows how to pass a -D command-line argument to the java interpreter with Mill
  • It shows how to specify a main class in a Mill build file

This is just a short example, but for more information on Mill, see my Scala “Mill” build tool “Hello, world” example.