I have ~6 main classes in my application, by I usually use only one of them, so I wanted to run it automatically by sbt. sbt makes it possible to define two keys in build.sbt:
// Run Key
val selectMainClass = TaskKey[Option[String]]("select-main-class", "Selects the main class to run.")
val mainClass = TaskKey[Option[String]]("main-class", "Defines the main class for packaging or running.")
so I defined them (sample project, two classes – Main1 & Main2 in the root of source dir):
mainClass := Some("Main1")
selectMainClass := Some("Main1")
And `show main-class’ from sbt prompt also seems to work:
[info] Some(Main1)
But sbt’s run task still prompts me for main class.
Also, sbt-revolver fails to work with multiple classes with exception java.util.NoSuchElementException: None.get
Using sbt 0.11.2.
What am I doing wrong here?
As you can see from using inspect, mainClass is scoped to various configurations and tasks:
Therefore you have to use proper scoping: