From 5676ee490c54c0e26e4574778287a71150767906 Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Wed, 18 May 2022 16:01:46 +0200 Subject: [PATCH 01/11] Rewrite the model loading logic to avoid having to depend on publishLocal --- build.sbt | 3 --- .../src/smithy4s/codegen/CodegenPlugin.scala | 2 +- .../src/smithy4s/codegen/ModelLoader.scala | 19 +++++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index aff4c6cbc..74075f1ce 100644 --- a/build.sbt +++ b/build.sbt @@ -726,9 +726,6 @@ def genSmithyResources(config: Configuration) = genSmithyImpl(config).map(_._2) * library code, aws-specific code. */ def genSmithyImpl(config: Configuration) = Def.task { - // codegen needs the `protocol` jar to be published - (protocol.jvm(autoScalaLibrary = false) / publishLocal).value - val inputFiles = (config / smithySpecs).value val outputDir = (config / genSmithyOutput).?.value .getOrElse((config / sourceManaged).value) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala index aa6e5c3c5..f57df6a76 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala @@ -149,7 +149,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { val out = streams.value val cacheFile = out.cacheDirectory / s"smithy4s_${scalaBinaryVersion.value}" - + // This is important - it's what re-triggers this task on file changes val _ = (conf / smithy4sCodegen).inputFileChanges diff --git a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala index a6446c841..6dc6452bd 100644 --- a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala @@ -28,10 +28,6 @@ import java.net.URL import java.net.URLClassLoader object ModelLoader { - private val requiredDeps = - s"${smithy4s.codegen.BuildInfo.organization}:${smithy4s.codegen.BuildInfo.protocolArtifact}:${smithy4s.codegen.BuildInfo.version}" :: - s"${smithy4s.codegen.BuildInfo.smithyOrg}:${smithy4s.codegen.BuildInfo.smithyArtifact}:${smithy4s.codegen.BuildInfo.smithyVersion}" :: - Nil def load( specs: Set[File], @@ -39,7 +35,7 @@ object ModelLoader { repositories: List[String], transformers: List[String] ): (ClassLoader, Model) = { - val allDeps = dependencies ++ requiredDeps + val allDeps = dependencies val maybeDeps = resolveDependencies(allDeps, repositories) val currentClassLoader = this.getClass().getClassLoader() @@ -47,12 +43,19 @@ object ModelLoader { // might be provided by smithy4s itself out of the box) val modelBuilder = Model.builder() + val smithy4sResource = + currentClassLoader.getResource("META-INF/smithy/smithy4s.smithy") + val smithy4sMetaResource = + currentClassLoader.getResource("META-INF/smithy/smithy4s.meta.smithy") + maybeDeps.foreach { deps => // Loading the model just from upstream dependencies, in isolation val upstreamClassLoader = new URLClassLoader(deps) val upstreamModel = Model .assembler() .discoverModels(upstreamClassLoader) + .addImport(smithy4sResource) + .addImport(smithy4sMetaResource) .assemble() .unwrap() @@ -69,7 +72,11 @@ object ModelLoader { } val modelAssembler = - Model.assembler(validatorClassLoader).addModel(modelBuilder.build()) + Model + .assembler(validatorClassLoader) + .addImport(smithy4sResource) + .addImport(smithy4sMetaResource) + .addModel(modelBuilder.build()) specs.map(_.toPath()).foreach { modelAssembler.addImport From c923edb3312885daf5f72047ac46859a296a2695 Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Wed, 18 May 2022 17:03:12 +0200 Subject: [PATCH 02/11] Pivoted the solution to a mere surfacing of the `discoverModels` option --- build.sbt | 30 +++++++++------- .../smithy4s/codegen/cli/CodegenCommand.scala | 13 ++++++- .../src/smithy4s/codegen/cli/DumpModel.scala | 3 +- .../src/smithy4s/codegen/CodegenPlugin.scala | 1 + .../src/smithy4s/codegen/Codegen.scala | 3 +- .../src/smithy4s/codegen/CodegenArgs.scala | 1 + .../src/smithy4s/codegen/ModelLoader.scala | 35 +++++++++++++------ 7 files changed, 60 insertions(+), 26 deletions(-) diff --git a/build.sbt b/build.sbt index 74075f1ce..c296493be 100644 --- a/build.sbt +++ b/build.sbt @@ -113,6 +113,8 @@ lazy val core = projectMatrix "smithy.waiters", "smithy4s.api" ), + genDiscoverModels := true, + Test / genDiscoverModels := false, Compile / sourceGenerators := Seq(genSmithyScala(Compile).taskValue), Compile / sourceGenerators += sourceDirectory .map(Boilerplate.gen(_, Boilerplate.BoilerplateModule.Core)) @@ -139,18 +141,17 @@ lazy val core = projectMatrix (ThisBuild / baseDirectory).value / "sampleSpecs" / "adtMember.smithy" ), (Test / sourceGenerators) := Seq(genSmithyScala(Test).taskValue), - testFrameworks += new TestFramework("weaver.framework.CatsEffect") - // TODO: bring back - // Compile / packageSrc / mappings ++= { - // val base = (Compile / sourceManaged).value - // val files = (Compile / managedSources).value - // files.map(f => - // ( - // f, - // f.relativeTo(base).get.getPath - // ) - // ) - // } + testFrameworks += new TestFramework("weaver.framework.CatsEffect"), + Compile / packageSrc / mappings ++= { + val base = (Compile / sourceManaged).value + val files = (Compile / managedSources).value + files.map(f => + ( + f, + f.relativeTo(base).get.getPath + ) + ) + } ) .jvmPlatform(allJvmScalaVersions, jvmDimSettings) .jsPlatform(allJsScalaVersions, jsDimSettings) @@ -191,6 +192,7 @@ lazy val `aws-kernel` = projectMatrix Dependencies.Weaver.scalacheck.value % Test ), testFrameworks += new TestFramework("weaver.framework.CatsEffect"), + genDiscoverModels := true, Compile / allowedNamespaces := Seq( "aws.api", "aws.auth", @@ -715,6 +717,7 @@ lazy val genSmithyOpenapiOutput = SettingKey[File]("genSmithyOpenapiOutput") lazy val allowedNamespaces = SettingKey[Seq[String]]("allowedNamespaces") lazy val genSmithyDependencies = SettingKey[Seq[String]]("genSmithyDependencies") +lazy val genDiscoverModels = SettingKey[Boolean]("genDiscoverModels") (ThisBuild / smithySpecs) := Seq.empty @@ -737,6 +740,8 @@ def genSmithyImpl(config: Configuration) = Def.task { val allowedNS = (config / allowedNamespaces).?.value.filterNot(_.isEmpty) val smithyDeps = (config / genSmithyDependencies).?.value.getOrElse(List.empty) + val discoverModels = + (config / genDiscoverModels).?.value.getOrElse(false) val codegenCp = (`codegen-cli`.jvm(Smithy4sPlugin.Scala213) / Compile / fullClasspath).value @@ -761,6 +766,7 @@ def genSmithyImpl(config: Configuration) = Def.task { val args = List("--output", outputDir) ++ List("--openapi-output", openapiOutputDir) ++ + (if (discoverModels) List("--discover-models") else Nil) ++ (if (allowedNS.isDefined) List("--allowed-ns", allowedNS.get.mkString(",")) else Nil) ++ inputs diff --git a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala index 82fe64e38..74a543898 100644 --- a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala +++ b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala @@ -69,6 +69,15 @@ object CodegenCommand { ) .orFalse + val discoverModelsOpt = + Opts + .flag( + long = "discover-models", + help = + "Indicates whether the model assembler should try to discover models in the classpath" + ) + .orFalse + val allowedNSOpt: Opts[Option[Set[String]]] = Opts .option[String]( @@ -93,6 +102,7 @@ object CodegenCommand { openApiOutputOpt, skipScalaOpt, skipOpenapiOpt, + discoverModelsOpt, allowedNSOpt, excludedNSOpt, repositoriesOpt, @@ -102,7 +112,7 @@ object CodegenCommand { ) .mapN { // format: off - case (output, openApiOutput, skipScala, skipOpenapi, allowedNS, excludedNS, repositories, dependencies, transformers, specsArgs) => + case (output, openApiOutput, skipScala, skipOpenapi, discoverModels, allowedNS, excludedNS, repositories, dependencies, transformers, specsArgs) => // format: on CodegenArgs( specsArgs, @@ -110,6 +120,7 @@ object CodegenCommand { openApiOutput.getOrElse(os.pwd), skipScala, skipOpenapi, + discoverModels, allowedNS, excludedNS, repositories.getOrElse(List.empty), diff --git a/modules/codegen-cli/src/smithy4s/codegen/cli/DumpModel.scala b/modules/codegen-cli/src/smithy4s/codegen/cli/DumpModel.scala index 5423c611e..6bd846500 100644 --- a/modules/codegen-cli/src/smithy4s/codegen/cli/DumpModel.scala +++ b/modules/codegen-cli/src/smithy4s/codegen/cli/DumpModel.scala @@ -26,7 +26,8 @@ object DumpModel { args.specs.map(_.toIO).toSet, args.dependencies, args.repositories, - args.transformers + args.transformers, + discoverModels = false ) Node.prettyPrintJson(ModelSerializer.builder().build.serialize(model)) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala index f57df6a76..629d6d702 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala @@ -169,6 +169,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { openapiOutput = os.Path(openApiOutputPath), skipScala = false, skipOpenapi = false, + discoverModels = false, allowedNS = allowedNamespaces, excludedNS = excludedNamespaces, repositories = res, diff --git a/modules/codegen/src/smithy4s/codegen/Codegen.scala b/modules/codegen/src/smithy4s/codegen/Codegen.scala index 89488d2f4..558f8cd14 100644 --- a/modules/codegen/src/smithy4s/codegen/Codegen.scala +++ b/modules/codegen/src/smithy4s/codegen/Codegen.scala @@ -31,7 +31,8 @@ object Codegen { self => args.specs.map(_.toIO).toSet, args.dependencies, args.repositories, - args.transformers + args.transformers, + args.discoverModels ) val scalaFiles = if (!args.skipScala) { diff --git a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala index 7cb2a2089..552990647 100644 --- a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala +++ b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala @@ -22,6 +22,7 @@ case class CodegenArgs( openapiOutput: os.Path, skipScala: Boolean, skipOpenapi: Boolean, + discoverModels: Boolean, allowedNS: Option[Set[String]], excludedNS: Option[Set[String]], repositories: List[String], diff --git a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala index 6dc6452bd..ec0d159d3 100644 --- a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala @@ -22,6 +22,7 @@ import coursier.parse.RepositoryParser import software.amazon.smithy.build.ProjectionTransformer import software.amazon.smithy.build.TransformContext import software.amazon.smithy.model.Model +import software.amazon.smithy.model.loader.ModelAssembler import java.io.File import java.net.URL @@ -33,7 +34,8 @@ object ModelLoader { specs: Set[File], dependencies: List[String], repositories: List[String], - transformers: List[String] + transformers: List[String], + discoverModels: Boolean ): (ClassLoader, Model) = { val allDeps = dependencies val maybeDeps = resolveDependencies(allDeps, repositories) @@ -41,12 +43,12 @@ object ModelLoader { // Loads a model using whatever's on the current classpath (in particular, anything that // might be provided by smithy4s itself out of the box) - val modelBuilder = Model.builder() - - val smithy4sResource = - currentClassLoader.getResource("META-INF/smithy/smithy4s.smithy") - val smithy4sMetaResource = - currentClassLoader.getResource("META-INF/smithy/smithy4s.meta.smithy") + val modelBuilder = Model + .assembler() + .maybeDiscoverModels(currentClassLoader, discoverModels) + .assemble() + .unwrap() + .toBuilder() maybeDeps.foreach { deps => // Loading the model just from upstream dependencies, in isolation @@ -54,8 +56,6 @@ object ModelLoader { val upstreamModel = Model .assembler() .discoverModels(upstreamClassLoader) - .addImport(smithy4sResource) - .addImport(smithy4sMetaResource) .assemble() .unwrap() @@ -74,8 +74,6 @@ object ModelLoader { val modelAssembler = Model .assembler(validatorClassLoader) - .addImport(smithy4sResource) - .addImport(smithy4sMetaResource) .addModel(modelBuilder.build()) specs.map(_.toPath()).foreach { @@ -134,4 +132,19 @@ object ModelLoader { else None } + implicit class ModelAssemblerOps(assembler: ModelAssembler) { + def addImports(urls: List[java.net.URL]): ModelAssembler = { + urls.foreach(assembler.addImport) + assembler + } + + def maybeDiscoverModels( + classLoader: ClassLoader, + flag: Boolean + ): ModelAssembler = { + if (flag) assembler.discoverModels(classLoader) + else assembler + } + } + } From 78444eb0d15a349a68ddc4d855067773e8b1316e Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Wed, 18 May 2022 12:27:04 -0400 Subject: [PATCH 03/11] Remove unused build info keys --- build.sbt | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index c296493be..34b5099e4 100644 --- a/build.sbt +++ b/build.sbt @@ -273,16 +273,7 @@ lazy val codegen = projectMatrix .dependsOn(openapi) .jvmPlatform(buildtimejvmScala2Versions, jvmDimSettings) .settings( - buildInfoKeys := Seq[BuildInfoKey]( - organization, - version, - scalaBinaryVersion, - "protocolArtifact" -> (protocol - .jvm(autoScalaLibrary = false) / moduleName).value, - "smithyOrg" -> Dependencies.Smithy.model.organization, - "smithyVersion" -> Dependencies.Smithy.model.revision, - "smithyArtifact" -> Dependencies.Smithy.model.name - ), + buildInfoKeys := Seq[BuildInfoKey](version, scalaBinaryVersion), buildInfoPackage := "smithy4s.codegen", isCE3 := true, libraryDependencies ++= Seq( From f4cac2fff6491a0fa38970cf4811602c27a274d0 Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Wed, 18 May 2022 12:51:13 -0400 Subject: [PATCH 04/11] Added a few `genDiscoverModels := true` here and there --- build.sbt | 6 +++++- .../test/src/smithy4s/codegen/cli/CommandParsingSpec.scala | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 34b5099e4..f3f5b79f4 100644 --- a/build.sbt +++ b/build.sbt @@ -114,7 +114,7 @@ lazy val core = projectMatrix "smithy4s.api" ), genDiscoverModels := true, - Test / genDiscoverModels := false, + Test / genDiscoverModels := true, Compile / sourceGenerators := Seq(genSmithyScala(Compile).taskValue), Compile / sourceGenerators += sourceDirectory .map(Boilerplate.gen(_, Boilerplate.BoilerplateModule.Core)) @@ -248,6 +248,7 @@ lazy val `aws-http4s` = projectMatrix .dependsOn(aws) .settings( isCE3 := true, + genDiscoverModels := true, libraryDependencies ++= { Seq( Dependencies.Http4s.client.value, @@ -389,6 +390,7 @@ lazy val dynamic = projectMatrix .dependsOn(core) .settings( isCE3 := true, + genDiscoverModels := true, libraryDependencies ++= Seq( "org.scala-lang.modules" %%% "scala-collection-compat" % "2.7.0", Dependencies.Cats.core.value, @@ -518,6 +520,7 @@ lazy val tests = projectMatrix .in(file("modules/tests")) .dependsOn(core) .settings( + genDiscoverModels := true, isCE3 := virtualAxes.value.contains(CatsEffect3Axis), libraryDependencies ++= { val ce3 = @@ -556,6 +559,7 @@ lazy val example = projectMatrix .disablePlugins(ScalafixPlugin) .disablePlugins(HeaderPlugin) .settings( + genDiscoverModels := true, Compile / allowedNamespaces := Seq( "smithy4s.example", "smithy4s.example.import_test", diff --git a/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala b/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala index b2a479ecb..bfb7ad399 100644 --- a/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala +++ b/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala @@ -31,6 +31,7 @@ object CommandParsingSpec extends FunSuite { openapiOutput = os.pwd, skipScala = false, skipOpenapi = false, + discoverModels = false, allowedNS = None, excludedNS = None, repositories = Nil, @@ -77,6 +78,7 @@ object CommandParsingSpec extends FunSuite { openapiOutput = os.pwd / "target" / "openapi", skipScala = true, skipOpenapi = true, + discoverModels = false, allowedNS = Some(Set("name1", "name2")), excludedNS = None, repositories = List("repo1", "repo2"), From fde0bc338a0055c697030f4ba1c3f1c12ab0122b Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Wed, 18 May 2022 12:57:17 -0400 Subject: [PATCH 05/11] Added another one for docs --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index f3f5b79f4..441dbc2f0 100644 --- a/build.sbt +++ b/build.sbt @@ -79,6 +79,7 @@ lazy val docs = "HTTP4S_VERSION" -> Dependencies.Http4s.http4sVersion.value ), isCE3 := true, + genDiscoverModels := true, libraryDependencies ++= Seq( Dependencies.Http4s.emberClient.value, Dependencies.Http4s.emberServer.value From b818e07e636beeeac4f3c35a84912331e6f11873 Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Wed, 18 May 2022 13:19:50 -0400 Subject: [PATCH 06/11] Filtering out generated source that are checked in --- build.sbt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 441dbc2f0..4855c64c9 100644 --- a/build.sbt +++ b/build.sbt @@ -146,12 +146,10 @@ lazy val core = projectMatrix Compile / packageSrc / mappings ++= { val base = (Compile / sourceManaged).value val files = (Compile / managedSources).value - files.map(f => - ( - f, - f.relativeTo(base).get.getPath - ) - ) + files + .map(f => (f, f.relativeTo(base))) + // this excludes modules/core/src/generated/PartiallyAppliedStruct.scala + .collect { case (f, Some(relF)) => f -> relF.getPath() } } ) .jvmPlatform(allJvmScalaVersions, jvmDimSettings) From fae0f68eba8190048700bc0a13340f14a82b315c Mon Sep 17 00:00:00 2001 From: David Francoeur Date: Wed, 18 May 2022 13:20:11 -0400 Subject: [PATCH 07/11] codegen via the plugin needs the protocol --- modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala index 629d6d702..e27f4b2a5 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala @@ -169,7 +169,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { openapiOutput = os.Path(openApiOutputPath), skipScala = false, skipOpenapi = false, - discoverModels = false, + discoverModels = true, // we need protocol here allowedNS = allowedNamespaces, excludedNS = excludedNamespaces, repositories = res, From 9a0ed4d9ce6f348284dda7e659adc5d52f498720 Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Thu, 19 May 2022 09:44:16 +0200 Subject: [PATCH 08/11] Use mix solution of hardcoded models + opt-in discovery --- build.sbt | 2 -- .../codegen/src/smithy4s/codegen/ModelLoader.scala | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index c296493be..797a24738 100644 --- a/build.sbt +++ b/build.sbt @@ -113,8 +113,6 @@ lazy val core = projectMatrix "smithy.waiters", "smithy4s.api" ), - genDiscoverModels := true, - Test / genDiscoverModels := false, Compile / sourceGenerators := Seq(genSmithyScala(Compile).taskValue), Compile / sourceGenerators += sourceDirectory .map(Boilerplate.gen(_, Boilerplate.BoilerplateModule.Core)) diff --git a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala index ec0d159d3..4b7f8debf 100644 --- a/modules/codegen/src/smithy4s/codegen/ModelLoader.scala +++ b/modules/codegen/src/smithy4s/codegen/ModelLoader.scala @@ -45,7 +45,7 @@ object ModelLoader { // might be provided by smithy4s itself out of the box) val modelBuilder = Model .assembler() - .maybeDiscoverModels(currentClassLoader, discoverModels) + .addClasspathModels(currentClassLoader, discoverModels) .assemble() .unwrap() .toBuilder() @@ -138,12 +138,17 @@ object ModelLoader { assembler } - def maybeDiscoverModels( + def addClasspathModels( classLoader: ClassLoader, flag: Boolean ): ModelAssembler = { + val smithy4sResources = List( + "META-INF/smithy/smithy4s.smithy", + "META-INF/smithy/smithy4s.meta.smithy" + ).map(classLoader.getResource) + if (flag) assembler.discoverModels(classLoader) - else assembler + else addImports(smithy4sResources) } } From 86240c527cfc0e914d5f4bf5bc4f70e5762b3a34 Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Thu, 19 May 2022 09:53:36 +0200 Subject: [PATCH 09/11] Enable model discovery for aws-http4s/test --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 01b84617b..fda9bd82f 100644 --- a/build.sbt +++ b/build.sbt @@ -244,6 +244,7 @@ lazy val `aws-http4s` = projectMatrix .dependsOn(aws) .settings( isCE3 := true, + Test / genDiscoverModels := true, libraryDependencies ++= { Seq( Dependencies.Http4s.client.value, From f18c4132de04ee23d06b55e207401bae702f6dad Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Thu, 19 May 2022 10:05:05 +0200 Subject: [PATCH 10/11] Enable discoverModels on core --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index fda9bd82f..d75739cee 100644 --- a/build.sbt +++ b/build.sbt @@ -113,6 +113,7 @@ lazy val core = projectMatrix "smithy.waiters", "smithy4s.api" ), + genDiscoverModels := true, Compile / sourceGenerators := Seq(genSmithyScala(Compile).taskValue), Compile / sourceGenerators += sourceDirectory .map(Boilerplate.gen(_, Boilerplate.BoilerplateModule.Core)) From edf9c19b2c6ce92518eca5c789b92d68f1cdc54f Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Thu, 19 May 2022 15:14:06 +0200 Subject: [PATCH 11/11] Remove the inference of fs paths from strings --- .../codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala | 4 ++-- modules/codegen/src/smithy4s/codegen/Codegen.scala | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala index e27f4b2a5..905871972 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala @@ -133,8 +133,8 @@ object Smithy4sCodegenPlugin extends AutoPlugin { * to decide whether or not Codegen should run. */ def cachedSmithyCodegen(conf: Configuration) = Def.task { - val outputPath = (conf / smithy4sOutputDir).value.getAbsolutePath() - val openApiOutputPath = (conf / smithy4sOpenapiDir).value.getAbsolutePath() + val outputPath = (conf / smithy4sOutputDir).value + val openApiOutputPath = (conf / smithy4sOpenapiDir).value val allowedNamespaces = (conf / smithy4sAllowedNamespaces).?.value.map(_.toSet) val excludedNamespaces = diff --git a/modules/codegen/src/smithy4s/codegen/Codegen.scala b/modules/codegen/src/smithy4s/codegen/Codegen.scala index 558f8cd14..ee29305e2 100644 --- a/modules/codegen/src/smithy4s/codegen/Codegen.scala +++ b/modules/codegen/src/smithy4s/codegen/Codegen.scala @@ -96,7 +96,8 @@ object Codegen { self => Renderer(amended) } .map { result => - val relPath = os.RelPath(result.namespace.replace('.', '/')) + val relPath = + os.RelPath(result.namespace.split('.').toIndexedSeq, ups = 0) (relPath, result.name, result.content) } }