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.

194 lines
8.0 KiB

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