aboutsummaryrefslogtreecommitdiff
path: root/project/Build.scala
blob: 82b9c66492f6d02a30becef5308ef2ab8e156ba2 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import sbt._
import Keys._
import JniKeys._
import NativeKeys._


object FlowBuild extends Build {
  
  lazy val commonSettings: Seq[Setting[_]] = Seq(
    version := "2.2.2",
    scalaVersion in ThisBuild := "2.11.7",
    crossScalaVersions in ThisBuild := Seq("2.10.5", "2.11.7"),
    organization := "com.github.jodersky",
    licenses := Seq(("BSD New", url("http://opensource.org/licenses/BSD-3-Clause"))),
    scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", "-target:jvm-1.7")
  )
  
  lazy val runSettings: Seq[Setting[_]] = Seq(
    fork := true,
    connectInput in run := true,
    outputStrategy := Some(StdoutOutput)
  )

  lazy val root: Project = (
    Project("root", file("."))
    aggregate(main, native)
    settings(commonSettings: _*)
    settings(
      publishArtifact := false,
      publish := (),
      publishLocal := (),
      publishTo := Some(Resolver.file("Unused transient repository", target.value / "unusedrepo")) // make sbt-pgp happy
    )
  )
  
  lazy val main: Project = (
    Project("main", file("flow-main"))
    settings(commonSettings: _*)
    settings(JniDefaults.settings: _*)
    settings(
      name := "flow",
      javahHeaderDirectory := (baseDirectory in ThisBuild).value / "flow-native" / "src",
      javahClasses := Seq("com.github.jodersky.flow.internal.NativeSerial"),
      compileOrder in Compile := CompileOrder.Mixed,
      libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.13"
    )
  )

  lazy val native: Project = (
    Project("native", file("flow-native-sbt"))
    settings(commonSettings: _*)
    settings(NativeDefaults.settings: _*)
    settings(
      name := "flow-native",
      crossPaths := false,
      nativeBuildDirectory := (baseDirectory in ThisBuild).value / "flow-native"
    )
  )

  lazy val samplesTerminal = (
    Project("samples-terminal", file("flow-samples") / "terminal")
    settings(commonSettings: _*)
    settings(runSettings: _*)
    dependsOn(main)

    //kind of dirty, but it gets the sample to run without installing native libraries
    settings(
      (run in Compile) <<= (run in Compile).dependsOn(nativeBuild in native),
      javaOptions += "-Djava.library.path=" + (nativeOutputDirectory in native).value.getAbsolutePath()
    )    
  )

  lazy val samplesWatcher = (
    Project("samples-watcher", file("flow-samples") / "watcher")
    settings(commonSettings: _*)
    settings(runSettings: _*)
    dependsOn(main)
  )

}