title: How can I override tasks ``run`` and ``runMain`` in SBT to use my own ``ForkOptions``?
body: <h2>Problem</h2>
  
  <p>In a multimodule build, each module has it's own <code>baseDirectory</code> but I would like to launch applications defined in modules employing the <code>baseDirectory</code> of the root project instead of the <code>baseDirectory</code> relative to modules involved.</p>
  
  <p>This way, applications always would take relative file names from the root folder, which is a very common pattern.</p>
  
  <p>The problem is that <code>ForkOptions</code> enforces the <code>baseDirectory</code> from the module and apparently there's no easy way to change that because <code>forkOptions</code> is private. I would like to pass a <code>forkOptions</code> populated with the <code>baseDirectory</code> from the root project instead.</p>
  
  <p>Besides, there are modules which contain two or more applications. So, I'd like to have separate configurations for each application in a given module which contains two or more applications.</p>
  
  <p>An example tells more than 1000 words:</p>
  
  <h2>build.sbt</h2>
  
  <pre class="lang-scala prettyprint-override"><code>import sbt._
  import Keys._
  
  lazy val buildSettings: Seq[Setting[_]] = Defaults.defaultSettings
  lazy val forkRunOptions: Seq[Setting[_]] = Seq(fork := true)
  
  addCommandAlias("r1",       "ModuleA/RunnerR1:run")
  addCommandAlias("r2",       "ModuleA/RunnerR2:run")
  
  lazy val RunnerR1 = sbt.config("RunnerR1").extend(Compile)
  lazy val RunnerR2 = sbt.config("RunnerR2").extend(Compile)
  
  lazy val root =
    project
      .in(file("."))
      .settings(buildSettings:_*)
      .aggregate(ModuleA)
  
  lazy val ModuleA =
    project
      .in(file("ModuleA"))
      .settings(buildSettings:_*)
      .configs(RunnerR1,RunnerR2)
      .settings(inConfig(RunnerR1)(
        forkRunOptions ++
          Seq(
            mainClass in Compile :=  Option("sbt.tests.issueX.Application1"))):_*)
      .settings(inConfig(RunnerR2)(
        forkRunOptions ++
          Seq(
            mainClass in Compile :=  Option("sbt.tests.issueX.Application2"))):_*)
  </code></pre>
  
  <p>In SBT console, I would expect this:</p>
  
  <pre><code>&gt; r1
  This is Application1
  &gt; r2
  This is Application2
  </code></pre>
  
  <p>But I see this:</p>
  
  <pre><code>&gt; r1
  This is Application2
  &gt; r2
  This is Application2
  </code></pre>
  
  <p>What is the catch?</p>
  
  <p>Not only that... SBT is running applications in process. It's not forking them. Why <code>fork := true</code> is not taking any effect?</p>