forked from overview/overview-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.scala
167 lines (150 loc) · 7.23 KB
/
Build.scala
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import sbt._
import Keys._
import play.Project._
import templemore.sbt.cucumber.CucumberPlugin
import com.typesafe.sbteclipse.core.EclipsePlugin.EclipseKeys
import com.typesafe.sbt.SbtStartScript
object ApplicationBuild extends Build with ProjectSettings {
override def settings = super.settings ++ Seq(
EclipseKeys.skipParents in ThisBuild := false,
scalaVersion := ourScalaVersion,
resolvers ++= ourResolvers)
val workerJavaOpts = "-Dlogback.configurationFile=workerdevlog.xml" +: {
if (System.getProperty("datasource.default.url") == null) Seq("-Ddatasource.default.url=" + appDatabaseUrl)
else Nil
}
val ourTestWithNoDbOptions = Seq(
Tests.Argument("xonly"),
Tests.Setup { loader =>
// Load Logger so configurations happen in the right order
loader.loadClass("org.slf4j.LoggerFactory")
.getMethod("getLogger", loader.loadClass("java.lang.String"))
.invoke(null, "ROOT")
}
)
val ourTestOptions = ourTestWithNoDbOptions ++ Seq(
Tests.Setup { () =>
System.setProperty("datasource.default.url", testDatabaseUrl)
System.setProperty("logback.configurationFile", "logback-test.xml")
},
Tests.Setup(loader => ClearTestDatabase(loader)))
val printClasspathTask = TaskKey[Unit]("print-classpath")
val printClasspath = printClasspathTask <<= (fullClasspath in Runtime) map { classpath =>
println(classpath.map(_.data).mkString(":"))
}
val messageBroker = Project("message-broker", file("message-broker"), settings =
Defaults.defaultSettings ++ SbtStartScript.startScriptForClassesSettings ++ OverviewCommands.defaultSettings ++
Seq(
libraryDependencies ++= messageBrokerDependencies,
printClasspath))
val searchIndex = Project("search-index", file("search-index"), settings =
Defaults.defaultSettings ++ SbtStartScript.startScriptForClassesSettings ++ OverviewCommands.defaultSettings).settings(
libraryDependencies ++= searchIndexDependencies,
Keys.fork := true,
javaOptions in run <++= (baseDirectory) map { (d) =>
Seq(
"-Des.path.home=" + d,
"-Xms1g", "-Xmx1g", "-Xss256k",
"-XX:+UseParNewGC", "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-XX:+UseCMSInitiatingOccupancyOnly",
"-Djava.awt.headless=true",
"-Delasticsearch",
"-Des.foreground=yes"
)
},
printClasspath)
// Create a subProject with our common settings
object OverviewProject extends OverviewCommands with OverviewKeys {
def apply(name: String, dependencies: Seq[ModuleID],
useSharedConfig: Boolean = true,
theTestOptions: Seq[TestOption] = ourTestOptions) = {
Project(name, file(name), settings =
Defaults.defaultSettings ++
defaultSettings ++
SbtStartScript.startScriptForClassesSettings ++
Seq(printClasspath) ++
addUnmanagedResourceDirectory(useSharedConfig) ++
Seq(
libraryDependencies ++= dependencies,
testOptions in Test ++= theTestOptions,
scalacOptions ++= ourScalacOptions,
logBuffered := false,
parallelExecution in Test := false,
sources in doc in Compile := List(),
printClasspath))
}
// don't clean the database if it isn't being used in tests
def withNoDbTests(name: String, dependencies: Seq[ModuleID], useSharedConfig: Boolean = true,
theTestOptions: Seq[TestOption] = ourTestWithNoDbOptions) = apply(name, dependencies, useSharedConfig, theTestOptions)
private def addUnmanagedResourceDirectory(useSharedConfig: Boolean) =
if (useSharedConfig) Seq(unmanagedResourceDirectories in Compile <+= baseDirectory { _ / "../worker-conf" })
else Seq()
}
// Project definitions
val common = OverviewProject("common", commonProjectDependencies, useSharedConfig = false)
val workerCommon = OverviewProject.withNoDbTests("worker-common", workerCommonProjectDependencies, useSharedConfig = false)
.dependsOn(common)
val documentSetWorker = OverviewProject.withNoDbTests("documentset-worker", documentSetWorkerProjectDependencies)
.settings(
Keys.fork := true,
javaOptions in run ++= workerJavaOpts,
javaOptions in Test += "-Dlogback.configurationFile=logback-test.xml")
.dependsOn(common, workerCommon)
val worker = OverviewProject("worker", workerProjectDependencies).settings(
Keys.fork := true,
javaOptions in run ++= workerJavaOpts,
javaOptions in Test += "-Dlogback.configurationFile=logback-test.xml").dependsOn(workerCommon, common)
val main = play.Project(appName, appVersion, serverProjectDependencies).settings(
resolvers += "t2v.jp repo" at "http://www.t2v.jp/maven-repo/").settings(
CucumberPlugin.cucumberSettingsWithIntegrationTestPhaseIntegration: _*).configs(
IntegrationTest).settings(
Defaults.itSettings: _*).settings(
scalacOptions ++= ourScalacOptions,
templatesImport += "views.Magic._",
requireJs ++= Seq(
"bundle/DocumentCloudImportJob/new.js",
"bundle/DocumentSet/index.js",
"bundle/DocumentSet/show.js",
"bundle/Document/show.js",
"bundle/Welcome/show.js",
"bundle/admin/ImportJob/index.js",
"bundle/admin/User/index.js"),
requireJsShim += "main.js",
aggregate in Compile := true,
parallelExecution in IntegrationTest := false,
javaOptions in Test ++= Seq(
"-Dconfig.file=conf/application-test.conf",
"-Dlogger.resource=logback-test.xml",
"-Ddb.default.url=" + testDatabaseUrl,
"-XX:MaxPermSize=256m"),
javaOptions in IntegrationTest ++= Seq(
"-Dconfig.file=conf/application-it.conf",
"-Dlogger.resource=logback-test.xml",
"-Ddb.default.url=" + testDatabaseUrl,
"-Dsbt.ivy.home=" + sys.props("sbt.ivy.home"),
"-Dsbt.boot.properties=" + sys.props("sbt.boot.properties"),
"-Dplay.home=" + sys.props("play.home"),
"-Ddatasource.default.url=" + testDatabaseUrl),
Keys.fork in Test := true,
aggregate in Test := false,
testOptions in Test ++= ourTestOptions,
logBuffered := false,
Keys.fork in IntegrationTest := true,
sources in doc in Compile := List(),
printClasspath,
aggregate in printClasspathTask := false
).settings(
if (scala.util.Properties.envOrElse("COMPILE_LESS", "true") == "false")
lessEntryPoints := Nil
else
lessEntryPoints <<= baseDirectory(_ / "app" / "assets" / "stylesheets" * "*.less") // only compile .less files that aren't in subdirs
).dependsOn(common)
val all = Project("all", file("all"))
.aggregate(main, worker, documentSetWorker, workerCommon, common)
.settings(
aggregate in Test := false,
test in Test <<= (test in Test in main)
dependsOn (test in Test in worker)
dependsOn (test in Test in documentSetWorker)
dependsOn (test in Test in workerCommon)
dependsOn (test in Test in common))
}