aboutsummaryrefslogtreecommitdiff
path: root/project/FlowBuild.scala
blob: 1754e3446c7bc03ae8b730c9d54c34f27b90ed7c (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sbt._
import Keys._
import JniKeys._
import UniqueVersionKeys._
import NativeKeys._


object FlowBuild extends Build {
  val Organization = "com.github.jodersky"
  val ScalaVersion = "2.11.2"
  val Version = "2.0.4"
  
  
  lazy val commonSettings: Seq[Setting[_]] =
    UniqueVersionDefaults.settings ++
    Seq(
      organization := Organization,
      scalaVersion in ThisBuild := ScalaVersion,
      crossScalaVersions in ThisBuild := Seq("2.10.4", ScalaVersion),
      baseVersion := Version,
      licenses := Seq(("BSD-3-Clause", url("http://opensource.org/licenses/BSD-3-Clause"))),
      homepage := Some(url("http://github.com/jodersky/flow")),
      resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/",
      scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature"))

  lazy val publishSettings: Seq[Setting[_]] = Seq(
    publishMavenStyle := true,
    publishTo := {
      val nexus = "https://oss.sonatype.org/"
      if (isSnapshot.value)
        Some("snapshots" at nexus + "content/repositories/snapshots")
      else
        Some("releases"  at nexus + "service/local/staging/deploy/maven2")
    },
    pomIncludeRepository := { _ => false },
    pomExtra := {
      <scm>
        <url>git@github.com:jodersky/flow.git</url>
        <connection>scm:git:git@github.com:jodersky/flow.git</connection>
      </scm>
      <developers>
        <developer>
          <id>jodersky</id>
          <name>Jakob Odersky</name>
        </developer>
      </developers>
    }
  )
  
  lazy val runSettings: Seq[Setting[_]] = Seq(
    fork := true,
    connectInput in run := true,
    outputStrategy := Some(StdoutOutput)
  )

  lazy val root: Project = (
    Project("root", file(".")).aggregate(flow, flowNative)
    settings(
      publish := (),
      publishLocal := ()
    )
  )
  
  lazy val flow: Project = (
    Project("flow", file("flow"))
    settings(commonSettings: _*)
    settings(publishSettings: _*)
    settings(JniDefaults.settings: _*)
    settings(
      javahHeaderDirectory := (baseDirectory in ThisBuild).value / "flow-native" / "src",
      javahClasses := Seq("com.github.jodersky.flow.internal.NativeSerial"),
      compileOrder in Compile := CompileOrder.Mixed,
      libraryDependencies += Dependencies.akkaActor,
      libraryDependencies += Dependencies.ioCore,
      libraryDependencies += Dependencies.ioFile
    )
  )

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

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

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

}