forked from tototoshi/sbt-slick-codegen-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
59 lines (55 loc) · 2.1 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
import slick.codegen.SourceCodeGenerator
import slick.{model => m}
lazy val databaseUrl = sys.env.getOrElse("DB_DEFAULT_URL", "DB_DEFAULT_URL is not set")
lazy val databaseUser = sys.env.getOrElse("DB_DEFAULT_USER", "DB_DEFAULT_USER is not set")
lazy val databasePassword = sys.env.getOrElse("DB_DEFAULT_PASSWORD", "DB_DEFAULT_PASSWORD is not set")
lazy val flyway = (project in file("flyway"))
.enablePlugins(FlywayPlugin)
.settings(
scalaVersion := "2.13.10",
flywayUrl := databaseUrl,
flywayUser := databaseUser,
flywayPassword := databasePassword,
flywayLocations := Seq("filesystem:web/conf/db/migration/default")
)
lazy val web = (project in file("web"))
.enablePlugins(PlayScala, CodegenPlugin)
.settings(
scalaVersion := "2.13.10",
libraryDependencies ++= Seq(
guice,
jdbc,
"com.typesafe.play" %% "play-slick" % "5.0.2",
"com.typesafe.slick" %% "slick" % "3.3.3",
"com.h2database" % "h2" % "2.1.214",
"org.scalatest" %% "scalatest" % "3.2.13" % Test
),
slickCodegenDatabaseUrl := databaseUrl,
slickCodegenDatabaseUser := databaseUser,
slickCodegenDatabasePassword := databasePassword,
slickCodegenDriver := slick.jdbc.H2Profile,
slickCodegenJdbcDriver := "org.h2.Driver",
slickCodegenOutputPackage := "models",
slickCodegenExcludedTables := Seq("schema_version"),
slickCodegenCodeGenerator := { (model: m.Model) =>
new SourceCodeGenerator(model) {
override def Table = new Table(_) {
override def Column = new Column(_) {
override def rawType = model.tpe match {
case "java.sql.Timestamp" => "java.time.Instant" // kill j.s.Timestamp
case _ =>
super.rawType
}
}
}
}
},
slickCodegenOutputToMultipleFiles := true,
Compile / sourceGenerators += slickCodegen.taskValue,
slickCodegenOutputDir := (Compile / sourceManaged).value / "a"
)
lazy val root = (project in file("."))
.aggregate(flyway, web)
.settings(
ThisBuild / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oF")
)