blob: 7b51fb8499b794963b3c9c6424130158b233e9e0 (
plain) (
blame)
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
|
import sbt._
import sbt.Keys._
import complete.DefaultParsers._
object CodegenPlugin extends AutoPlugin {
override def requires = sbt.plugins.JvmPlugin
type TableColumn = (String, String)
object autoImport {
lazy val genTables = TaskKey[Seq[File]]("gen-tables")
lazy val uri = SettingKey[String]("uri for the database configuration")
lazy val pkg = SettingKey[String]("package in which to place generated code")
lazy val tablesFilename = SettingKey[String]("path for slick table models")
lazy val rowsFilename = SettingKey[String]("path for row case classes")
lazy val schemas = SettingKey[List[String]]("schemas and tables to process")
lazy val manualForeignKeys = SettingKey[Map[TableColumn, TableColumn]]("foreign key references to data models add manually")
lazy val slickCodeGenTask = Def.task {
codegen.NamespacedCodegen.run(
new java.net.URI(uri.value),
pkg.value,
tablesFilename.value,
rowsFilename.value,
schemas.value,
manualForeignKeys.value)
Seq(file(tablesFilename.value), file(rowsFilename.value))
}
}
}
|