How to set main class in build?

The main Class must be fully qualified with the package:

Compile/mainClass := Some("myPackage.aMainClass")

This will work for run and it will set the Main-Class in the Manifest when using the package task. The main class for these tasks can be set separately as in:

mainClass in (Compile, run) := Some("myPackage.aMainClass")
mainClass in (Compile, packageBin) := Some("myPackage.anotherMainClass")

Note:

mainClass := Some("myPackage.aMainClass")

does nothing. If you put this in your build file you will receive no warning that it does nothing.

Leave a Comment