Scala “Mill” build tool: How to specify the main method/class you want to run when you have multiple main methods

As another brief example of the Mill build tool, when you have multiple main methods in a Mill project you’ll need to specify which main method you want to run in your Mill configuration file. This is the syntax for doing that:

def mainClass = Some("hello.Hello")

This says that you want to run the main method that’s in the Hello class that’s in the hello package.

A complete Mill file example

Here’s a complete Mill example for a small Scala project I’ve been working on that demonstrates this:

object RssAtomReader extends ScalaModule {

    def scalaVersion = "2.12.11"

    object test extends Tests {
        def ivyDeps = Agg(
        def testFrameworks = Seq("")

    // `::` for scala deps, `:` for java deps
    def ivyDeps = Agg(

    // 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")


The last line of that file shows how I define which Scala (or Java) class has the main method that I want to run.

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