You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
7.0 KiB

3 years ago
  1. val Http4sVersion = "0.21.16"
  2. val CirceVersion = "0.13.0"
  3. val MunitVersion = "0.7.20"
  4. val LogbackVersion = "1.2.3"
  5. val MunitCatsEffectVersion = "0.13.0"
  6. val FlywayVersion = "7.5.3"
  7. scalaVersion in ThisBuild := "2.13.4"
  8. import com.github.tototoshi.sbt.slick.CodegenPlugin.autoImport.{
  9. slickCodegenDatabasePassword,
  10. slickCodegenDatabaseUrl,
  11. slickCodegenJdbcDriver
  12. }
  13. import _root_.slick.codegen.SourceCodeGenerator
  14. import _root_.slick.{model => m}
  15. lazy val databaseUrl = sys.env.getOrElse(
  16. "DB_DEFAULT_URL",
  17. "jdbc:postgresql://localhost:5432/test_db"
  18. )
  19. lazy val databaseUser = sys.env.getOrElse("DB_DEFAULT_USER", "test_user")
  20. lazy val databasePassword = sys.env.getOrElse("DB_DEFAULT_PASSWORD", "password")
  21. lazy val flyway = (project in file("modules/flyway"))
  22. .enablePlugins(FlywayPlugin)
  23. .settings(
  24. libraryDependencies += "org.flywaydb" % "flyway-core" % FlywayVersion,
  25. flywayLocations := Seq("classpath:db/migration/default"),
  26. flywayUrl := databaseUrl,
  27. flywayUser := databaseUser,
  28. flywayPassword := databasePassword,
  29. flywayBaselineOnMigrate := true
  30. )
  31. lazy val root = (project in file("."))
  32. .enablePlugins(CodegenPlugin)
  33. .settings(
  34. organization := "wow.doge",
  35. name := "http4s-demo",
  36. version := "0.0.1-SNAPSHOT",
  37. scalacOptions ++= Seq(
  38. "-encoding",
  39. "UTF-8",
  40. "-deprecation",
  41. "-feature",
  42. "-language:existentials",
  43. "-language:experimental.macros",
  44. "-language:higherKinds",
  45. "-language:implicitConversions",
  46. "-unchecked",
  47. "-Xlint",
  48. "-Ywarn-numeric-widen",
  49. "-Ymacro-annotations",
  50. //silence warnings for by-name implicits
  51. "-Wconf:cat=lint-byname-implicit:s",
  52. //give errors on non exhaustive matches
  53. "-Wconf:msg=match may not be exhaustive:e",
  54. "-explaintypes" // Explain type errors in more detail.
  55. ),
  56. javacOptions ++= Seq("-source", "11", "-target", "11"),
  57. //format: off
  58. libraryDependencies ++= Seq(
  59. "org.http4s" %% "http4s-blaze-server" % Http4sVersion,
  60. "org.http4s" %% "http4s-blaze-client" % Http4sVersion,
  61. "org.http4s" %% "http4s-circe" % Http4sVersion,
  62. "org.http4s" %% "http4s-dsl" % Http4sVersion,
  63. "io.circe" %% "circe-generic" % CirceVersion,
  64. "org.scalameta" %% "munit" % MunitVersion % Test,
  65. "org.typelevel" %% "munit-cats-effect-2" % MunitCatsEffectVersion % Test,
  66. "ch.qos.logback" % "logback-classic" % LogbackVersion,
  67. "org.scalameta" %% "svm-subs" % "20.2.0",
  68. "co.fs2" %% "fs2-reactive-streams" % "2.5.0"
  69. ),
  70. //format: on
  71. libraryDependencies ++= Seq(
  72. "io.monix" %% "monix" % "3.3.0",
  73. "io.monix" %% "monix-bio" % "1.1.0",
  74. "io.circe" %% "circe-core" % "0.13.0",
  75. "io.circe" %% "circe-generic" % "0.13.0",
  76. "com.softwaremill.sttp.client" %% "core" % "2.2.9",
  77. "com.softwaremill.sttp.client" %% "monix" % "2.2.9",
  78. "com.softwaremill.sttp.client" %% "circe" % "2.2.9",
  79. "com.softwaremill.sttp.client" %% "httpclient-backend-monix" % "2.2.9",
  80. "com.softwaremill.quicklens" %% "quicklens" % "1.6.1",
  81. "com.softwaremill.common" %% "tagging" % "2.2.1",
  82. "com.softwaremill.macwire" %% "macros" % "2.3.6" % "provided",
  83. "com.github.valskalla" %% "odin-monix" % "0.9.1",
  84. "com.github.valskalla" %% "odin-slf4j" % "0.9.1",
  85. "com.github.valskalla" %% "odin-json" % "0.9.1",
  86. "com.github.valskalla" %% "odin-extras" % "0.9.1",
  87. "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
  88. "com.lihaoyi" %% "os-lib" % "0.7.1",
  89. "com.beachape" %% "enumeratum" % "1.6.1",
  90. "com.chuusai" %% "shapeless" % "2.3.3",
  91. "com.lihaoyi" %% "sourcecode" % "0.2.1",
  92. "eu.timepit" %% "refined" % "0.9.19",
  93. "com.zaxxer" % "HikariCP" % "3.4.2",
  94. "com.typesafe.slick" %% "slick" % "3.3.2",
  95. "com.typesafe.slick" %% "slick-hikaricp" % "3.3.2",
  96. "com.h2database" % "h2" % "1.4.199",
  97. "org.postgresql" % "postgresql" % "42.2.18",
  98. "com.github.pureconfig" %% "pureconfig" % "0.14.0",
  99. "io.scalaland" %% "chimney" % "0.6.0",
  100. "com.rms.miu" %% "slick-cats" % "0.10.4",
  101. "com.kubukoz" %% "slick-effect" % "0.3.0"
  102. ),
  103. addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
  104. addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
  105. ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.4.3",
  106. inThisBuild(
  107. List(
  108. scalaVersion := scalaVersion.value, // 2.11.12, or 2.13.3
  109. semanticdbEnabled := true, // enable SemanticDB
  110. semanticdbVersion := "4.4.2" // use Scalafix compatible version
  111. )
  112. ),
  113. testFrameworks += new TestFramework("munit.Framework"),
  114. assemblyMergeStrategy in assembly := {
  115. case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
  116. case PathList(ps @ _*) if ps.last endsWith ".html" => MergeStrategy.first
  117. case "application.conf" => MergeStrategy.concat
  118. case "unwanted.txt" => MergeStrategy.discard
  119. case x if Assembly.isConfigFile(x) =>
  120. MergeStrategy.concat
  121. case PathList("META-INF", xs @ _*) =>
  122. (xs map { _.toLowerCase }) match {
  123. case ("manifest.mf" :: Nil) | ("index.list" :: Nil) |
  124. ("dependencies" :: Nil) =>
  125. MergeStrategy.discard
  126. case ps @ (x :: xs)
  127. if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =>
  128. MergeStrategy.discard
  129. case "plexus" :: xs =>
  130. MergeStrategy.discard
  131. case "services" :: xs =>
  132. MergeStrategy.filterDistinctLines
  133. case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =>
  134. MergeStrategy.filterDistinctLines
  135. case _ => MergeStrategy.first // Changed deduplicate to first
  136. }
  137. case PathList(_*) => MergeStrategy.first
  138. }
  139. )
  140. .settings(
  141. // libraryDependencies ++= Seq(
  142. // "com.zaxxer" % "HikariCP" % "3.4.2",
  143. // "com.typesafe.slick" %% "slick" % "3.3.2",
  144. // "com.typesafe.slick" %% "slick-hikaricp" % "3.3.2",
  145. // "com.h2database" % "h2" % "1.4.199"
  146. // ),
  147. slickCodegenDatabaseUrl := databaseUrl,
  148. slickCodegenDatabaseUser := databaseUser,
  149. slickCodegenDatabasePassword := databasePassword,
  150. slickCodegenDriver := _root_.slick.jdbc.PostgresProfile,
  151. slickCodegenJdbcDriver := "org.postgresql.Driver",
  152. slickCodegenOutputPackage := "wow.doge.http4sdemo.slickcodegen",
  153. slickCodegenExcludedTables := Seq("schema_version"),
  154. slickCodegenCodeGenerator := { (model: m.Model) =>
  155. new SourceCodeGenerator(model) {
  156. override def Table = new Table(_) {
  157. override def Column = new Column(_) {
  158. override def rawType = model.tpe match {
  159. case "java.sql.Timestamp" =>
  160. "java.time.Instant" // kill j.s.Timestamp
  161. case _ =>
  162. super.rawType
  163. }
  164. }
  165. }
  166. }
  167. },
  168. sourceGenerators in Compile += slickCodegen.taskValue
  169. )
  170. .dependsOn(flyway)