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?
To prevent this:
sbt> ~run
Multiple main classes detected, select one to run:
[1] com.yourapp.MainClass1
[2] com.yourapp.MainClass2
[3] com.yourapp.MainClass3
do this:
sbt> ~runMain com.yourapp.MainClass1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With