SBT: Start a command line 'run' of the main class of a non-default project

前端 未结 4 1030
别那么骄傲
别那么骄傲 2021-01-30 08:33

I am starting to use sbt build my Scala code (and handle dependencies). As far as I know if I use

$ sbt run 

on the command line th

相关标签:
4条回答
  • 2021-01-30 08:45

    This works: sbt "runMain com.example.Hello arg1" or sbt "run-main com.example.Hello arg1".

    See here for reference: https://blog.ssanj.net/posts/2016-03-02-how-to-run-a-specific-main-class-with-parameters-through-sbt.html

    0 讨论(0)
  • 2021-01-30 08:46

    $ sbt foo/run arg1 arg2 also work

    0 讨论(0)
  • 2021-01-30 09:01

    You simply have to quote each command (as in the second example on this page), so in your case it would be:

    $ sbt "project foo" "run arg1 arg2"
    
    0 讨论(0)
  • 2021-01-30 09:01

    Worked for me:

    $ sbt "run someNumber"
    

    Also this may be of some help:

    def main(args: Array[String]) {
        val n = args(0).toInt
    }
    
    0 讨论(0)
提交回复
热议问题