From 4d3c6bce2a5820f2fd4f84d3e0455da6325de78a Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Wed, 17 Apr 2024 10:05:06 +0200 Subject: [PATCH 1/5] Add `sbt-tpolecat` - And fix some warnings --- build.sbt | 4 +++- src/main/g8/build.sbt | 4 +++- src/main/g8/project/plugins.sbt | 1 + .../HelloWorldSuite.scala | 1 - 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 src/main/g8/project/plugins.sbt diff --git a/build.sbt b/build.sbt index c7dd95b..3cf9c1b 100644 --- a/build.sbt +++ b/build.sbt @@ -18,5 +18,7 @@ lazy val root = (project in file(".")) "org.typelevel" %% "cats-effect-std" % "3.5.4", "org.typelevel" %% "cats-effect-testing-specs2" % "1.5.0" % Test, "org.typelevel" %% "munit-cats-effect-3" % "1.0.7" % Test - ) + ), + // Add sbt plugins here, so that scala steward updates them in the g8 template + addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1"), ) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index be7cc43..f2c9d43 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,5 +1,8 @@ +import org.typelevel.sbt.tpolecat.* + ThisBuild / organization := "com.example" ThisBuild / scalaVersion := $if(scala3.truthy)$"3.4.0"$else$"2.13.13"$endif$ +ThisBuild / tpolecatDefaultOptionsMode := VerboseMode; lazy val root = (project in file(".")).settings( name := "$name;format="norm"$", @@ -15,6 +18,5 @@ lazy val root = (project in file(".")).settings( compilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1")$endif$$if(testlib-use-cats-effect-testing-specs2.truthy)$, "org.typelevel" %% "cats-effect-testing-specs2" % "1.5.0" % Test$else$$endif$$if(testlib-use-munit-cats-effect-3.truthy)$, "org.typelevel" %% "munit-cats-effect-3" % "1.0.7" % Test$else$$endif$ - ) ) diff --git a/src/main/g8/project/plugins.sbt b/src/main/g8/project/plugins.sbt new file mode 100644 index 0000000..792120b --- /dev/null +++ b/src/main/g8/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1") diff --git a/src/main/g8/src/test/scala/$package$/$if(testlib-use-munit-cats-effect-3.truthy)$.$endif$/HelloWorldSuite.scala b/src/main/g8/src/test/scala/$package$/$if(testlib-use-munit-cats-effect-3.truthy)$.$endif$/HelloWorldSuite.scala index da6e13f..4dbdba7 100644 --- a/src/main/g8/src/test/scala/$package$/$if(testlib-use-munit-cats-effect-3.truthy)$.$endif$/HelloWorldSuite.scala +++ b/src/main/g8/src/test/scala/$package$/$if(testlib-use-munit-cats-effect-3.truthy)$.$endif$/HelloWorldSuite.scala @@ -1,6 +1,5 @@ package $package$ -import cats.effect.{IO, SyncIO} import munit.CatsEffectSuite class HelloWorldSuite extends CatsEffectSuite { From 28a340de15e72f1333a1d63f866d15c17f77e900 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Wed, 17 Apr 2024 10:18:03 +0200 Subject: [PATCH 2/5] Add comment how to enable CI mode --- src/main/g8/build.sbt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index f2c9d43..c060a39 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -2,6 +2,8 @@ import org.typelevel.sbt.tpolecat.* ThisBuild / organization := "com.example" ThisBuild / scalaVersion := $if(scala3.truthy)$"3.4.0"$else$"2.13.13"$endif$ +// This disables fatal-warnings for local development. To enable it in CI set the `SBT_TPOLECAT_CI` environment variable in your pipeline. +// See https://github.com/typelevel/sbt-tpolecat/?tab=readme-ov-file#modes ThisBuild / tpolecatDefaultOptionsMode := VerboseMode; lazy val root = (project in file(".")).settings( From 97f9fd19e20e16bf15e7a0f32619a506b3d0332c Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Wed, 17 Apr 2024 11:07:22 +0200 Subject: [PATCH 3/5] fix typo Co-authored-by: Antonio Gelameris --- src/main/g8/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index c060a39..761b413 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -4,7 +4,7 @@ ThisBuild / organization := "com.example" ThisBuild / scalaVersion := $if(scala3.truthy)$"3.4.0"$else$"2.13.13"$endif$ // This disables fatal-warnings for local development. To enable it in CI set the `SBT_TPOLECAT_CI` environment variable in your pipeline. // See https://github.com/typelevel/sbt-tpolecat/?tab=readme-ov-file#modes -ThisBuild / tpolecatDefaultOptionsMode := VerboseMode; +ThisBuild / tpolecatDefaultOptionsMode := VerboseMode lazy val root = (project in file(".")).settings( name := "$name;format="norm"$", From 707ad9f4200b011404984ca0204116f2d0224562 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Sun, 21 Apr 2024 11:14:44 +0200 Subject: [PATCH 4/5] Add info about `sbt-tpolecat` to generated README --- src/main/g8/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/g8/README.md b/src/main/g8/README.md index dc597bd..f9e592b 100644 --- a/src/main/g8/README.md +++ b/src/main/g8/README.md @@ -13,3 +13,7 @@ sbt run ```shell sbt test ``` + +## sbt-tpolecat + +This template uses the `sbt-tpolecat` sbt plugin to set Scala compiler options to recommended defaults. If you want to change these defaults or find out about the different modes the plugin can operate in you can find out [here](https://github.com/typelevel/sbt-tpolecat/). From c0fb3463f2f8dd0b4c0166d458b8da4848417b04 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Sun, 21 Apr 2024 11:15:25 +0200 Subject: [PATCH 5/5] Make fatal warnings configurable --- src/main/g8/build.sbt | 4 +++- src/main/g8/default.properties | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 761b413..2c745a3 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -2,9 +2,11 @@ import org.typelevel.sbt.tpolecat.* ThisBuild / organization := "com.example" ThisBuild / scalaVersion := $if(scala3.truthy)$"3.4.0"$else$"2.13.13"$endif$ -// This disables fatal-warnings for local development. To enable it in CI set the `SBT_TPOLECAT_CI` environment variable in your pipeline. + +$if(!use-fatal-warnings.truthy)$// This disables fatal-warnings for local development. To enable it in CI set the `SBT_TPOLECAT_CI` environment variable in your pipeline. // See https://github.com/typelevel/sbt-tpolecat/?tab=readme-ov-file#modes ThisBuild / tpolecatDefaultOptionsMode := VerboseMode +$endif$ lazy val root = (project in file(".")).settings( name := "$name;format="norm"$", diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index 9dbc5e0..0f8dc2b 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -3,3 +3,4 @@ package=com.example scala3 = no testlib-use-munit-cats-effect-3 = yes testlib-use-cats-effect-testing-specs2 = no +use-fatal-warnings = no