From ef8033bee5890c95c1b44855038909c44c540d66 Mon Sep 17 00:00:00 2001 From: Alessandro Zoffoli Date: Fri, 12 Nov 2021 16:31:54 +0100 Subject: [PATCH 01/21] Add scala 3.1.0 --- .github/workflows/ci.yml | 8 - build.sbt | 10 - ...mage.truthy)$native-image-readme.md$endif$ | 6 - src/main/g8/build.sbt | 9 +- src/main/g8/default.properties | 6 - .../$package__packaged$/reflect-config.json | 180 ------------------ .../$name__Camel$Routes.scala | 9 +- .../$name__Camel$Server.scala | 3 +- .../$package__packaged$/HelloWorld.scala | 18 +- .../scala/$package__packaged$/Jokes.scala | 28 +-- .../main/scala/$package__packaged$/Main.scala | 6 +- .../$package__packaged$/HelloWorldSpec.scala | 6 +- 12 files changed, 27 insertions(+), 262 deletions(-) delete mode 100644 src/main/g8/$if(graal_native_image.truthy)$native-image-readme.md$endif$ delete mode 100644 src/main/g8/src/main/resources/$if(graal_native_image.truthy)$META-INF$endif$/native-image/$package__packaged$/reflect-config.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f87eaa97..89fdbdd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,11 +56,3 @@ jobs: - name: Test generated template run: sbt ++${{ matrix.scala }} g8Test - - - name: Build native assembly - if: startsWith(matrix.java, 'graalvm-') - run: | - cd target/sbt-test/http4s-g8/scripted - sbt assembly - gu install native-image - cat native-image-readme.md | grep 'native-image -H*' | sh diff --git a/build.sbt b/build.sbt index 79cf2959..47b9f5c6 100644 --- a/build.sbt +++ b/build.sbt @@ -6,16 +6,6 @@ ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt( List("g8Test"), name = Some("Test generated template") - ), - WorkflowStep.Run( - List( - "cd target/sbt-test/http4s-g8/scripted", - "sbt assembly", - "gu install native-image", - "cat native-image-readme.md | grep 'native-image -H*' | sh" - ), - cond = Some("startsWith(matrix.java, 'graalvm-')"), - name = Some("Build native assembly") ) ) ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8", "graalvm-ce-java11@") diff --git a/src/main/g8/$if(graal_native_image.truthy)$native-image-readme.md$endif$ b/src/main/g8/$if(graal_native_image.truthy)$native-image-readme.md$endif$ deleted file mode 100644 index e022957d..00000000 --- a/src/main/g8/$if(graal_native_image.truthy)$native-image-readme.md$endif$ +++ /dev/null @@ -1,6 +0,0 @@ -You can build a native-image binary as mentioned in the http4s deployment [section] (https://github.com/drocsid/http4s/blob/docs/deployment/docs/src/main/tut/deployment.md) . You will need to follow the directions there to provide GraalVM / native-image plugin and provide a muslC bundle. Then populate the UseMuslC path with it's location. - -``` -native-image $if(is_linux_build.truthy)$--static -H:UseMuslC="/path.to/muslC"$endif$ -H:+ReportExceptionStackTraces -H:+AddAllCharsets --allow-incomplete-classpath --no-fallback --initialize-at-build-time --enable-http --enable-https --enable-all-security-services --verbose -jar "./target/$scala_assembly_target$/$name$-assembly-0.0.1-SNAPSHOT.jar" $name$BinaryImage -``` - diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 239a8348..521f0673 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,5 +1,4 @@ val Http4sVersion = "$http4s_version$" -val CirceVersion = "$circe_version$" val MunitVersion = "$munit_version$" val LogbackVersion = "$logback_version$" val MunitCatsEffectVersion = "$munit_cats_effect_version$" @@ -9,21 +8,15 @@ lazy val root = (project in file(".")) organization := "$organization$", name := "$name;format="norm"$", version := "0.0.1-SNAPSHOT", - scalaVersion := "$scala_version$", + scalaVersion := "3.1.0", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % Http4sVersion, "org.http4s" %% "http4s-ember-client" % Http4sVersion, "org.http4s" %% "http4s-circe" % Http4sVersion, "org.http4s" %% "http4s-dsl" % Http4sVersion, - "io.circe" %% "circe-generic" % CirceVersion, "org.scalameta" %% "munit" % MunitVersion % Test, "org.typelevel" %% "munit-cats-effect-3" % MunitCatsEffectVersion % Test, "ch.qos.logback" % "logback-classic" % LogbackVersion, - $if(graal_native_image.truthy)$ - "org.scalameta" %% "svm-subs" % "20.2.0" - $endif$ ), - addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.0" cross CrossVersion.full), - addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"), testFrameworks += new TestFramework("munit.Framework") ) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index fdea3724..17055ac0 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -8,14 +8,8 @@ package = $organization$.$name;format="norm,word"$ #http4s_version = maven(org.http4s, http4s-blaze-server_2.12, stable) #logback_version = maven(ch.qos.logback, logback-classic, stable) -scala_version = 2.13.6 sbt_version = 1.5.5 http4s_version = 0.23.6 -circe_version = 0.14.1 logback_version = 1.2.6 munit_version = 0.7.29 munit_cats_effect_version = 1.0.6 -# graal_vm_specific -graal_native_image = true -is_linux_build = false -scala_assembly_target = scala-2.13 diff --git a/src/main/g8/src/main/resources/$if(graal_native_image.truthy)$META-INF$endif$/native-image/$package__packaged$/reflect-config.json b/src/main/g8/src/main/resources/$if(graal_native_image.truthy)$META-INF$endif$/native-image/$package__packaged$/reflect-config.json deleted file mode 100644 index d297bd6a..00000000 --- a/src/main/g8/src/main/resources/$if(graal_native_image.truthy)$META-INF$endif$/native-image/$package__packaged$/reflect-config.json +++ /dev/null @@ -1,180 +0,0 @@ -[ - { - "name": "org.slf4j.impl.StaticLoggerBinder", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.DateConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MessageConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ContextNameConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LoggerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.CyanCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.RedCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.WhiteCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.PropertyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MethodOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LevelConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.IdentityCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MarkerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.RelativeTimeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.MagentaCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LineOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.FileOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LocalSequenceNumberConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.YellowCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.GrayCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.MDCConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BoldRedCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.GreenCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.pattern.color.BlackCompositeConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.ThreadConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.pattern.LineSeparatorConverter", - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.classic.encoder.PatternLayoutEncoder", - "allPublicMethods":true, - "allDeclaredConstructors": true - }, - { - "name": "ch.qos.logback.core.ConsoleAppender", - "allPublicMethods":true, - "allDeclaredConstructors": true - }, - { - "name": "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", - "allDeclaredConstructors": true - } -] diff --git a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala index 7560df86..ac105e6a 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala @@ -5,9 +5,9 @@ import cats.implicits._ import org.http4s.HttpRoutes import org.http4s.dsl.Http4sDsl -object $name;format="Camel"$Routes { +object $name;format="Camel"$Routes: - def jokeRoutes[F[_]: Sync](J: Jokes[F]): HttpRoutes[F] = { + def jokeRoutes[F[_]: Sync](J: Jokes[F]): HttpRoutes[F] = val dsl = new Http4sDsl[F]{} import dsl._ HttpRoutes.of[F] { @@ -17,9 +17,8 @@ object $name;format="Camel"$Routes { resp <- Ok(joke) } yield resp } - } - def helloWorldRoutes[F[_]: Sync](H: HelloWorld[F]): HttpRoutes[F] = { + def helloWorldRoutes[F[_]: Sync](H: HelloWorld[F]): HttpRoutes[F] = val dsl = new Http4sDsl[F]{} import dsl._ HttpRoutes.of[F] { @@ -29,5 +28,3 @@ object $name;format="Camel"$Routes { resp <- Ok(greeting) } yield resp } - } -} \ No newline at end of file diff --git a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala index e6b11d55..7c3f4d55 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala @@ -9,7 +9,7 @@ import org.http4s.ember.server.EmberServerBuilder import org.http4s.implicits._ import org.http4s.server.middleware.Logger -object $name;format="Camel"$Server { +object $name;format="Camel"$Server: def stream[F[_]: Async]: Stream[F, Nothing] = { for { @@ -39,4 +39,3 @@ object $name;format="Camel"$Server { ) } yield exitCode }.drain -} diff --git a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala index 224fba69..83c421e7 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala @@ -6,11 +6,10 @@ import io.circe.{Encoder, Json} import org.http4s.EntityEncoder import org.http4s.circe._ -trait HelloWorld[F[_]]{ +trait HelloWorld[F[_]]: def hello(n: HelloWorld.Name): F[HelloWorld.Greeting] -} -object HelloWorld { +object HelloWorld: implicit def apply[F[_]](implicit ev: HelloWorld[F]): HelloWorld[F] = ev final case class Name(name: String) extends AnyVal @@ -20,18 +19,15 @@ object HelloWorld { * create encoders for your data. **/ final case class Greeting(greeting: String) extends AnyVal - object Greeting { - implicit val greetingEncoder: Encoder[Greeting] = new Encoder[Greeting] { + object Greeting: + given Encoder[Greeting] = new Encoder[Greeting]: final def apply(a: Greeting): Json = Json.obj( ("message", Json.fromString(a.greeting)), ) - } - implicit def greetingEntityEncoder[F[_]]: EntityEncoder[F, Greeting] = + + given [F[_]]: EntityEncoder[F, Greeting] = jsonEncoderOf[F, Greeting] - } - def impl[F[_]: Applicative]: HelloWorld[F] = new HelloWorld[F]{ + def impl[F[_]: Applicative]: HelloWorld[F] = new HelloWorld[F]: def hello(n: HelloWorld.Name): F[HelloWorld.Greeting] = Greeting("Hello, " + n.name).pure[F] - } -} diff --git a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala index edd18b01..601c0add 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala @@ -3,7 +3,6 @@ package $package$ import cats.effect.Concurrent import cats.implicits._ import io.circe.{Encoder, Decoder} -import io.circe.generic.semiauto._ import org.http4s._ import org.http4s.implicits._ import org.http4s.client.Client @@ -11,31 +10,24 @@ import org.http4s.client.dsl.Http4sClientDsl import org.http4s.circe._ import org.http4s.Method._ -trait Jokes[F[_]]{ +trait Jokes[F[_]]: def get: F[Jokes.Joke] -} -object Jokes { +object Jokes: def apply[F[_]](implicit ev: Jokes[F]): Jokes[F] = ev - final case class Joke(joke: String) extends AnyVal - object Joke { - implicit val jokeDecoder: Decoder[Joke] = deriveDecoder[Joke] - implicit def jokeEntityDecoder[F[_]: Concurrent]: EntityDecoder[F, Joke] = - jsonOf - implicit val jokeEncoder: Encoder[Joke] = deriveEncoder[Joke] - implicit def jokeEntityEncoder[F[_]]: EntityEncoder[F, Joke] = - jsonEncoderOf - } + final case class Joke(joke: String) + object Joke: + given Decoder[Joke] = Decoder.derived[Joke] + given [F[_]: Concurrent]: EntityDecoder[F, Joke] = jsonOf + given Encoder[Joke] = Encoder.AsObject.derived[Joke] + given [F[_]]: EntityEncoder[F, Joke] = jsonEncoderOf final case class JokeError(e: Throwable) extends RuntimeException - def impl[F[_]: Concurrent](C: Client[F]): Jokes[F] = new Jokes[F]{ + def impl[F[_]: Concurrent](C: Client[F]): Jokes[F] = new Jokes[F]: val dsl = new Http4sClientDsl[F]{} import dsl._ - def get: F[Jokes.Joke] = { + def get: F[Jokes.Joke] = C.expect[Joke](GET(uri"https://icanhazdadjoke.com/")) .adaptError{ case t => JokeError(t)} // Prevent Client Json Decoding Failure Leaking - } - } -} diff --git a/src/main/g8/src/main/scala/$package__packaged$/Main.scala b/src/main/g8/src/main/scala/$package__packaged$/Main.scala index 3db443c8..982b64f0 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/Main.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/Main.scala @@ -2,7 +2,7 @@ package $package$ import cats.effect.{ExitCode, IO, IOApp} -object Main extends IOApp { - def run(args: List[String]) = +object Main extends IOApp.Simple: + def run: IO[Unit] = $name;format="Camel"$Server.stream[IO].compile.drain.as(ExitCode.Success) -} + diff --git a/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala b/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala index 56d4ba92..dad10e65 100644 --- a/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala +++ b/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala @@ -5,7 +5,7 @@ import org.http4s._ import org.http4s.implicits._ import munit.CatsEffectSuite -class HelloWorldSpec extends CatsEffectSuite { +class HelloWorldSpec extends CatsEffectSuite: test("HelloWorld returns status code 200") { assertIO(retHelloWorld.map(_.status) ,Status.Ok) @@ -15,9 +15,7 @@ class HelloWorldSpec extends CatsEffectSuite { assertIO(retHelloWorld.flatMap(_.as[String]), "{\"message\":\"Hello, world\"}") } - private[this] val retHelloWorld: IO[Response[IO]] = { + private[this] val retHelloWorld: IO[Response[IO]] = val getHW = Request[IO](Method.GET, uri"/hello/world") val helloWorld = HelloWorld.impl[IO] $name;format="Camel"$Routes.helloWorldRoutes(helloWorld).orNotFound(getHW) - } -} \ No newline at end of file From 04dd220c6517226cabfe34c1c34416632dd994ca Mon Sep 17 00:00:00 2001 From: Alessandro Zoffoli Date: Sat, 13 Nov 2021 15:59:13 +0100 Subject: [PATCH 02/21] Using intead of implicit for defining summoners --- src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala | 2 +- src/main/g8/src/main/scala/$package__packaged$/Jokes.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala index 83c421e7..2cd338ee 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala @@ -10,7 +10,7 @@ trait HelloWorld[F[_]]: def hello(n: HelloWorld.Name): F[HelloWorld.Greeting] object HelloWorld: - implicit def apply[F[_]](implicit ev: HelloWorld[F]): HelloWorld[F] = ev + def apply[F[_]](using ev: HelloWorld[F]): HelloWorld[F] = ev final case class Name(name: String) extends AnyVal /** diff --git a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala index 601c0add..b84644f1 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala @@ -14,7 +14,7 @@ trait Jokes[F[_]]: def get: F[Jokes.Joke] object Jokes: - def apply[F[_]](implicit ev: Jokes[F]): Jokes[F] = ev + def apply[F[_]](using ev: Jokes[F]): Jokes[F] = ev final case class Joke(joke: String) object Joke: From adb046f64574b99c317118f0a8d70092985a7d91 Mon Sep 17 00:00:00 2001 From: Alessandro Zoffoli Date: Sat, 13 Nov 2021 16:01:42 +0100 Subject: [PATCH 03/21] Update github workflow --- .github/workflows/ci.yml | 7 ++----- build.sbt | 8 +++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89fdbdd0..34b72794 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,9 @@ jobs: name: Build and Test strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] scala: [2.12.14] - java: [adopt@1.8, graalvm-ce-java11@] - exclude: - - os: macos-latest - java: adopt@1.8 + java: [adopt@1.8, adopt@1.11, adopt@1.15] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) diff --git a/build.sbt b/build.sbt index 47b9f5c6..6d51ab7f 100644 --- a/build.sbt +++ b/build.sbt @@ -8,16 +8,14 @@ ThisBuild / githubWorkflowBuild := Seq( name = Some("Test generated template") ) ) -ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8", "graalvm-ce-java11@") -ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest") -ThisBuild / githubWorkflowBuildMatrixExclusions := Seq(MatrixExclude(Map("os" -> "macos-latest", "java" -> "adopt@1.8"))) +ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8", "adopt@1.11", "adopt@1.15") ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty lazy val root = project.in(file(".")) .settings( name := "http4s-g8", - test in Test := { - val _ = (g8Test in Test).toTask("").value + Test / test := { + val _ = (Test / g8Test).toTask("").value }, scriptedLaunchOpts ++= List("-Xms1024m", "-Xmx1024m", "-XX:ReservedCodeCacheSize=128m", "-Xss2m", "-Dfile.encoding=UTF-8"), resolvers += Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns), From d2fe25df3d8ceb8ac958d65dccc677c951bdc06c Mon Sep 17 00:00:00 2001 From: Justin Reardon Date: Wed, 9 Nov 2022 22:41:27 -0500 Subject: [PATCH 04/21] issue #278: Use F directly instead of Stream --- LICENSE.md | 3 ++- .../$name__Camel$Server.scala | 17 +++++++---------- .../main/scala/$package__packaged$/Main.scala | 4 +--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index c390b317..2ca428c3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,8 @@ -Written in 2017 by +Written in 2017-2022 by Christopher Davenport, chris@christopherdavenport.tech Ross A. Baker, ross@rossabaker.com +Justin Reardon, me@jmreardon.com To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this template to the public domain worldwide. This template is distributed without any warranty. See . diff --git a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala index 7c3f4d55..bd38398b 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala @@ -1,9 +1,8 @@ package $package$ -import cats.effect.{Async, Resource} +import cats.effect.Async import cats.syntax.all._ import com.comcast.ip4s._ -import fs2.Stream import org.http4s.ember.client.EmberClientBuilder import org.http4s.ember.server.EmberServerBuilder import org.http4s.implicits._ @@ -11,9 +10,9 @@ import org.http4s.server.middleware.Logger object $name;format="Camel"$Server: - def stream[F[_]: Async]: Stream[F, Nothing] = { + def run[F[_]: Async]: F[Nothing] = { for { - client <- Stream.resource(EmberClientBuilder.default[F].build) + client <- EmberClientBuilder.default[F].build helloWorldAlg = HelloWorld.impl[F] jokeAlg = Jokes.impl[F](client) @@ -29,13 +28,11 @@ object $name;format="Camel"$Server: // With Middlewares in place finalHttpApp = Logger.httpApp(true, true)(httpApp) - exitCode <- Stream.resource( + _ <- EmberServerBuilder.default[F] .withHost(ipv4"0.0.0.0") .withPort(port"8080") .withHttpApp(finalHttpApp) - .build >> - Resource.eval(Async[F].never) - ) - } yield exitCode - }.drain + .build + } yield () + }.useForever diff --git a/src/main/g8/src/main/scala/$package__packaged$/Main.scala b/src/main/g8/src/main/scala/$package__packaged$/Main.scala index 982b64f0..5539e28f 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/Main.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/Main.scala @@ -3,6 +3,4 @@ package $package$ import cats.effect.{ExitCode, IO, IOApp} object Main extends IOApp.Simple: - def run: IO[Unit] = - $name;format="Camel"$Server.stream[IO].compile.drain.as(ExitCode.Success) - + val run = $name;format="Camel"$Server.run[IO] From d1e34f7137de8a6b72541f34e6d192345e574ca9 Mon Sep 17 00:00:00 2001 From: Justin Reardon Date: Wed, 9 Nov 2022 22:42:10 -0500 Subject: [PATCH 05/21] issue #108: Remove unused apply --- src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala index 2cd338ee..40c65b4c 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala @@ -10,8 +10,6 @@ trait HelloWorld[F[_]]: def hello(n: HelloWorld.Name): F[HelloWorld.Greeting] object HelloWorld: - def apply[F[_]](using ev: HelloWorld[F]): HelloWorld[F] = ev - final case class Name(name: String) extends AnyVal /** * More generally you will want to decouple your edge representations from From 96a219e7286853e15929f825a79048b7c6decc7b Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Tue, 9 May 2023 09:58:23 +0100 Subject: [PATCH 06/21] Update library and plugin versions --- build.sbt | 7 ++++++- project/build.properties | 2 +- project/plugin.sbt | 4 ++-- src/main/g8/build.sbt | 2 +- src/main/g8/default.properties | 8 ++++---- src/main/g8/project/plugins.sbt | 6 +++--- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/build.sbt b/build.sbt index 6d51ab7f..368db279 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,12 @@ ThisBuild / githubWorkflowBuild := Seq( name = Some("Test generated template") ) ) -ThisBuild / githubWorkflowJavaVersions := Seq("adopt@1.8", "adopt@1.11", "adopt@1.15") +ThisBuild / githubWorkflowJavaVersions := Seq( + JavaSpec(JavaSpec.Distribution.Adopt, "8"), + JavaSpec(JavaSpec.Distribution.Adopt, "11"), + JavaSpec(JavaSpec.Distribution.Adopt, "15"), + JavaSpec(JavaSpec.Distribution.Adopt, "17") +) ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty lazy val root = project.in(file(".")) diff --git a/project/build.properties b/project/build.properties index 10fd9eee..46e43a97 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.8.2 diff --git a/project/plugin.sbt b/project/plugin.sbt index 5b52a25a..1f3e4ffd 100644 --- a/project/plugin.sbt +++ b/project/plugin.sbt @@ -1,2 +1,2 @@ -addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "0.13.1") -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.13.0") +addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "0.16.2") +addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 521f0673..bb1a7a66 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -8,7 +8,7 @@ lazy val root = (project in file(".")) organization := "$organization$", name := "$name;format="norm"$", version := "0.0.1-SNAPSHOT", - scalaVersion := "3.1.0", + scalaVersion := "3.2.1", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % Http4sVersion, "org.http4s" %% "http4s-ember-client" % Http4sVersion, diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index 17055ac0..fa988cf2 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -8,8 +8,8 @@ package = $organization$.$name;format="norm,word"$ #http4s_version = maven(org.http4s, http4s-blaze-server_2.12, stable) #logback_version = maven(ch.qos.logback, logback-classic, stable) -sbt_version = 1.5.5 -http4s_version = 0.23.6 -logback_version = 1.2.6 +sbt_version = 1.8.2 +http4s_version = 0.23.19-RC3 +logback_version = 1.4.7 munit_version = 0.7.29 -munit_cats_effect_version = 1.0.6 +munit_cats_effect_version = 1.0.7 diff --git a/src/main/g8/project/plugins.sbt b/src/main/g8/project/plugins.sbt index 6cd6d397..8734714e 100644 --- a/src/main/g8/project/plugins.sbt +++ b/src/main/g8/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.14") -addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") +addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.2") +addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1") From a91af72c5d2b87d88bbd6be8d501cb1360ab1b06 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Tue, 9 May 2023 10:05:29 +0100 Subject: [PATCH 07/21] Add jdk 1.17 to ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b72794..0b723b27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: matrix: os: [ubuntu-latest] scala: [2.12.14] - java: [adopt@1.8, adopt@1.11, adopt@1.15] + java: [adopt@1.8, adopt@1.11, adopt@1.15, adopt@1.17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) From 2ca3ade627d92b031b74848305a4f1a94965d451 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Tue, 9 May 2023 17:17:54 +0100 Subject: [PATCH 08/21] Update scala to 3.2.2 Co-authored-by: Arman Bilge --- 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 bb1a7a66..6ef3f388 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -8,7 +8,7 @@ lazy val root = (project in file(".")) organization := "$organization$", name := "$name;format="norm"$", version := "0.0.1-SNAPSHOT", - scalaVersion := "3.2.1", + scalaVersion := "3.2.2", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % Http4sVersion, "org.http4s" %% "http4s-ember-client" % Http4sVersion, From b56ca86ce996eb28626b1ee7409e275562592c7f Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Tue, 9 May 2023 17:18:28 +0100 Subject: [PATCH 09/21] Use http4s 0.23.18 Co-authored-by: Arman Bilge --- src/main/g8/default.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index fa988cf2..87588fa6 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -9,7 +9,7 @@ package = $organization$.$name;format="norm,word"$ #logback_version = maven(ch.qos.logback, logback-classic, stable) sbt_version = 1.8.2 -http4s_version = 0.23.19-RC3 +http4s_version = 0.23.18 logback_version = 1.4.7 munit_version = 0.7.29 munit_cats_effect_version = 1.0.7 From 3394d9df5963ccceac2a497d0c1b5fb96b6cf81e Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Tue, 9 May 2023 17:18:48 +0100 Subject: [PATCH 10/21] Remove JDK 15 as it is not LTS --- build.sbt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 368db279..8b253d18 100644 --- a/build.sbt +++ b/build.sbt @@ -3,25 +3,31 @@ // See http://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin for more details. ThisBuild / githubWorkflowBuild := Seq( - WorkflowStep.Sbt( - List("g8Test"), - name = Some("Test generated template") - ) + WorkflowStep.Sbt(List("g8Test"), name = Some("Test generated template")) ) ThisBuild / githubWorkflowJavaVersions := Seq( JavaSpec(JavaSpec.Distribution.Adopt, "8"), JavaSpec(JavaSpec.Distribution.Adopt, "11"), - JavaSpec(JavaSpec.Distribution.Adopt, "15"), JavaSpec(JavaSpec.Distribution.Adopt, "17") ) ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty -lazy val root = project.in(file(".")) +lazy val root = project + .in(file(".")) .settings( name := "http4s-g8", Test / test := { val _ = (Test / g8Test).toTask("").value }, - scriptedLaunchOpts ++= List("-Xms1024m", "-Xmx1024m", "-XX:ReservedCodeCacheSize=128m", "-Xss2m", "-Dfile.encoding=UTF-8"), - resolvers += Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns), + scriptedLaunchOpts ++= List( + "-Xms1024m", + "-Xmx1024m", + "-XX:ReservedCodeCacheSize=128m", + "-Xss2m", + "-Dfile.encoding=UTF-8" + ), + resolvers += Resolver.url( + "typesafe", + url("https://repo.typesafe.com/typesafe/ivy-releases/") + )(Resolver.ivyStylePatterns), ) From d25eb6330761832b87c2416e70bf8d31bdbb7ad3 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Wed, 10 May 2023 09:14:06 +0100 Subject: [PATCH 11/21] Use sbt-typelevel-github-actions --- build.sbt | 6 +++--- project/plugin.sbt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 8b253d18..619da396 100644 --- a/build.sbt +++ b/build.sbt @@ -6,9 +6,9 @@ ThisBuild / githubWorkflowBuild := Seq( WorkflowStep.Sbt(List("g8Test"), name = Some("Test generated template")) ) ThisBuild / githubWorkflowJavaVersions := Seq( - JavaSpec(JavaSpec.Distribution.Adopt, "8"), - JavaSpec(JavaSpec.Distribution.Adopt, "11"), - JavaSpec(JavaSpec.Distribution.Adopt, "17") + JavaSpec.temurin("8"), + JavaSpec.temurin("11"), + JavaSpec.temurin("17") ) ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty diff --git a/project/plugin.sbt b/project/plugin.sbt index 1f3e4ffd..d67ef23f 100644 --- a/project/plugin.sbt +++ b/project/plugin.sbt @@ -1,2 +1,2 @@ addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "0.16.2") -addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2") +addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.4.20") From f66f40c2d9f4605f5a7ff0a1198ae3bca8ef2ed1 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Wed, 10 May 2023 14:25:19 +0100 Subject: [PATCH 12/21] remove JDK 15 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b723b27..7c0d8651 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: matrix: os: [ubuntu-latest] scala: [2.12.14] - java: [adopt@1.8, adopt@1.11, adopt@1.15, adopt@1.17] + java: [adopt@1.8, adopt@1.11, adopt@1.17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) From 00386fc3834aefd1bf702e3d94c53451fabd8410 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Wed, 10 May 2023 14:28:45 +0100 Subject: [PATCH 13/21] use temurin in GHA --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c0d8651..8d53ac21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: matrix: os: [ubuntu-latest] scala: [2.12.14] - java: [adopt@1.8, adopt@1.11, adopt@1.17] + java: [temurin@8, temurin@11, temurin@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) From 1afa855bff31d57eb6dab23dc136db0081b5d3e9 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Wed, 10 May 2023 20:34:53 +0100 Subject: [PATCH 14/21] Upgrade GH actions --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d53ac21..817ec7d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,22 +22,22 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [2.12.14] + scala: [2.12.17] java: [temurin@8, temurin@11, temurin@17] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup Java and Scala - uses: olafurpg/setup-scala@v13 + uses: actions/setup-java@v3 with: java-version: ${{ matrix.java }} - name: Cache sbt - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ~/.sbt From f3451254ce33ac4d5667e458a55356ed4de1872d Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Thu, 11 May 2023 10:27:25 +0100 Subject: [PATCH 15/21] Generate the ci.yml properly --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 817ec7d9..0edc58fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,10 +31,53 @@ jobs: with: fetch-depth: 0 - - name: Setup Java and Scala + - name: Download Java (temurin@8) + id: download-java-temurin-8 + if: matrix.java == 'temurin@8' + uses: typelevel/download-java@v2 + with: + distribution: temurin + java-version: 8 + + - name: Setup Java (temurin@8) + if: matrix.java == 'temurin@8' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 8 + jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }} + + - name: Download Java (temurin@11) + id: download-java-temurin-11 + if: matrix.java == 'temurin@11' + uses: typelevel/download-java@v2 + with: + distribution: temurin + java-version: 11 + + - name: Setup Java (temurin@11) + if: matrix.java == 'temurin@11' + uses: actions/setup-java@v3 + with: + distribution: jdkfile + java-version: 11 + jdkFile: ${{ steps.download-java-temurin-11.outputs.jdkFile }} + + - name: Download Java (temurin@17) + id: download-java-temurin-17 + if: matrix.java == 'temurin@17' + uses: typelevel/download-java@v2 + with: + distribution: temurin + java-version: 17 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' uses: actions/setup-java@v3 with: - java-version: ${{ matrix.java }} + distribution: jdkfile + java-version: 17 + jdkFile: ${{ steps.download-java-temurin-17.outputs.jdkFile }} - name: Cache sbt uses: actions/cache@v3 @@ -49,7 +92,7 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Check that workflows are up to date - run: sbt ++${{ matrix.scala }} githubWorkflowCheck + run: sbt githubWorkflowCheck - name: Test generated template - run: sbt ++${{ matrix.scala }} g8Test + run: sbt '++ ${{ matrix.scala }}' g8Test From 8340e47c3df0641fe8b8f498570c4d916c8d314a Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Sat, 13 May 2023 19:36:42 +0100 Subject: [PATCH 16/21] Update sbt and plugins --- project/build.properties | 2 +- project/plugin.sbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index 46e43a97..72413de1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.8.2 +sbt.version=1.8.3 diff --git a/project/plugin.sbt b/project/plugin.sbt index d67ef23f..27c39a08 100644 --- a/project/plugin.sbt +++ b/project/plugin.sbt @@ -1,2 +1,2 @@ addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8" % "0.16.2") -addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.4.20") +addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.4.21") From 629a7095ab23e54d9b946e930aa0cef887d631d5 Mon Sep 17 00:00:00 2001 From: Channing Walton Date: Sat, 13 May 2023 19:53:06 +0100 Subject: [PATCH 17/21] Update http4s and syntax --- src/main/g8/default.properties | 4 ++-- .../$package__packaged$/$name__Camel$Routes.scala | 6 +++--- .../$package__packaged$/$name__Camel$Server.scala | 9 +++++---- .../main/scala/$package__packaged$/HelloWorld.scala | 4 ++-- .../src/main/scala/$package__packaged$/Jokes.scala | 12 ++++++------ .../scala/$package__packaged$/HelloWorldSpec.scala | 4 ++-- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index 87588fa6..1ca471a2 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -8,8 +8,8 @@ package = $organization$.$name;format="norm,word"$ #http4s_version = maven(org.http4s, http4s-blaze-server_2.12, stable) #logback_version = maven(ch.qos.logback, logback-classic, stable) -sbt_version = 1.8.2 -http4s_version = 0.23.18 +sbt_version = 1.8.3 +http4s_version = 0.23.19 logback_version = 1.4.7 munit_version = 0.7.29 munit_cats_effect_version = 1.0.7 diff --git a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala index ac105e6a..f25c1102 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Routes.scala @@ -1,7 +1,7 @@ package $package$ import cats.effect.Sync -import cats.implicits._ +import cats.syntax.all.* import org.http4s.HttpRoutes import org.http4s.dsl.Http4sDsl @@ -9,7 +9,7 @@ object $name;format="Camel"$Routes: def jokeRoutes[F[_]: Sync](J: Jokes[F]): HttpRoutes[F] = val dsl = new Http4sDsl[F]{} - import dsl._ + import dsl.* HttpRoutes.of[F] { case GET -> Root / "joke" => for { @@ -20,7 +20,7 @@ object $name;format="Camel"$Routes: def helloWorldRoutes[F[_]: Sync](H: HelloWorld[F]): HttpRoutes[F] = val dsl = new Http4sDsl[F]{} - import dsl._ + import dsl.* HttpRoutes.of[F] { case GET -> Root / "hello" / name => for { diff --git a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala index bd38398b..d2403fb9 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/$name__Camel$Server.scala @@ -1,16 +1,17 @@ package $package$ import cats.effect.Async -import cats.syntax.all._ -import com.comcast.ip4s._ +import cats.syntax.all.* +import com.comcast.ip4s.* +import fs2.io.net.Network import org.http4s.ember.client.EmberClientBuilder import org.http4s.ember.server.EmberServerBuilder -import org.http4s.implicits._ +import org.http4s.implicits.* import org.http4s.server.middleware.Logger object $name;format="Camel"$Server: - def run[F[_]: Async]: F[Nothing] = { + def run[F[_]: Async: Network]: F[Nothing] = { for { client <- EmberClientBuilder.default[F].build helloWorldAlg = HelloWorld.impl[F] diff --git a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala index 40c65b4c..65bee056 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/HelloWorld.scala @@ -1,10 +1,10 @@ package $package$ import cats.Applicative -import cats.implicits._ +import cats.syntax.all.* import io.circe.{Encoder, Json} import org.http4s.EntityEncoder -import org.http4s.circe._ +import org.http4s.circe.* trait HelloWorld[F[_]]: def hello(n: HelloWorld.Name): F[HelloWorld.Greeting] diff --git a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala index b84644f1..88af5110 100644 --- a/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala +++ b/src/main/g8/src/main/scala/$package__packaged$/Jokes.scala @@ -1,14 +1,14 @@ package $package$ import cats.effect.Concurrent -import cats.implicits._ +import cats.syntax.all.* import io.circe.{Encoder, Decoder} -import org.http4s._ -import org.http4s.implicits._ +import org.http4s.* +import org.http4s.implicits.* import org.http4s.client.Client import org.http4s.client.dsl.Http4sClientDsl -import org.http4s.circe._ -import org.http4s.Method._ +import org.http4s.circe.* +import org.http4s.Method.* trait Jokes[F[_]]: def get: F[Jokes.Joke] @@ -27,7 +27,7 @@ object Jokes: def impl[F[_]: Concurrent](C: Client[F]): Jokes[F] = new Jokes[F]: val dsl = new Http4sClientDsl[F]{} - import dsl._ + import dsl.* def get: F[Jokes.Joke] = C.expect[Joke](GET(uri"https://icanhazdadjoke.com/")) .adaptError{ case t => JokeError(t)} // Prevent Client Json Decoding Failure Leaking diff --git a/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala b/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala index dad10e65..a50a89ff 100644 --- a/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala +++ b/src/main/g8/src/test/scala/$package__packaged$/HelloWorldSpec.scala @@ -1,8 +1,8 @@ package $package$ import cats.effect.IO -import org.http4s._ -import org.http4s.implicits._ +import org.http4s.* +import org.http4s.implicits.* import munit.CatsEffectSuite class HelloWorldSpec extends CatsEffectSuite: From 5b517aa19eb685bdd985c873d423a7ae67e5f447 Mon Sep 17 00:00:00 2001 From: Fred Roth Date: Tue, 13 Jun 2023 14:15:20 +0200 Subject: [PATCH 18/21] Update dependency versions --- src/main/g8/build.sbt | 2 +- src/main/g8/default.properties | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/g8/build.sbt b/src/main/g8/build.sbt index 6ef3f388..0371d777 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -8,7 +8,7 @@ lazy val root = (project in file(".")) organization := "$organization$", name := "$name;format="norm"$", version := "0.0.1-SNAPSHOT", - scalaVersion := "3.2.2", + scalaVersion := "3.3.0", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % Http4sVersion, "org.http4s" %% "http4s-ember-client" % Http4sVersion, diff --git a/src/main/g8/default.properties b/src/main/g8/default.properties index 1ca471a2..4e70b15c 100644 --- a/src/main/g8/default.properties +++ b/src/main/g8/default.properties @@ -8,8 +8,8 @@ package = $organization$.$name;format="norm,word"$ #http4s_version = maven(org.http4s, http4s-blaze-server_2.12, stable) #logback_version = maven(ch.qos.logback, logback-classic, stable) -sbt_version = 1.8.3 -http4s_version = 0.23.19 -logback_version = 1.4.7 +sbt_version = 1.9.0 +http4s_version = 0.23.20 +logback_version = 1.4.8 munit_version = 0.7.29 munit_cats_effect_version = 1.0.7 From d21455ec72d3647df57111fe4f2dc4a8b45e33d9 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Mon, 29 Apr 2024 15:07:03 +0200 Subject: [PATCH 19/21] Update to current scala3 LTS --- 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 86fff03f..76fc4de8 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -9,7 +9,7 @@ lazy val root = (project in file(".")) organization := "$organization$", name := "$name;format="norm"$", version := "0.0.1-SNAPSHOT", - scalaVersion := "3.3.0", + scalaVersion := "3.3.3", libraryDependencies ++= Seq( "org.http4s" %% "http4s-ember-server" % Http4sVersion, "org.http4s" %% "http4s-ember-client" % Http4sVersion, From ac2eb66314648c0bbf1cfe6bbca9f1b3cf65bf90 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Sun, 5 May 2024 14:47:12 +0200 Subject: [PATCH 20/21] update http4s version Co-authored-by: Daniel Esik --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 61353565..436f740c 100644 --- a/build.sbt +++ b/build.sbt @@ -26,7 +26,7 @@ ThisBuild / githubWorkflowJavaVersions := Seq( ) ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty -val Http4sVersion = "0.23.26" +val Http4sVersion = "0.23.27" val CirceVersion = "0.14.7" val MunitVersion = "0.7.29" val LogbackVersion = "1.5.6" From e70b8ea85ec748049f410f00052a90396eab1a76 Mon Sep 17 00:00:00 2001 From: Frederick Roth Date: Sun, 5 May 2024 14:47:22 +0200 Subject: [PATCH 21/21] update http4s version Co-authored-by: Daniel Esik --- 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 76fc4de8..095e233c 100644 --- a/src/main/g8/build.sbt +++ b/src/main/g8/build.sbt @@ -1,4 +1,4 @@ -val Http4sVersion = "0.23.26" +val Http4sVersion = "0.23.27" val CirceVersion = "0.14.7" val MunitVersion = "0.7.29" val LogbackVersion = "1.5.6"