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.

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