fork in run := true
javaOptions in run += "-Xmx6144m"
A basic run task is created by:
// this lazy val has to go in a full configuration
lazy val myRunTask = TaskKey[Unit]("my-run-task")
myRunTask <<= runTask(Test, "foo.Foo", "arg1", "arg2")
or, if you don't need to refer to myRunTask (this can be in a basic one):
TaskKey("my-run-task") <<= runTask(Test, "foo.Foo", "arg1", "arg2")
If you want to be able to supply arguments on the command line, replace TaskKey with InputKey and runTask with runInputTask.
The 'Test' part can be replaced with another configuration, such as Compile.
-Mark
fork in run := true
javaOptions in run += "-Xmx6144m"
A basic run task is created by:
// this lazy val has to go in a full configuration
lazy val myRunTask = TaskKey[Unit]("my-run-task")myRunTask <<= runTask(Test, "foo.Foo", "arg1", "arg2")
or, if you don't need to refer to myRunTask (this can be in a basic one):
TaskKey("my-run-task") <<= runTask(Test, "foo.Foo", "arg1", "arg2")
If you want to be able to supply arguments on the command line, replace TaskKey with InputKey and runTask with runInputTask.
The 'Test' part can be replaced with another configuration, such as Compile.
> Hi Mark,
>
> Thanks. Comments below.
>
> On Saturday, 21 May 2011 19:41:33 UTC+1, Mark Harrah wrote:
> >
> > fork in run := true
> >
> > javaOptions in run += "-Xmx6144m"
> >
> I came across this, but I thought this meant that all the tasks forked from
> that project would get those JVM settings. Is that not true? The code I was
> using in SBT 0.7.x allowed me to set a different -Xmx for each task. Some of
> my projects have a bunch of tools where each requires different settings and
> it's handy for one person to configure it once in the build file making it
> easy to launch by invoking a name later on.
Yes, that is correct. You can do it in 0.9.x as well, but it could be simpler. You can see the implementation of runTask and runInputTask here:
https://github.com/harrah/xsbt/blob/0.9/main/Defaults.scala#L875
What needs to be changed to be able to use the runTask/runInputTask methods is for the runner to be scoped per individual run-like task instead of the 'run' task itself. This is something I plan to change, but haven't decided how to do it yet.
-Mark
Yes, that is correct. You can do it in 0.9.x as well, but it could be simpler. You can see the implementation of runTask and runInputTask here:
https://github.com/harrah/xsbt/blob/0.9/main/Defaults.scala#L875
What needs to be changed to be able to use the runTask/runInputTask methods is for the runner to be scoped per individual run-like task instead of the 'run' task itself. This is something I plan to change, but haven't decided how to do it yet.
This is added in 0.9.8. There is a new method fullRunTask, which is like runTask but takes as the first argument the task key. It will configure the runner using the specific scope for that key. You can then apply settings to only that key:
val myRun = TaskKey[Unit]("my-run", "Custom run task.")
fullRunTask(myRun, Compile, "pkg.Main", "arg1", "arg2")
fork in myRun := true
javaOptions in myRun += ...
Something that might be helpful if you have groups of tasks is defining delegation for tasks.
val aRun = TaskKey[Unit]("a-run", "A run task.")
// Specifies that myRun delegates to aRun
// for any uninitialized settings
// (the last parameter is a repeated one)
val myRun = TaskKey[Unit]("my-run", "Custom run task.", aRun)
// Make the run task as before.
fullRunTask(myRun, Compile, "pkg.Main", "arg1", "arg2")
// If fork in myRun is not explicitly set,
// then this also configures myRun to fork.
// If fork in myRun is set, it overrides this setting
// because it is more specific.
fork in aRun := true
// Appends "-Xmx2G" to the current options for myRun.
// Because we haven't defined them explicitly,
// the current options are delegated to aRun.
// So, this says to use the same options as aRun
// plus -Xmx2G.
javaOptions in myRun += "-Xmx2G"
This is added in 0.9.8. There is a new method fullRunTask, which is like runTask but takes as the first argument the task key. It will configure the runner using the specific scope for that key. You can then apply settings to only that key:
Something that might be helpful if you have groups of tasks is defining delegation for tasks.
I had indeed figured this part out. Although when I tried using TaskKey inline in a Full Configuration, it complained about duplicate keys (I guess it was being invoked more than once). Memoising them in my build file fixed that though.