diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a217ff6f..d5cb17dd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,10 @@ Previously they'd be named after the **member target**, now they will use the na There's usually only one instance of `EncoderK[F, A]` for a particular `F[_]`, and interpreters don't need to know what `A` is. For convenience, the type parameter has been moved to a type member. +## Remove `smithy4sRenderOptics` setting from SBT and Mill plugins in [#1566](https://github.com/disneystreaming/smithy4s/pull/1566) + +Optics can still be rendered using metadata (global) and traits (selective), the only thing that's been removed is configuration in the build tool. + # Removed `UnknownErrorResponse` in [#1570](https://github.com/disneystreaming/smithy4s/pull/1570) The error type `smithy4s.http.UnknownErrorResponse` has been replaced with `smithy4s.http.RawErrorResponse`, which provides a more accurate description of an error response that failed to decode, including a full representation of the response code, headers, body and the discriminator if one was found. diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/build.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/build.sbt deleted file mode 100644 index 3ada07e61..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/build.sbt +++ /dev/null @@ -1,10 +0,0 @@ -lazy val root = (project in file(".")) - .enablePlugins(Smithy4sCodegenPlugin) - .settings( - scalaVersion := "2.13.10", - Compile / smithy4sRenderOptics := true, - libraryDependencies ++= Seq( - "com.disneystreaming.smithy4s" %% "smithy4s-core" % smithy4sVersion.value, - "com.disneystreaming.smithy4s" %% "smithy4s-dynamic" % smithy4sVersion.value - ) - ) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/build.properties b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/build.properties deleted file mode 100644 index 72413de15..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.8.3 diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/plugins.sbt b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/plugins.sbt deleted file mode 100644 index b8589b92c..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/project/plugins.sbt +++ /dev/null @@ -1,9 +0,0 @@ -sys.props.get("plugin.version") match { - case Some(x) => - addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % x) - case _ => - sys.error( - """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin - ) -} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/scala/Main.scala b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/scala/Main.scala deleted file mode 100644 index 3f7cb448c..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/scala/Main.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2021-2024 Disney Streaming - * - * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://disneystreaming.github.io/TOST-1.0.txt - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package demo - -object Main extends App { - try { - println( - smithy4s.example.TestOptics.optics.one - .get(smithy4s.example.TestOptics(Some("test one"))) - ) - } catch { - case _: java.lang.ExceptionInInitializerError => - println("failed") - sys.exit(1) - } -} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/smithy/optics.smithy b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/smithy/optics.smithy deleted file mode 100644 index 456c4e6e6..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/src/main/smithy/optics.smithy +++ /dev/null @@ -1,5 +0,0 @@ -namespace smithy4s.example - -structure TestOptics { - one: String -} diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/test deleted file mode 100644 index 863293500..000000000 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/optics-generate/test +++ /dev/null @@ -1,2 +0,0 @@ -# check if smithy4sCodegen works and everything compiles -> compile diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index d0d15baae..4d1ccfb2b 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -140,11 +140,6 @@ object Smithy4sCodegenPlugin extends AutoPlugin { "String value to use as wildcard argument in types in generated code" ) - val smithy4sRenderOptics = - taskKey[Boolean]( - "Boolean value to indicate whether or not to generate optics" - ) - val smithy4sGeneratedSmithyFiles = taskKey[Seq[File]]( "Generated smithy files" @@ -259,15 +254,14 @@ object Smithy4sCodegenPlugin extends AutoPlugin { case _ => "_" } }, - config / smithy4sRenderOptics := false, config / smithy4sGeneratedSmithyMetadataFile := { (config / sourceManaged).value / "smithy" / "generated-metadata.smithy" }, config / smithy4sGeneratedSmithyFiles := { val cacheFactory = (config / streams).value.cacheStoreFactory - val cached = Tracked.inputChanged[(String, Boolean), Seq[File]]( + val cached = Tracked.inputChanged[String, Seq[File]]( cacheFactory.make("smithy4sGeneratedSmithyFilesInput") - ) { case (changed, (wildcardArg, shouldGenerateOptics)) => + ) { case (changed, (wildcardArg)) => val lastOutput = Tracked.lastOutput[Boolean, Seq[File]]( cacheFactory.make("smithy4sGeneratedSmithyFilesOutput") ) { case (changed, prevResult) => @@ -278,7 +272,6 @@ object Smithy4sCodegenPlugin extends AutoPlugin { file, s"""$$version: "2" |metadata smithy4sWildcardArgument = "$wildcardArg" - |metadata smithy4sRenderOptics = $shouldGenerateOptics |""".stripMargin ) Seq(file) @@ -289,8 +282,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { lastOutput(changed) } val wildcardArg = (config / smithy4sWildcardArgument).value - val generateOptics = (config / smithy4sRenderOptics).value - cached((wildcardArg, generateOptics)) + cached(wildcardArg) }, config / sourceGenerators += (config / smithy4sCodegen).map( _.filter(_.ext == "scala") diff --git a/modules/docs/markdown/04-codegen/01-customisation/11-optics.md b/modules/docs/markdown/04-codegen/01-customisation/11-optics.md index bf46d4d66..f39c37c6b 100644 --- a/modules/docs/markdown/04-codegen/01-customisation/11-optics.md +++ b/modules/docs/markdown/04-codegen/01-customisation/11-optics.md @@ -5,12 +5,8 @@ title: Optics - Lenses and Prisms Smithy4s has the ability to render optics (Lens/Prism) instances in the code it generates. -If you're using Smithy4s via `mill` or `sbt`, then you can enable this functionality with the following keys: - -* in mill, task: `def smithy4sRenderOptics = true` -* in sbt, setting: `smithy4sRenderOptics := true` - -If you are using Smithy4s via the CLI, then they way to utilize this feature is through your Smithy specifications. The simplest approach is to add a file with the following content to your CLI invocation: +The way to enable this feature is through your Smithy specifications. +The simplest approach is to add a file with the following content to your CLI invocation: ```kotlin $version: "2"