aboutsummaryrefslogtreecommitdiff
path: root/generateModel.sbt
blob: 8597c05510c0524f5a847ae8e87a4e6bbf1d7cb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

// code generation task that calls the customized code generator
lazy val slick = TaskKey[Seq[File]]("generateModel")
lazy val slickCodeGenTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (dir, cp, r, s) =>
  //val outputDir = (dir / "slick").getPath
  val outputDir = "app"
  val url = System.getenv("DATABASE_URL")
  val jdbcDriver = "org.postgresql.Driver"
  val slickDriver = "scala.slick.driver.PostgresDriver"
  val pkg = "models"
  val tables = "bids,charges,items,transactions,users"
  val views = "accounts,sales"
  toError(r.run("codegen.ModelGenerator", cp.files, Array(slickDriver, jdbcDriver, url, tables, outputDir, "Tables", pkg), s.log))
  toError(r.run("codegen.ModelGenerator", cp.files, Array(slickDriver, jdbcDriver, url, views, outputDir, "Views", pkg), s.log))
  Seq(
    file(outputDir + "/models/Tables.scala"),
    file(outputDir + "/models/Views.scala")
  )
}

slick <<= slickCodeGenTask