aboutsummaryrefslogtreecommitdiff
path: root/build.sbt
diff options
context:
space:
mode:
authorAnthony Pieter Holland <anthony.holland@gmail.com>2016-03-25 18:23:27 +0200
committerAnthony Pieter Holland <anthony.holland@gmail.com>2016-03-25 18:23:27 +0200
commit3df9e26bb9aa7b992dd704c72e34e0e28159f426 (patch)
treef12e27a5a3c47d645508a91abdb2eee3e37de9c4 /build.sbt
parent08831a9fb92242a4b1af2f5f3e12d560d36d6659 (diff)
downloadslick-codegen-example-3df9e26bb9aa7b992dd704c72e34e0e28159f426.tar.gz
slick-codegen-example-3df9e26bb9aa7b992dd704c72e34e0e28159f426.tar.bz2
slick-codegen-example-3df9e26bb9aa7b992dd704c72e34e0e28159f426.zip
Updated library version for sbt, scala, slick, sl4j, h2 and the eclipse plugin to latest stable versions as of the time of this commit. Also has to remove prefix "scala." from val profile in Example.scala
Diffstat (limited to 'build.sbt')
-rw-r--r--build.sbt30
1 files changed, 30 insertions, 0 deletions
diff --git a/build.sbt b/build.sbt
new file mode 100644
index 0000000..86ceb40
--- /dev/null
+++ b/build.sbt
@@ -0,0 +1,30 @@
+val slickVersion = "3.1.1"
+
+lazy val mainProject = Project(
+ id="slick-codegen-example",
+ base=file("."),
+ settings = Defaults.coreDefaultSettings ++ Seq(
+ scalaVersion := "2.11.8",
+ libraryDependencies ++= List(
+ "com.typesafe.slick" %% "slick" % slickVersion,
+ "com.typesafe.slick" %% "slick-codegen" % slickVersion,
+ "org.slf4j" % "slf4j-nop" % "1.7.19",
+ "com.h2database" % "h2" % "1.4.191"
+ ),
+ slick <<= slickCodeGenTask, // register manual sbt command
+ sourceGenerators in Compile <+= slickCodeGenTask // register automatic code generation on every compile, remove for only manual use
+ )
+)
+
+// code generation task
+lazy val slick = TaskKey[Seq[File]]("gen-tables")
+lazy val slickCodeGenTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (dir, cp, r, s) =>
+ val outputDir = (dir / "slick").getPath // place generated files in sbt's managed sources folder
+ val url = "jdbc:h2:mem:test;INIT=runscript from 'src/main/sql/create.sql'" // connection info for a pre-populated throw-away, in-memory db for this demo, which is freshly initialized on every run
+ val jdbcDriver = "org.h2.Driver"
+ val slickDriver = "slick.driver.H2Driver"
+ val pkg = "demo"
+ toError(r.run("slick.codegen.SourceCodeGenerator", cp.files, Array(slickDriver, jdbcDriver, url, outputDir, pkg), s.log))
+ val fname = outputDir + "/demo/Tables.scala"
+ Seq(file(fname))
+}