forked from softwaremill/bootzooka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
135 lines (113 loc) · 5.25 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
import java.text.SimpleDateFormat
import java.util.Date
import sbt._
import Keys._
import scala.util.Try
import scalariform.formatter.preferences._
val slf4jVersion = "1.7.21"
val logBackVersion = "1.1.7"
val scalaLoggingVersion = "3.1.0"
val slickVersion = "3.1.1"
val seleniumVersion = "2.53.0"
val circeVersion = "0.4.0"
val akkaVersion = "2.4.4"
val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion
val logBackClassic = "ch.qos.logback" % "logback-classic" % logBackVersion
val scalaLogging = "com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion
val loggingStack = Seq(slf4jApi, logBackClassic, scalaLogging)
val typesafeConfig = "com.typesafe" % "config" % "1.3.0"
val circeCore = "io.circe" %% "circe-core" % circeVersion
val circeGeneric = "io.circe" %% "circe-generic" % circeVersion
val circeJawn = "io.circe" %% "circe-jawn" % circeVersion
val circe = Seq(circeCore, circeGeneric, circeJawn)
val javaxMailSun = "com.sun.mail" % "javax.mail" % "1.5.5"
val slick = "com.typesafe.slick" %% "slick" % slickVersion
val slickHikari = "com.typesafe.slick" %% "slick-hikaricp" % slickVersion
val h2 = "com.h2database" % "h2" % "1.3.176" //watch out! 1.4.190 is beta
val postgres = "org.postgresql" % "postgresql" % "9.4.1208"
val flyway = "org.flywaydb" % "flyway-core" % "4.0"
val slickStack = Seq(slick, h2, postgres, slickHikari, flyway)
val scalatest = "org.scalatest" %% "scalatest" % "2.2.6" % "test"
val unitTestingStack = Seq(scalatest)
val seleniumJava = "org.seleniumhq.selenium" % "selenium-java" % seleniumVersion % "test"
val seleniumFirefox = "org.seleniumhq.selenium" % "selenium-firefox-driver" % seleniumVersion % "test"
val seleniumStack = Seq(seleniumJava, seleniumFirefox)
val akkaHttpCore = "com.typesafe.akka" %% "akka-http-core" % akkaVersion
val akkaHttpExperimental = "com.typesafe.akka" %% "akka-http-experimental" % akkaVersion
val akkaHttpTestkit = "com.typesafe.akka" %% "akka-http-testkit" % akkaVersion % "test"
val akkaHttpSession = "com.softwaremill.akka-http-session" %% "core" % "0.2.5"
val akkaStack = Seq(akkaHttpCore, akkaHttpExperimental, akkaHttpTestkit, akkaHttpSession)
val commonDependencies = unitTestingStack ++ loggingStack
lazy val commonSettings = SbtScalariform.scalariformSettings ++ Seq(
scalariformPreferences := scalariformPreferences.value
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(PreserveSpaceBeforeArguments, true)
.setPreference(CompactControlReadability, true)
.setPreference(SpacesAroundMultiImports, false),
organization := "com.softwaremill",
version := "0.0.1-SNAPSHOT",
scalaVersion := "2.11.8",
scalacOptions ++= Seq("-unchecked", "-deprecation"),
libraryDependencies ++= commonDependencies
)
def haltOnCmdResultError(result: Int) {
if (result != 0) {
throw new Exception("Build failed.")
}
}
val updateNpm = baseDirectory map { bd =>
println("Updating NPM dependencies")
haltOnCmdResultError(Process("npm install", bd / ".." / "ui") !)
}
def npmTask(taskName: String) = (baseDirectory, streams) map { (bd, s) =>
val localNpmCommand = "npm " + taskName
def buildWebpack() = {
Process(localNpmCommand, bd / ".." / "ui").!
}
println("Building with Webpack : " + taskName)
haltOnCmdResultError(buildWebpack())
} dependsOn updateNpm
lazy val rootProject = (project in file("."))
.settings(commonSettings: _*)
.settings(
name := "bootzooka",
herokuFatJar in Compile := Some((assemblyOutputPath in backend in assembly).value),
deployHeroku in Compile <<= (deployHeroku in Compile) dependsOn (assembly in backend)
)
.aggregate(backend, ui)
lazy val backend: Project = (project in file("backend"))
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings)
.settings(Revolver.settings)
.settings(
libraryDependencies ++= slickStack ++ akkaStack ++ circe ++ Seq(javaxMailSun, typesafeConfig),
buildInfoPackage := "com.softwaremill.bootzooka.version",
buildInfoObject := "BuildInfo",
buildInfoKeys := Seq[BuildInfoKey](
BuildInfoKey.action("buildDate")(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())),
// if the build is done outside of a git repository, we still want it to succeed
BuildInfoKey.action("buildSha")(Try(Process("git rev-parse HEAD").!!.stripLineEnd).getOrElse("?"))),
compile in Compile := {
val compilationResult = (compile in Compile).value
IO.touch(target.value / "compilationFinished")
compilationResult
},
mainClass in Compile := Some("com.softwaremill.bootzooka.Main"),
// We need to include the whole webapp, hence replacing the resource directory
unmanagedResourceDirectories in Compile := {
(unmanagedResourceDirectories in Compile).value ++ List(baseDirectory.value.getParentFile / ui.base.getName / "dist")
},
assemblyJarName in assembly := "bootzooka.jar",
assembly <<= assembly dependsOn npmTask("run build")
)
lazy val ui = (project in file("ui"))
.settings(commonSettings: _*)
.settings(test in Test <<= (test in Test) dependsOn npmTask("run test"))
lazy val uiTests = (project in file("ui-tests"))
.settings(commonSettings: _*)
.settings(
parallelExecution := false,
libraryDependencies ++= seleniumStack,
test in Test <<= (test in Test) dependsOn npmTask("run build")
) dependsOn backend
RenameProject.settings