This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.sbt
140 lines (122 loc) · 4.92 KB
/
build.sbt
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import sbtassembly.Plugin.AssemblyKeys._
enablePlugins(BintrayPlugin)
val scalaTest = "org.scalatest" %% "scalatest" % "2.1.6" % "test"
val json4sNative = "org.json4s" %% "json4s-native" % "3.2.10"
val akka = "com.typesafe.akka" %% "akka-actor" % "2.3.4"
val jodaTime = "joda-time" % "joda-time" % "2.5"
val jodaConvert = "org.joda" % "joda-convert" % "1.7"
val sprayVersion = "1.3.1"
val sprayCan = "io.spray" %% "spray-can" % sprayVersion
val sprayRouting = "io.spray" %% "spray-routing" % sprayVersion
val sprayHttpx = "io.spray" %% "spray-httpx" % sprayVersion
val Version = "0.3.1i-SNAPSHOT"
val buildSettings = Defaults.coreDefaultSettings ++ Seq(
version := Version,
scalaVersion := "2.11.5",
scalacOptions ++= Seq("-unchecked", "-deprecation", "-feature", "-language:existentials", "-language:higherKinds"),
parallelExecution := false
)
val doNotPublishSettings = Seq(publish := {})
val publishSettings =
(if (Version.endsWith("-SNAPSHOT"))
Seq(
publishTo := Some("Artifactory Realm" at "http://oss.jfrog.org/artifactory/oss-snapshot-local"),
bintrayReleaseOnPublish := false,
// Only setting the credentials file if it exists (#52)
credentials := List(Path.userHome / ".bintray" / ".artifactory").filter(_.exists).map(Credentials(_))
)
else
Seq(
bintrayOrganization := Some("softwaremill"),
bintrayRepository := "softwaremill")
) ++ Seq(
organization := "com.softwaremill.supler",
pomExtra := <scm>
<url>[email protected]:softwaremill/supler.git</url>
<connection>scm:git:[email protected]:softwaremill/supler.git</connection>
</scm>
<developers>
<developer>
<id>szimano</id>
<name>Tomasz Szymanski</name>
<url>http://www.szimano.org</url>
</developer>
<developer>
<id>adamw</id>
<name>Adam Warski</name>
<url>http://www.warski.org</url>
</developer>
</developers>,
publishMavenStyle := false,
publishArtifact in Test := false,
homepage := Some(url("https://github.com/softwaremill/supler")),
resolvers += Resolver.url("supler ivy resolver", url("http://dl.bintray.com/softwaremill/maven"))(Resolver.ivyStylePatterns),
licenses := ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.txt")) :: Nil
)
def haltOnCmdResultError(result: Int) {
if (result != 0) {
throw new Exception("Build failed.")
}
}
lazy val makeVersionSh = taskKey[Seq[File]]("Creates .run.central.synchro.sh file.")
lazy val root: Project = Project(
"root",
file("."),
settings = buildSettings ++ doNotPublishSettings ++ Seq(
publishArtifact := false,
makeVersionSh := {
val pf = new java.io.File(".run.central.synchro.sh")
val content = s"""|#!/bin/bash
|PROJECT_VERSION=${version.value} /bin/bash .central.synchro.sh
""".stripMargin
IO.write(pf, content)
Seq(pf)
}
)
) aggregate(supler, suplerjs, examples)
lazy val supler: Project = Project(
"supler",
file("supler"),
settings = buildSettings ++ publishSettings ++ Seq(
libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _ % "provided"),
libraryDependencies ++= Seq(json4sNative, scalaTest))
)
lazy val createAndCopySuplerJs = taskKey[Unit]("Create and copy the supler js files.")
lazy val examples: Project = Project(
"examples",
file("examples"),
settings = buildSettings ++ doNotPublishSettings ++ assemblySettings ++ Seq(
libraryDependencies ++= Seq(akka, sprayCan, sprayRouting, sprayHttpx, jodaTime, jodaConvert),
jarName in assembly := "supler-example.jar",
mainClass in assembly := Some("org.demo.DemoServer"),
createAndCopySuplerJs := {
val suplerJsDir = baseDirectory.value / ".." / "supler-js"
println("Running grunt")
Process(List("grunt", "ts"), suplerJsDir.getCanonicalFile).!
val suplerJsSource = suplerJsDir / "target" / "supler.js"
val suplerJsTarget = (classDirectory in Compile).value / "supler.js"
println(s"Copying supler.js to resources from $suplerJsSource to $suplerJsTarget")
IO.copy(List((suplerJsSource, suplerJsTarget)))
},
assembly <<= assembly.dependsOn(createAndCopySuplerJs),
publishArtifact := false)
) dependsOn (supler)
val updateNpm = baseDirectory map { bd =>
println("Updating NPM dependencies in " + bd)
haltOnCmdResultError(Process("npm install", bd) !)
println("NPM dependencies updated")
}
def gruntTask(taskName: String) = (baseDirectory, streams) map { (bd, s) =>
val localGruntCommand = "./node_modules/.bin/grunt " + taskName
def buildGrunt() = {
Process(localGruntCommand, bd).!
}
println("Building with Grunt.js : " + taskName)
haltOnCmdResultError(buildGrunt())
} dependsOn updateNpm
lazy val suplerjs: Project = Project(
"supler-js",
file("supler-js"),
settings = buildSettings ++ publishSettings ++ Seq(
test in Test <<= gruntTask("test") dependsOn (test in Test in supler))
)