Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify command line arguments within build.sbt

Tags:

scala

sbt

There are a number of Q&A about how to send command line args to sbt run . My question is: how to specify the command line args in a hard-coded manner within build.sbt - where we know how to specify the class itself:

mainClass in Global := Some("mypackage.MyMainClas")

We need to specify the command line parameters in a hardcoded manner in build.sbt due to our toolchain.

like image 877
WestCoastProjects Avatar asked Oct 26 '25 17:10

WestCoastProjects


1 Answers

You can try create custom run task with the default arguments, like:

lazy val myParameters = Array("arg1", "arg3")
lazy val myRunTask = taskKey[Unit]("A custom run task.")
fullRunTask(myRunTask, Runtime, "mypackage.MyMainClas", myParameters: _*)

and run with: sbt myRunTask.

Reference:

http://www.scala-sbt.org/0.13/docs/Faq.html#How+can+I+create+a+custom+run+task%2C+in+addition+to+%3F

like image 63
chengpohi Avatar answered Oct 28 '25 15:10

chengpohi