-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sbt
91 lines (80 loc) · 3.33 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
import scala.sys.process.*
import org.flywaydb.core.Flyway
import DbTasks.*
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / scalaVersion := "3.3.1"
ThisBuild / tlBaseVersion := "0.1"
ThisBuild / tlCiHeaderCheck := false
// Remove dependency submission, which is failing and is not worth setting up for this project
ThisBuild / githubWorkflowAddedJobs ~= (jobs => jobs.filter(job => job.id != "dependency-submission"))
val startDb = taskKey[Unit]("Start the Postgres Docker container")
val initDb = taskKey[Unit]("Create database tables and add initial data")
val databaseDirectory = settingKey[File]("The directory on the local file system where the database is stored.")
val databaseContainerName = settingKey[String]("The name of the Docker container running the database.")
val databaseName = settingKey[String]("The name of the Snorri database.")
val commonSettings = Seq(
libraryDependencies ++=
"org.creativescala" %% "krop-core" % "0.7.0" ::
Modules.circe
)
lazy val snorriRoot =
project
.in(file("."))
.aggregate(backend, frontend, integration)
lazy val backend: Project =
project
.in(file("backend"))
.settings(
commonSettings,
libraryDependencies += "org.tpolecat" %% "skunk-core" % "0.6.3",
// This sets Krop into development mode, which gives useful tools for
// developers. If you don't set this, Krop runs in production mode.
run / javaOptions += "-Dkrop.mode=development",
run / fork := true,
databaseDirectory := baseDirectory.value / "data",
databaseContainerName := "snorri-db",
databaseName := "snorri",
startDb := {
s"mkdir ${databaseDirectory.value}".!
s"docker run --name ${databaseContainerName.value} -p 5432:5432 -v ${databaseDirectory.value}/snorri-db -e POSTGRES_PASSWORD=password -d postgres:latest".!
},
initDb := {
createDb(databaseName.value, databaseContainerName.value)
createTrgm(databaseName.value, databaseContainerName.value)
Flyway
.configure(getClass.getClassLoader)
.driver("org.postgresql.Driver")
.dataSource(
s"jdbc:postgresql://localhost:5432/${databaseName.value}",
"postgres",
"password"
)
.schemas(databaseName.value)
.locations(s"filesystem:${(Compile / resourceDirectory).value / "db" / "migration"}")
.validateMigrationNaming(true)
.failOnMissingLocations(true)
.outOfOrder(true)
.load
.migrate
}
)
lazy val frontend =
project
.in(file("frontend"))
.settings(commonSettings)
.settings(
libraryDependencies += "io.indigoengine" %%% "tyrian-io" % "0.10.0",
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) }
)
.enablePlugins(ScalaJSPlugin)
lazy val integration = (project in file("integration"))
.dependsOn(backend)
.settings(
publish / skip := true,
libraryDependencies ++=
"com.dimafeng" %% "testcontainers-scala-scalatest" % "0.41.2" % Test ::
"com.dimafeng" %% "testcontainers-scala-postgresql" % "0.41.2" % Test ::
"org.postgresql" % "postgresql" % "42.7.1" % Test ::
"org.scalatest" %% "scalatest" % "3.2.18" % Test ::
Nil
)