aboutsummaryrefslogtreecommitdiff
path: root/project/build/SparkProject.scala
blob: be4f263891085a125bdc6da4313556984c8d6974 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sbt._
import de.element34.sbteclipsify._

import sbt.Process._

class SparkProject(info: ProjectInfo)
extends ParentProject(info) with IdeaProject
{
  lazy val core = project("core", "Spark Core", new CoreProject(_))

  lazy val examples =
    project("examples", "Spark Examples", new ExamplesProject(_), core)

  class CoreProject(info: ProjectInfo)
  extends DefaultProject(info) with Eclipsify with IdeaProject
  {
    val TARGET = path("target") / "scala_2.8.1"

    val TEST_REPORT_DIR = TARGET / "test-report"

    // Create an XML test report using ScalaTest's -u option. Unfortunately
    // there is currently no way to call this directly from SBT without
    // executing a subprocess.
    lazy val testReport = task {
      log.info("Creating " + TEST_REPORT_DIR + "...")
      if (!TEST_REPORT_DIR.exists) {
        TEST_REPORT_DIR.asFile.mkdirs()
      }

      log.info("Executing org.scalatest.tools.Runner...")
      val command = ("scala -classpath " + testClasspath.absString + 
                     " org.scalatest.tools.Runner -o " + 
                     " -u " + TEST_REPORT_DIR.absolutePath +
                     " -p " + (TARGET / "test-classes").absolutePath)
      val process = Process(command, path("."), "JAVA_OPTS" -> "-Xmx500m")
      process !

      None
    }.dependsOn(compile, testCompile).describedAs("Generate XML test report.")
  }

  class ExamplesProject(info: ProjectInfo)
  extends DefaultProject(info) with Eclipsify with IdeaProject
  {
  }
}