title: How SBT test task manages class path and how to correctly start a Java process from SBT test
body: <p>In one of my Scala tests, using <code>ProcessBuilder</code>, I fire up 3 Apache Spark streaming applications in separate JVMs. (Two or more Spark streaming applications can not co-exist in the same JVM.) One Spark application processes data and ingests into Apache Kafka, which the other ones read. Moreover the test involves writing into a NoSQL database.</p>
  
  <p>While using <code>ProcessBuilder</code>, the Spark application's class path is set using:</p>
  
  <p><code>val classPath = System.getProperty("java.class.path")</code></p>
  
  <p>Running the test in IntelliJ works as expected, but on a CI system, the test is invoked by SBT's test task. The <code>java.class.path</code> in the latter case, will be solely the <code>sbt.jar</code>, so the child JVM exits with <code>NoClassFoundException</code>, again, as expected. :-)</p>
  
  <p>I'm looking for a way to "span" JVMs from SBT tests using the same class path that the tests are actually using. For example if the test is invoked in project <code>core</code>, the class path of project <code>core</code> should be supplied to the child JVM, where the Spark application starts. Unfortunately I have got no idea how to retrieve the correct class path in SBT tasks - which then could be supplied to child JVMs.</p>