diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/main/g8/flake.nix b/src/main/g8/flake.nix index 44ba5be..9efe8ae 100644 --- a/src/main/g8/flake.nix +++ b/src/main/g8/flake.nix @@ -12,7 +12,7 @@ in { devShell = import ./shell.nix { pkgs = pkgs.extend - (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-11; }); + (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-$java_version$; }); }; }); } diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/main/g8/flake.nix b/src/main/g8/flake.nix index 44ba5be..9efe8ae 100644 --- a/src/main/g8/flake.nix +++ b/src/main/g8/flake.nix @@ -12,7 +12,7 @@ in { devShell = import ./shell.nix { pkgs = pkgs.extend - (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-11; }); + (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-$java_version$; }); }; }); } diff --git a/src/main/g8/project/build.properties b/src/main/g8/project/build.properties index 10fd9ee..252aa2c 100644 --- a/src/main/g8/project/build.properties +++ b/src/main/g8/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=$sbt_version$ diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/main/g8/flake.nix b/src/main/g8/flake.nix index 44ba5be..9efe8ae 100644 --- a/src/main/g8/flake.nix +++ b/src/main/g8/flake.nix @@ -12,7 +12,7 @@ in { devShell = import ./shell.nix { pkgs = pkgs.extend - (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-11; }); + (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-$java_version$; }); }; }); } diff --git a/src/main/g8/project/build.properties b/src/main/g8/project/build.properties index 10fd9ee..252aa2c 100644 --- a/src/main/g8/project/build.properties +++ b/src/main/g8/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=$sbt_version$ diff --git a/src/main/g8/project/default.properties b/src/main/g8/project/default.properties new file mode 100644 index 0000000..0d20198 --- /dev/null +++ b/src/main/g8/project/default.properties @@ -0,0 +1,3 @@ +iw_version = 0.1.0-SNAPSHOT +sbt_version = 1.5.5 +java_version = 11 \ No newline at end of file diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/main/g8/flake.nix b/src/main/g8/flake.nix index 44ba5be..9efe8ae 100644 --- a/src/main/g8/flake.nix +++ b/src/main/g8/flake.nix @@ -12,7 +12,7 @@ in { devShell = import ./shell.nix { pkgs = pkgs.extend - (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-11; }); + (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-$java_version$; }); }; }); } diff --git a/src/main/g8/project/build.properties b/src/main/g8/project/build.properties index 10fd9ee..252aa2c 100644 --- a/src/main/g8/project/build.properties +++ b/src/main/g8/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=$sbt_version$ diff --git a/src/main/g8/project/default.properties b/src/main/g8/project/default.properties new file mode 100644 index 0000000..0d20198 --- /dev/null +++ b/src/main/g8/project/default.properties @@ -0,0 +1,3 @@ +iw_version = 0.1.0-SNAPSHOT +sbt_version = 1.5.5 +java_version = 11 \ No newline at end of file diff --git a/src/main/g8/project/plugins.sbt b/src/main/g8/project/plugins.sbt index cb83d6c..3f87abf 100644 --- a/src/main/g8/project/plugins.sbt +++ b/src/main/g8/project/plugins.sbt @@ -1,2 +1 @@ -lazy val root = (project in file(".")).dependsOn(iwPlugin) -lazy val iwPlugin = RootProject(file("../sbt-support")) +addIWProjects diff --git a/README.markdown b/README.markdown index 9d93074..dc2630b 100644 --- a/README.markdown +++ b/README.markdown @@ -28,7 +28,7 @@ - IWPluginPresets plugin that pulls in the default plugins used in all projects and shortcuts for a few other commonly used plugins (scalajs, lagom, play etc.) - IWMaterialsBOM plugin that adds shortcuts to currently used versions and settings of libraries used in IW projects (ZIO, Laminar etc.) -- IWProjectPlugin auto triggered plugin which provides default settings for all projects and exports currently used scala versions +- IWScalaProject auto triggered plugin which provides default settings for all projects and exports currently used scala versions Template license ---------------- diff --git a/build.sbt b/build.sbt index 0a3fc92..53a469b 100644 --- a/build.sbt +++ b/build.sbt @@ -2,9 +2,12 @@ ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "works.iterative" +ThisBuild / versionScheme := Some("strict") +ThisBuild / githubOwner := "iterative-works" +ThisBuild / githubRepository := "iw-project-support" lazy val `sbt-iw-plugin-presets` = (project in file("sbt-iw-plugin-presets")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .disablePlugins(Giter8Plugin) .settings( organization := "works.iterative.sbt", @@ -14,17 +17,35 @@ scriptedLaunchOpts.value ++ Seq("-Xmx1024M", "-Dplugin.version=" + version.value) }, - scriptedBufferLog := false + scriptedBufferLog := false, + buildInfoKeys := Seq[BuildInfoKey](name, version), + buildInfoPackage := "works.iterative.sbt" ) -lazy val `sbt-support` = (project in file(".")) +lazy val `sbt-iw-projects` = (project in file("sbt-iw-projects")) + .enablePlugins(SbtPlugin) + .disablePlugins(Giter8Plugin) + .settings( + organization := "works.iterative.sbt", + name := "sbt-iw-projects", + description := "Iterative Works SBT project support", + scriptedLaunchOpts := { + scriptedLaunchOpts.value ++ + Seq("-Xmx1024M", "-Dplugin.version=" + version.value) + }, + scriptedBufferLog := false, + addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2"), + addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") + ) + +lazy val `iw-project-support` = (project in file(".")) // .enablePlugins(ScriptedPlugin) .settings( name := "iw-project-support", Test / test := { val _ = (Test / g8Test).toTask("").value }, - /* scriptedLaunchOpts ++= List( "-Xms1024m", "-Xmx1024m", @@ -32,10 +53,10 @@ "-Xss2m", "-Dfile.encoding=UTF-8" ), - */ resolvers += Resolver.url( "typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/") - )(Resolver.ivyStylePatterns) + )(Resolver.ivyStylePatterns), + publish / skip := true ) - .aggregate(`sbt-iw-plugin-presets`) + .aggregate(`sbt-iw-plugin-presets`, `sbt-iw-projects`) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4260928..e085f6d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,6 @@ +addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.13.1") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") libraryDependencies += { "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value } diff --git a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala index b26f8d7..055249d 100644 --- a/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala +++ b/sbt-iw-plugin-presets/src/main/scala/works/iterative/sbt/IWPluginPresets.scala @@ -4,10 +4,12 @@ import sbt.Keys._ object IWPluginPresets extends AutoPlugin { - override def requires: Plugins = empty override def trigger = allRequirements object autoImport { + val addIWProjects: Def.Setting[_] = addSbtPlugin( + "works.iterative.sbt" % "sbt-iw-projects" % BuildInfo.version + ) val addScalaJSBundler: Def.Setting[_] = addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") val addWebScalaJSBundler: Def.Setting[_] = @@ -58,6 +60,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1"), addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.1"), addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.28"), - addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") + addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0"), + addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") ) } diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala new file mode 100644 index 0000000..e67f5da --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWMaterialsPlugin.scala @@ -0,0 +1,108 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ +import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._ + +object IWMaterialsPlugin extends AutoPlugin { + override def trigger: PluginTrigger = allRequirements + object autoImport { + val IWVersions = IWMaterialsVersions + val IWDeps = IWMaterialsDeps + } +} + +object IWMaterialsVersions { + val akka = "2.6.14" + val akkaHttp = "10.2.4" + val elastic4s = "7.12.2" + val play = "2.8.8" + val playJson = "2.9.2" + val scalaTest = "3.2.9" + val zio = "1.0.9" + val zioConfig = "1.0.6" + val zioJson = "0.1.5" + val zioLogging = "0.5.11" + val laminar = "0.13.1" +} + +object IWMaterialsDeps { + import works.iterative.sbt.{IWMaterialsVersions => V} + + val zio: Def.Setting[_] = libraryDependencies += "dev.zio" %%% "zio" % V.zio + val zioTest: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test" % V.zio % Test + val zioTestSbt: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-test-sbt" % V.zio % Test + + val zioConfig: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config" % V.zioConfig + val zioConfigTypesafe: Def.Setting[_] = + libraryDependencies += "dev.zio" %% "zio-config-typesafe" % V.zioConfig + + val zioJson: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-json" % V.zioJson + val zioLogging: Def.Setting[_] = + libraryDependencies += "dev.zio" %%% "zio-logging" % V.zioLogging + + val useZIO: Seq[Def.Setting[_]] = Seq( + zio, + zioTest, + zioTestSbt, + testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework") + ) + + val zioStreams: Def.Setting[_] = + libraryDependencies += "dev.zio" % "zio-streams" % V.zio + + private val akkaOrg = "com.typesafe.akka" + val akkaActor: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor" % V.akka + val akkaActorTyped: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-actor-typed" % V.akka + val akkaHttp: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http" % V.akkaHttp + val akkaHttpSprayJson: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-http-spray-json" % V.akkaHttp + val akkaStream: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-stream" % V.akka + val akkaPersistenceTestKit: Def.Setting[_] = + libraryDependencies += akkaOrg %% "akka-persistence-testkit" % V.akka + + val scalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatest" %%% "scalatest" % V.scalaTest + val scalaTestPlusScalacheck: Def.Setting[_] = + libraryDependencies += "org.scalatestplus" %% "scalacheck-1-15" % "3.2.9.0" + val playScalaTest: Def.Setting[_] = + libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" + + private val playOrg = "com.typesafe.play" + val playMailer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-mailer" % "8.0.1" + val playServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-server" % V.play + val playAkkaServer: Def.Setting[_] = + libraryDependencies += playOrg %% "play-akka-http-server" % V.play + val play: Def.Setting[_] = libraryDependencies += playOrg %% "play" % V.play + val playAhcWs: Def.Setting[_] = + libraryDependencies += playOrg %% "play-ahc-ws" % V.play + val playJson: Def.Setting[_] = + libraryDependencies += playOrg %%% "play-json" % V.playJson + + private val elastic4sOrg = "com.sksamuel.elastic4s" + val useElastic4S: Def.Setting[_] = libraryDependencies ++= Seq( + elastic4sOrg %% "elastic4s-core" % V.elastic4s, + elastic4sOrg %% "elastic4s-client-akka" % V.elastic4s, + elastic4sOrg %% "elastic4s-http-streams" % V.elastic4s, + elastic4sOrg %% "elastic4s-json-play" % V.elastic4s + ) + + val laminar: Def.Setting[_] = + libraryDependencies += "com.raquo" %%% "laminar" % V.laminar + + val laminextTailwind: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "tailwind" % "0.13.10" + + val laminextFetch: Def.Setting[_] = + libraryDependencies += "io.laminext" %%% "fetch" % "0.13.10" +} diff --git a/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala new file mode 100644 index 0000000..3812e80 --- /dev/null +++ b/sbt-iw-projects/src/main/scala/works/iterative/sbt/IWScalaProject.scala @@ -0,0 +1,38 @@ +package works.iterative.sbt + +import sbt._ +import sbt.Keys._ + +import scalafix.sbt.ScalafixPlugin +import scalafix.sbt.ScalafixPlugin.autoImport._ +import org.scalafmt.sbt.ScalafmtPlugin +import org.scalafmt.sbt.ScalafmtPlugin.autoImport._ + +object IWScalaProject extends AutoPlugin { + override def requires: Plugins = ScalafixPlugin && ScalafmtPlugin + + override def trigger: PluginTrigger = allRequirements + + object autoImport { + val scala2Version = "2.13.6" + val scala3Version = "3.0.1" + } + + import autoImport._ + + override def buildSettings: Seq[Def.Setting[_]] = Seq( + scalaVersion := scala2Version, + // enable SemanticDB + semanticdbEnabled := true, + // use Scalafix compatible version, + semanticdbVersion := scalafixSemanticdb.revision + ) + + override def projectSettings: Seq[Def.Setting[_]] = Seq( + // Do not buffer logging in tests + Test / logBuffered := false, + // Do I need this still for Metals? + // scalacOptions += s"-P:semanticdb:sourceroot:${(ThisBuild / baseDirectory).value}", + scalafmtOnCompile := true + ) +} diff --git a/src/main/g8/.scalafmt.conf b/src/main/g8/.scalafmt.conf index 31a6ebb..7941f4b 100644 --- a/src/main/g8/.scalafmt.conf +++ b/src/main/g8/.scalafmt.conf @@ -1,2 +1,7 @@ -version = "2.4.2" -style = IntelliJ +version = "3.0.0" + +// fileOverride { +// "glob:**/services/{documents,ares}/src/{main,test}/scala/**" { +// runner.dialect = scala3 +// } +// } diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 31c117f..c128b14 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,9 +1 @@ -// give the user a nice default project! -ThisBuild / organization := "com.example" -ThisBuild / scalaVersion := "2.12.8" - lazy val root = (project in file(".")) - .enablePlugins(IWEnvPlugin) - .settings( - name := "IW Project" - ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties deleted file mode 100644 index f8194fb..0000000 --- a/src/main/g8/default.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=My Something Project -description=Say something about this template. diff --git a/src/main/g8/flake.lock b/src/main/g8/flake.lock deleted file mode 100644 index 5dfd6c4..0000000 --- a/src/main/g8/flake.lock +++ /dev/null @@ -1,43 +0,0 @@ -{ - "nodes": { - "flake-utils": { - "locked": { - "lastModified": 1605370193, - "narHash": "sha256-YyMTf3URDL/otKdKgtoMChu4vfVL3vCMkRqpGifhUn0=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5021eac20303a61fafe17224c087f5519baed54d", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1611219034, - "narHash": "sha256-bgp8G3LcpvKs22/z5Cj4XQkmZq05Aa0vaP1bKl7X0zM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "f217c0ea7c148ddc0103347051555c7c252dcafb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/src/main/g8/flake.nix b/src/main/g8/flake.nix index 44ba5be..9efe8ae 100644 --- a/src/main/g8/flake.nix +++ b/src/main/g8/flake.nix @@ -12,7 +12,7 @@ in { devShell = import ./shell.nix { pkgs = pkgs.extend - (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-11; }); + (final: prev: { jre = prev.adoptopenjdk-hotspot-bin-$java_version$; }); }; }); } diff --git a/src/main/g8/project/build.properties b/src/main/g8/project/build.properties index 10fd9ee..252aa2c 100644 --- a/src/main/g8/project/build.properties +++ b/src/main/g8/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=$sbt_version$ diff --git a/src/main/g8/project/default.properties b/src/main/g8/project/default.properties new file mode 100644 index 0000000..0d20198 --- /dev/null +++ b/src/main/g8/project/default.properties @@ -0,0 +1,3 @@ +iw_version = 0.1.0-SNAPSHOT +sbt_version = 1.5.5 +java_version = 11 \ No newline at end of file diff --git a/src/main/g8/project/plugins.sbt b/src/main/g8/project/plugins.sbt index cb83d6c..3f87abf 100644 --- a/src/main/g8/project/plugins.sbt +++ b/src/main/g8/project/plugins.sbt @@ -1,2 +1 @@ -lazy val root = (project in file(".")).dependsOn(iwPlugin) -lazy val iwPlugin = RootProject(file("../sbt-support")) +addIWProjects diff --git a/src/main/g8/project/project/plugins.sbt b/src/main/g8/project/project/plugins.sbt new file mode 100644 index 0000000..fff3bff --- /dev/null +++ b/src/main/g8/project/project/plugins.sbt @@ -0,0 +1,3 @@ +resolvers += "IW plugin repository" at "https://maven.pkg.github.com/iterative-works/iw-project-support" + +addSbtPlugin("works.iterative.sbt" % "sbt-iw-plugin-presets" % "$iw_version$" \ No newline at end of file