-
Notifications
You must be signed in to change notification settings - Fork 37
/
build.sbt
133 lines (122 loc) · 5.21 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
import java.io.{File,IOException}
import spray.boilerplate.BoilerplatePlugin
val rootDirectory = sys.props("user.dir")
val baseJavaOpts = Seq(
"-Duser.timezone=UTC",
"-Ddb.default.properties.serverName=database",
"-Dredis.host=redis"
)
lazy val devJavaOpts = baseJavaOpts ++ Seq(
"-Ddb.default.properties.databaseName=overview-dev",
"-DblobStorage.file.baseDirectory=/var/lib/overview/blob-storage/dev",
"-Dsearch.baseDirectory=/var/lib/overview/search/dev"
)
lazy val testJavaOpts = baseJavaOpts ++ Seq(
"-Ddb.default.properties.databaseName=overview-test",
"-Dlogback.configurationFile=logback-test.xml",
"-DblobStorage.file.baseDirectory=/var/lib/overview/blob-storage/test",
"-Dsearch.baseDirectory=/var/lib/overview/blob-storage/test"
)
// Settings that apply to all our projects
lazy val root = (project in file("."))
.settings(
inThisBuild(List(
// Settings common to all projects
organization := "com.overviewdocs",
version := "1.0.0-SNAPSHOT",
scalaVersion := "2.12.10",
scalacOptions := Seq("-deprecation", "-unchecked", "-feature", "-target:jvm-1.8", "-encoding", "UTF8"),
resolvers := Seq(
"Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/",
"jbig2 repository" at "https://jbig2-imageio.googlecode.com/svn/maven-repository",
"Oracle Released Java Packages" at "https://download.oracle.com/maven",
"scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"
),
logBuffered := false,
javaOptions in Compile := devJavaOpts,
javaOptions in Test := testJavaOpts,
fork := true, // so javaOptions gets set
parallelExecution in Test := false, // because we test with the (global) database
aggregate in Test := false, // otherwise we'd get parallel execution
testOptions in Test := Seq(
Tests.Argument(TestFrameworks.Specs2, "xonly"),
Tests.Argument(TestFrameworks.Specs2, "showtimes"),
Tests.Argument("junitxml", "console")
)
)),
publish / skip := true
)
// Runs database evolutions on prod+dev
lazy val `db-evolution-applier` = (project in file("db-evolution-applier"))
.enablePlugins(JavaAppPackaging)
.settings(
target := file("/root") / "overview-build" / "db-evolution-applier",
libraryDependencies ++= Dependencies.dbEvolutionApplierDependencies
)
// Runs database evolutions on test (run this before running other tests)
lazy val `test-db-evolution-applier` = (project in file("db-evolution-applier"))
.enablePlugins(JavaAppPackaging)
.settings(
target := file("/root") / "overview-build" / "test-db-evolution-applier",
javaOptions in Compile := testJavaOpts,
libraryDependencies ++= Dependencies.dbEvolutionApplierDependencies
)
// Shared code for other projects
lazy val common = (project in file("common"))
.enablePlugins(JavaAppPackaging)
.settings(
target := file("/root") / "overview-build" / "common",
libraryDependencies ++= Dependencies.commonDependencies,
sources in doc in Compile := List() // docs take time; skip 'em
)
// Daemon that executes background tasks
lazy val worker = (project in file("worker"))
.enablePlugins(JavaAppPackaging)
.enablePlugins(BoilerplatePlugin)
//.enablePlugins(Revolver)
.settings(
target := file("/root") / "overview-build" / "worker",
libraryDependencies ++= Dependencies.workerDependencies,
mainClass in Compile := Some("com.overviewdocs.Worker"),
sources in doc in Compile := List(), // docs take time; skip 'em
javaOptions in reStart ++= devJavaOpts
)
.dependsOn(common % "test->test;compile->compile")
// Daemon that communicates with web browsers
lazy val web = (project in file("web"))
.enablePlugins(PlayScala)
.enablePlugins(PlayNpm)
.enablePlugins(SbtWeb)
.enablePlugins(JavaAppPackaging)
.settings(PlayNpm.projectSettings)
.settings(
target := file("/root") / "overview-build" / "web",
PlayKeys.externalizeResources := false, // so `stage` doesn't nix all assets
libraryDependencies ++= Dependencies.serverDependencies,
TwirlKeys.templateImports ++= Seq("views.Magic._", "play.twirl.api.HtmlFormat"),
routesImport += "extensions.Binders._",
javaOptions in Test += "-Dlogger.resource=logback-test.xml",
sources in doc in Compile := List(), // docs take time; skip 'em
includeFilter in (Assets, digest) := new FileFilter {
override def accept(f: File): Boolean = {
val pathString = f.getPath.replaceAll(File.pathSeparator, "/")
val rightDirectory = pathString.matches(".*/web/public/(fonts|images|javascript-bundles|javascripts/vendor|stylesheets)/.*")
val rightExtension = f.getName.matches(".*\\.(css|js|png|jpg|ttf|woff|woff2|svg)")
rightDirectory && rightExtension
}
},
pipelineStages := Seq(digest, gzip)
)
.dependsOn(common % "test->test;compile->compile;test->compile")
// Test aggregator. Call as "./sbt all/test".
lazy val all = (project in file("all"))
.aggregate(web, worker, common)
.settings(
target := file("/root") / "overview-build" / "all",
test in Test := Def.sequential(
(run in Runtime in `test-db-evolution-applier`).toTask(""),
test in Test in common,
test in Test in worker,
test in Test in web
).value
)