Last active
January 2, 2016 00:49
-
-
Save fdz5/8226163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slick <<= slickCodeGenTask | |
lazy val slick = TaskKey[Seq[File]]("gen-tables") | |
lazy val slickCodeGenTask = (baseDirectory, dependencyClasspath in Compile, runner in Compile, streams) map { | |
(dir, cp, r, s) => | |
println() | |
val outputDir = (dir / "app" ).getPath // place generated files in app sources folder | |
val url = "jdbc:postgresql://host:port/database" | |
val jdbcDriver = "org.postgresql.Driver" | |
val slickDriver = "scala.slick.driver.PostgresDriver" | |
val pkg = "models.db" | |
val cp2 = cp.files ++ Seq(new java.io.File((dir / "target" / "scala-2.10" / "classes").getPath)) | |
toError(r.run("sbt.CustomSourceCodeGenerator", cp2, Array(slickDriver, jdbcDriver, url, outputDir, pkg, "user", "password"), s.log)) | |
val fname = outputDir + "/models/db/Tables.scala" | |
Seq(file(fname)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment