build.sbt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. )
  22. /****** The Actual Plugin ******/
  23. lazy val plugin = (project in file("plugin"))
  24. .enablePlugins(SbtPlugin)
  25. .settings(commonSettings)
  26. .settings(
  27. addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.1"),
  28. name := "sbt-rest-rpc",
  29. version := s"0.3.2$VersionSuffix",
  30. Compile / resourceGenerators += Def.task {
  31. val file = (Compile / resourceManaged).value / "version.txt"
  32. IO.write(file, (libraryJvm / version).value)
  33. Seq(file)
  34. }.taskValue,
  35. publishLocal := (publishLocal
  36. dependsOn (libraryJvm / publishLocal)
  37. dependsOn (libraryJs / publishLocal)
  38. ).value
  39. ).dependsOn(libraryJvm)
  40. .dependsOn(libraryJs)
  41. /****** The Plugin Library ******/
  42. lazy val library = crossProject(JSPlatform, JVMPlatform)
  43. .in(file("library"))
  44. .settings(commonSettings)
  45. .settings(
  46. name := "rest-rpc",
  47. version := s"0.3.2$VersionSuffix",
  48. crossScalaVersions ++= Seq("3.0.0-M3", "2.13.7", "2.13.3")
  49. )
  50. .jvmSettings(
  51. // [tflucke] 2021-12-18: TODO: Exclude 3.1.0 because scalajs doesn't support it.
  52. libraryDependencies += "com.typesafe.play" %% "play-json" % "2.10.0-RC5",
  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. "-Dhttp.port=10000",
  84. ) },
  85. scriptedBufferLog := false,
  86. publishLocal := (publishLocal dependsOn (plugin / publishLocal)).value
  87. ).dependsOn(plugin)
  88. /******* The OpenAPI Plugin *******/
  89. lazy val openapiPlugin = (project in file("openapi"))
  90. .enablePlugins(SbtPlugin)
  91. .settings(commonSettings)
  92. .settings(
  93. addSbtPlugin("com.tflucke" % "sbt-rest-rpc" % "0.3.2-SNAPSHOT"),
  94. name := "sbt-rest-rpc-openapi",
  95. version := s"0.3.2$VersionSuffix",
  96. libraryDependencies ++= Seq(
  97. "io.swagger.parser.v3" % "swagger-parser" % "2.0.22",
  98. "org.scalatest" %% "scalatest" % "3.0.8" % Test
  99. ),
  100. Test / logBuffered := false,
  101. scriptedLaunchOpts := { scriptedLaunchOpts.value ++ Seq(
  102. "-Xmx1024M",
  103. "-Dplugin.version="+version.value,
  104. ) },
  105. scriptedBufferLog := false,
  106. publishLocal := (publishLocal dependsOn (plugin / publishLocal)).value
  107. ).dependsOn(plugin)