Docs: update Direct Usage section of Forking page. Closes #881.

This commit is contained in:
Mark Harrah 2013-09-22 13:46:34 -04:00
parent d1686d438c
commit 558029eee8
1 changed files with 21 additions and 7 deletions

View File

@ -158,10 +158,24 @@ Direct Usage
============
To fork a new Java process, use the `Fork
API <../../api/sbt/Fork$.html>`_. The
methods of interest are `Fork.java`, `Fork.javac`, `Fork.scala`,
and `Fork.scalac`. See the
`ForkJava <../../api/sbt/Fork$.ForkJava.html>`_
and
`ForkScala <../../api/sbt/Fork$.ForkScala.html>`_
classes for the arguments and types.
API <../../api/sbt/Fork$.html>`_.
The values of interest are `Fork.java`, `Fork.javac`, `Fork.scala`, and `Fork.scalac`.
These are of type `Fork <../../api/sbt/Fork.html>`_ and provide `apply` and `fork` methods.
For example, to fork a new Java process, ::
val options = ForkOptions(...)
val arguments: Seq[String] = ...
val mainClass: String = ...
val exitCode: Int = Fork.java(options, mainClass +: arguments)
`ForkOptions <../../api/sbt/ForkOptions.html>`_ defines the Java installation to use, the working directory, environment variables, and more.
For example, ::
val cwd: File = ...
val javaDir: File = ...
val options = ForkOptions(
envVars = Map("KEY" -> "value"),
workingDirectory = Some(cwd),
javaHome = Some(javaDir)
)