build.sbt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. val VersionSuffix = Option(System.getenv("VERSION_SUFFIX")).getOrElse("")
  2. lazy val root = project.in(file("."))
  3. .aggregate(
  4. plugin,
  5. libraryJvm,
  6. libraryJs,
  7. playPlugin,
  8. //openapiPlugin
  9. ).settings(
  10. crossScalaVersions := Nil,
  11. publish / skip := true,
  12. )
  13. def commonSettings = Seq(
  14. organization := "com.tflucke",
  15. //maintainer := "Thomas Flucke <admin@tflucke.name>",
  16. scalacOptions ++= Seq(
  17. "-deprecation",
  18. "-unchecked",
  19. "-feature"
  20. ),
  21. crossScalaVersions := Seq("2.12.11", "2.12.10")
  22. )
  23. /****** The Actual Plugin ******/
  24. lazy val plugin = (project in file("plugin"))
  25. .enablePlugins(SbtPlugin)
  26. .settings(commonSettings)
  27. .settings(
  28. addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.1"),
  29. name := "sbt-rest-rpc",
  30. version := s"0.3.2$VersionSuffix",
  31. Compile / resourceGenerators += Def.task {
  32. val file = (Compile / resourceManaged).value / "version.txt"
  33. IO.write(file, (libraryJvm / version).value)
  34. Seq(file)
  35. }.taskValue,
  36. publishLocal := (publishLocal
  37. dependsOn (libraryJvm / publishLocal)
  38. dependsOn (libraryJs / publishLocal)
  39. ).value
  40. ).dependsOn(libraryJvm)
  41. .dependsOn(libraryJs)
  42. /****** The Plugin Library ******/
  43. lazy val library = crossProject(JSPlatform, JVMPlatform)
  44. .in(file("library"))
  45. .settings(commonSettings)
  46. .settings(
  47. name := "rest-rpc",
  48. version := s"0.3.2$VersionSuffix",
  49. crossScalaVersions ++= Seq("2.13.7", "2.13.3")
  50. )
  51. .jvmSettings(
  52. libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.0",
  53. libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.4.2"
  54. )
  55. .jsSettings(
  56. crossScalaVersions ++= Seq("3.1.0"),
  57. libraryDependencies ++= (if (scalaJSVersion.startsWith("0.6.")) Seq(
  58. // Wrapper library for JS dom to scala
  59. // Docs: https://scala-js.github.io/scala-js-dom/
  60. // Scaladocs: https://www.javadoc.io/doc/org.scala-js/scalajs-dom_sjs1.0.0-M7_2.12/0.9.6/org/scalajs/dom/index.html
  61. "org.scala-js" %%% "scalajs-dom" % "0.9.8",
  62. "com.typesafe.play" %%% "play-json" % "2.8.1"
  63. ) else Seq(
  64. "org.scala-js" %%% "scalajs-dom" % "2.1.0",
  65. "com.typesafe.play" %%% "play-json" % "2.10.0-RC5"
  66. ))
  67. )
  68. lazy val libraryJvm = library.jvm
  69. lazy val libraryJs = library.js
  70. /******* The Play Plugin *******/
  71. lazy val playPlugin = (project in file("play"))
  72. .enablePlugins(SbtPlugin)
  73. .settings(commonSettings)
  74. .settings(
  75. addSbtPlugin("com.tflucke" % "sbt-rest-rpc" % "0.3.2-SNAPSHOT"),
  76. name := "sbt-rest-rpc-play",
  77. version := s"0.3.2$VersionSuffix",
  78. libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % Test,
  79. Test / logBuffered := false,
  80. scriptedLaunchOpts := { scriptedLaunchOpts.value ++ Seq(
  81. "-Xmx1024M",
  82. "-Dplugin.version="+version.value,
  83. ) },
  84. scriptedBufferLog := false,
  85. publishLocal := (publishLocal dependsOn (plugin / publishLocal)).value
  86. ).dependsOn(plugin)
  87. /******* The OpenAPI Plugin *******/
  88. lazy val openapiPlugin = (project in file("openapi"))
  89. .enablePlugins(SbtPlugin)
  90. .settings(commonSettings)
  91. .settings(
  92. addSbtPlugin("com.tflucke" % "sbt-rest-rpc" % "0.3.2-SNAPSHOT"),
  93. name := "sbt-rest-rpc-openapi",
  94. version := s"0.3.2$VersionSuffix",
  95. libraryDependencies ++= Seq(
  96. "io.swagger.parser.v3" % "swagger-parser" % "2.0.22",
  97. "org.scalatest" %% "scalatest" % "3.0.8" % Test
  98. ),
  99. Test / logBuffered := false,
  100. scriptedLaunchOpts := { scriptedLaunchOpts.value ++ Seq(
  101. "-Xmx1024M",
  102. "-Dplugin.version="+version.value,
  103. ) },
  104. scriptedBufferLog := false,
  105. publishLocal := (publishLocal dependsOn (plugin / publishLocal)).value
  106. ).dependsOn(plugin)