Last active
August 29, 2015 14:24
-
-
Save laughingman7743/d4de19dfbf6a68eefbab to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Database configuration | |
# ~~~~~ | |
# You can declare as many datasources as you want. | |
# By convention, the default datasource is named `default` | |
# | |
slick.dbs.default.driver="slick.driver.PostgresDriver$" | |
slick.dbs.default.db.driver=org.postgresql.Driver | |
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/YOUR_DATABASE" | |
slick.dbs.default.db.username=YOUR_USER | |
slick.dbs.default.db.password="YOUR_PASSWORD" |
This file contains hidden or 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
import com.typesafe.config.ConfigFactory | |
name := """play24""" | |
version := "1.0-SNAPSHOT" | |
lazy val root = (project in file(".")).enablePlugins(PlayScala) | |
scalaVersion := "2.11.6" | |
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases" | |
libraryDependencies ++= Seq( | |
/*jdbc,*/ // use slick | |
cache, | |
ws, | |
"com.typesafe.play" %% "play-slick" % "1.0.0", | |
"com.typesafe.play" %% "play-slick-evolutions" % "1.0.0", | |
"com.typesafe.slick" % "slick-codegen_2.11" % "3.0.0", | |
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41", | |
specs2 % Test | |
) | |
// Play provides two styles of routers, one expects its actions to be injected, the | |
// other, legacy style, accesses its actions statically. | |
routesGenerator := InjectedRoutesGenerator | |
// Slick code generator | |
slickCodeGen <<= slickCodeGenTask // register sbt command | |
//(compile in Compile) <<= (compile in Compile) dependsOn (slickCodeGenTask) // register automatic code generation on compile | |
lazy val config = ConfigFactory.parseFile(new File("./conf/application.conf")) | |
lazy val slickCodeGen = taskKey[Seq[File]]("slick-codegen") | |
lazy val slickCodeGenTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (dir, cp, r, s) => | |
val slickDriver = config.getString("slick.dbs.default.driver").init | |
val jdbcDriver = config.getString("slick.dbs.default.db.driver") | |
val url = config.getString("slick.dbs.default.db.url") | |
val username = config.getString("slick.dbs.default.db.username") | |
val password = config.getString("slick.dbs.default.db.password") | |
val outputDir = "app/" | |
val pkg = "models" | |
toError(r.run("slick.codegen.SourceCodeGenerator", cp.files, Array(slickDriver, jdbcDriver, url, outputDir, pkg), s.log)) | |
val fname = outputDir + "/Tables.scala" | |
Seq(file(fname)) | |
} |
This file contains hidden or 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
name := """play24""" | |
version := "1.0-SNAPSHOT" | |
lazy val root = (project in file(".")).enablePlugins(PlayScala) | |
scalaVersion := "2.11.6" | |
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases" | |
libraryDependencies ++= Seq( | |
/*jdbc,*/ // use slick | |
cache, | |
ws, | |
"com.typesafe.play" %% "play-slick" % "1.0.0", | |
"com.typesafe.play" %% "play-slick-evolutions" % "1.0.0", | |
"com.typesafe.slick" % "slick-codegen_2.11" % "3.0.0", | |
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41", | |
specs2 % Test | |
) | |
// Play provides two styles of routers, one expects its actions to be injected, the | |
// other, legacy style, accesses its actions statically. | |
routesGenerator := InjectedRoutesGenerator | |
// Slick code generator | |
slickCodeGen <<= slickCodeGenTask // register sbt command | |
//(compile in Compile) <<= (compile in Compile) dependsOn (slickCodeGenTask) // register automatic code generation on compile | |
lazy val slickCodeGen = taskKey[Seq[File]]("slick-codegen") | |
lazy val slickCodeGenTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (dir, cp, r, s) => | |
val slickDriver = "slick.driver.PostgresDriver" | |
val jdbcDriver = "org.postgresql.Driver" | |
val url = "jdbc:postgresql://localhost:5432/YOUR_DATABASE" | |
val username = "YOUR_USER" | |
val password = "YOUR_PASSWORD" | |
val outputDir = "app/" | |
val pkg = "models" | |
toError(r.run("slick.codegen.SourceCodeGenerator", cp.files, Array(slickDriver, jdbcDriver, url, outputDir, pkg), s.log)) | |
val fname = outputDir + "/Tables.scala" | |
Seq(file(fname)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment