"run" not finding main method in 0.9.9

192 views
Skip to first unread message

Graham Tackley

unread,
May 29, 2011, 9:40:05 AM5/29/11
to simple-b...@googlegroups.com
Hey,

I created a simple project with a main method:

object MyApp {
  def main(args: Array[String]) {
    println("hello!!")
  }
}

0.9.9 fails to find it:

$ ./sbt099 run
[info] Set current project to default (in build file:/home/graham/working/simple/)
[info] Updating...
[info] Done updating.
Compiling:
    /home/graham/working/simple/src/main/scala/Hello.scala
Traversing /home/graham/working/simple/src/main/scala/Hello.scala
API phase took : 0.078 s
[error] Incomplete tasks (run 'last <task>' for the full log):
[error]   {file:/home/graham/working/simple/}default/test:run: java.lang.RuntimeException: No main class detected.
[error] Total time: 5 s, completed 29-May-2011 14:37:57

The same project works fine in 0.9.8:

$ ./sbt098 run
[info] Set current project to default (in build file:/home/graham/working/simple/)
[info] Updating...
[info] Done updating.
Compiling:
    /home/graham/working/simple/src/main/scala/Hello.scala
Traversing /home/graham/working/simple/src/main/scala/Hello.scala
API phase took : 0.061 s
[info] Running MyApp
hello!!
[success] Total time: 4 s, completed 29-May-2011 14:37:34

Fwiw, I've pushed the example project to github: https://github.com/tackley/simple-main

Cheers
g



Mark Harrah

unread,
May 29, 2011, 7:19:53 PM5/29/11
to simple-b...@googlegroups.com

Thanks, I pushed a fix to github.

The problem was a bug in sbt revealed by a change in iteration order over Maps in Scala 2.9.0. (This is of course an implementation detail of most Maps.) This caused 'run' to refer to 'test:run' in some cases. You can work around it by explicitly specifying 'compile:run'.

-Mark

Reply all
Reply to author
Forward
0 new messages