From 70ebc751df539333ea884f1637f8087c182a7f90 Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Mon, 22 Apr 2024 16:58:20 +0200 Subject: [PATCH 01/12] Improve cache in code generation --- .../src/smithy4s/codegen/JsonConverters.scala | 14 +++++++++----- .../smithy4s/codegen/Smithy4sCodegenPlugin.scala | 14 ++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala index c571ae3de..20190d640 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala @@ -61,13 +61,17 @@ private[smithy4s] object JsonConverters { ) // format: off - type GenTarget = List[os.Path] :*: os.Path :*: os.Path :*: Set[FileType] :*: Boolean:*: Option[Set[String]] :*: Option[Set[String]] :*: List[String] :*: List[String] :*: List[String] :*: List[os.Path] :*: LNil + type GenTarget = List[os.Path] :*: String :*: String :*: Set[FileType] :*: Boolean:*: Option[Set[String]] :*: Option[Set[String]] :*: List[String] :*: List[String] :*: List[String] :*: List[os.Path] :*: LNil // format: on + + // `output` and `resourceOutput` are intentionally serialized as strings + // instead paths. This is to avoid hashing the directories that are generated by smithy4s anyway + // See https://github.com/disneystreaming/smithy4s/issues/1495 for reference on this decision implicit val codegenArgsIso = LList.iso[CodegenArgs, GenTarget]( { ca: CodegenArgs => ("specs", ca.specs) :*: - ("output", ca.output) :*: - ("resourceOutput", ca.resourceOutput) :*: + ("output", ca.output.toString) :*: + ("resourceOutput", ca.resourceOutput.toString) :*: ("skip", ca.skip) :*: ("discoverModels", ca.discoverModels) :*: ("allowedNS", ca.allowedNS) :*: @@ -92,8 +96,8 @@ private[smithy4s] object JsonConverters { (_, localJars) :*: LNil => CodegenArgs( specs, - output, - resourceOutput, + os.Path(output), + os.Path(resourceOutput), skip, discoverModels, allowedNS, diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index 4f2c625ad..107e8a35d 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -403,8 +403,8 @@ object Smithy4sCodegenPlugin extends AutoPlugin { (inputDirs ++ generatedFiles) .filter(_.exists()) .toList - val outputPath = (conf / smithy4sOutputDir).value - val resourceOutputPath = (conf / smithy4sResourceDir).value + val outputPath = (conf / smithy4sOutputDir).value / "smithy4s" + val resourceOutputPath = (conf / smithy4sResourceDir).value / "smithy4s" val allowedNamespaces = (conf / smithy4sAllowedNamespaces).?.value.map(_.toSet) val excludedNamespaces = @@ -424,7 +424,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { val filePaths = inputFiles.map(_.getAbsolutePath()) val codegenArgs = CodegenArgs( - filePaths.map(os.Path(_)).toList, + filePaths.sorted.map(os.Path(_)).toList, output = os.Path(outputPath), resourceOutput = os.Path(resourceOutputPath), skip = skipSet, @@ -433,8 +433,8 @@ object Smithy4sCodegenPlugin extends AutoPlugin { excludedNS = excludedNamespaces, repositories = res, dependencies = List.empty, - transformers = transforms, - localJars = localJars + transformers = transforms.sorted, + localJars = localJars.sorted ) val cached = @@ -443,14 +443,16 @@ object Smithy4sCodegenPlugin extends AutoPlugin { ) { Function.untupled { Tracked.lastOutput[(Boolean, CodegenArgs), Seq[File]]( - s.cacheStoreFactory.make("output") + s.cacheDirectory / "smithy4s-output" ) { case ((inputChanged, args), outputs) => if (inputChanged || outputs.isEmpty) { + s.log.debug("Regenerating managed sources") val resPaths = smithy4s.codegen.Codegen .generateToDisk(args) .toList resPaths.map(path => new File(path.toString)) } else { + s.log.debug("Using cached version of outputs") outputs.getOrElse(Seq.empty) } } From 4fcd2dd8ec158525eba1d064bf7d53275242e362 Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Tue, 23 Apr 2024 18:42:30 +0200 Subject: [PATCH 02/12] introduce PathRef for hashed directories --- .../smithy4s/codegen/cli/CodegenCommand.scala | 5 ++-- .../codegen/cli/CommandParsingSpec.scala | 5 ++-- .../src/smithy4s/codegen/JsonConverters.scala | 28 +++++++++++-------- .../codegen/Smithy4sCodegenPlugin.scala | 12 ++++---- .../src/smithy4s/codegen/CodegenArgs.scala | 5 ++-- .../src/smithy4s/codegen/PathRef.scala | 3 ++ .../codegen/internals/CodegenImpl.scala | 6 ++-- .../codegen/mill/Smithy4sModule.scala | 11 ++++++-- 8 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 modules/codegen/src/smithy4s/codegen/PathRef.scala diff --git a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala index 39a89420f..6222c319e 100644 --- a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala +++ b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala @@ -24,6 +24,7 @@ import smithy4s.codegen.CodegenArgs import smithy4s.codegen.FileType import Options._ +import smithy4s.codegen.PathRef object CodegenCommand { @@ -116,7 +117,7 @@ object CodegenCommand { defaultDependencies ++ dependencies.getOrElse(List.empty) } CodegenArgs( - specsArgs, + specsArgs.map(PathRef(_)), output.getOrElse(os.pwd), resourseOutput.getOrElse(os.pwd), skip, @@ -126,7 +127,7 @@ object CodegenCommand { repositories.getOrElse(List.empty), dependenciesWithDefaults, transformers.getOrElse(List.empty), - localJars.getOrElse(List.empty) + localJars.getOrElse(List.empty).map(PathRef(_)) ) } 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 9190935f8..dce995dac 100644 --- a/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala +++ b/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala @@ -21,6 +21,7 @@ import smithy4s.codegen.FileType import weaver._ import Defaults.defaultDependencies +import smithy4s.codegen.PathRef object CommandParsingSpec extends FunSuite { @@ -81,7 +82,7 @@ object CommandParsingSpec extends FunSuite { specs = List( os.pwd / "sampleSpecs" / "pizza.smithy", os.pwd / "sampleSpecs" / "example.smithy" - ), + ).map(PathRef(_)), output = os.pwd / "target", resourceOutput = os.pwd / "target" / "openapi", skip = Set(FileType.Openapi, FileType.Scala), @@ -94,7 +95,7 @@ object CommandParsingSpec extends FunSuite { localJars = List( os.pwd / "lib1.jar", os.pwd / "lib2.jar" - ) + ).map(PathRef(_)) ) ) ) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala index 20190d640..86e876b51 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala @@ -30,24 +30,30 @@ private[smithy4s] object JsonConverters { // This serialises a path by providing a hash of the content it points to. // Because the hash is part of the Json, this allows SBT to detect when a file // changes and invalidate its relevant caches, leading to a call to Smithy4s' code generator. - implicit val pathFormat: JsonFormat[os.Path] = - BasicJsonProtocol.projectFormat[os.Path, HashFileInfo]( + implicit val pathRefFormat: JsonFormat[PathRef] = + BasicJsonProtocol.projectFormat[PathRef, HashFileInfo]( p => { - if (os.isFile(p)) FileInfo.hash(p.toIO) + if (os.isFile(p.underlying)) FileInfo.hash(p.underlying.toIO) else // If the path is a directory, we get the hashes of all files // then hash the concatenation of the hash's bytes. FileInfo.hash( - p.toIO, + p.underlying.toIO, Hash( - os.walk(p) + os.walk(p.underlying) .map(_.toIO) .map(Hash(_)) .foldLeft(Array.emptyByteArray)(_ ++ _) ) ) }, - hash => os.Path(hash.file) + hash => PathRef(os.Path(hash.file)) + ) + + implicit val pathFormat: JsonFormat[os.Path] = + BasicJsonProtocol.projectFormat[os.Path, String]( + p => p.toString, + str => os.Path(str) ) implicit val fileTypeFormat: JsonFormat[FileType] = @@ -61,7 +67,7 @@ private[smithy4s] object JsonConverters { ) // format: off - type GenTarget = List[os.Path] :*: String :*: String :*: Set[FileType] :*: Boolean:*: Option[Set[String]] :*: Option[Set[String]] :*: List[String] :*: List[String] :*: List[String] :*: List[os.Path] :*: LNil + type GenTarget = List[PathRef] :*: os.Path :*: os.Path :*: Set[FileType] :*: Boolean:*: Option[Set[String]] :*: Option[Set[String]] :*: List[String] :*: List[String] :*: List[String] :*: List[PathRef] :*: LNil // format: on // `output` and `resourceOutput` are intentionally serialized as strings @@ -70,8 +76,8 @@ private[smithy4s] object JsonConverters { implicit val codegenArgsIso = LList.iso[CodegenArgs, GenTarget]( { ca: CodegenArgs => ("specs", ca.specs) :*: - ("output", ca.output.toString) :*: - ("resourceOutput", ca.resourceOutput.toString) :*: + ("output", ca.output) :*: + ("resourceOutput", ca.resourceOutput) :*: ("skip", ca.skip) :*: ("discoverModels", ca.discoverModels) :*: ("allowedNS", ca.allowedNS) :*: @@ -96,8 +102,8 @@ private[smithy4s] object JsonConverters { (_, localJars) :*: LNil => CodegenArgs( specs, - os.Path(output), - os.Path(resourceOutput), + output, + resourceOutput, skip, discoverModels, allowedNS, diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index 107e8a35d..576ccd2cf 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -410,12 +410,13 @@ object Smithy4sCodegenPlugin extends AutoPlugin { val excludedNamespaces = (conf / smithy4sExcludedNamespaces).?.value.map(_.toSet) val localJars = - (conf / smithy4sAllDependenciesAsJars).value.map(os.Path(_)).toList + (conf / smithy4sAllDependenciesAsJars).value.toList.sorted + .map(p => PathRef(os.Path(p))) val res = (conf / resolvers).value.toList.collect { case m: MavenRepository => m.root } - val transforms = (conf / smithy4sModelTransformers).value + val transforms = (conf / smithy4sModelTransformers).value.sorted val s = (conf / streams).value val skipResources: Set[FileType] = if ((conf / smithy4sSmithyLibrary).value) Set.empty @@ -423,8 +424,9 @@ object Smithy4sCodegenPlugin extends AutoPlugin { val skipSet = skipResources val filePaths = inputFiles.map(_.getAbsolutePath()) + val specs = filePaths.sorted.map(p => PathRef(os.Path(p))).toList val codegenArgs = CodegenArgs( - filePaths.sorted.map(os.Path(_)).toList, + specs, output = os.Path(outputPath), resourceOutput = os.Path(resourceOutputPath), skip = skipSet, @@ -433,8 +435,8 @@ object Smithy4sCodegenPlugin extends AutoPlugin { excludedNS = excludedNamespaces, repositories = res, dependencies = List.empty, - transformers = transforms.sorted, - localJars = localJars.sorted + transformers = transforms, + localJars = localJars ) val cached = diff --git a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala index c3e347360..7e7cf08d6 100644 --- a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala +++ b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala @@ -20,7 +20,7 @@ import cats.data.ValidatedNel import cats.syntax.all._ final case class CodegenArgs( - specs: List[os.Path], + specs: List[PathRef], output: os.Path, resourceOutput: os.Path, skip: Set[FileType], @@ -30,12 +30,13 @@ final case class CodegenArgs( repositories: List[String], dependencies: List[String], transformers: List[String], - localJars: List[os.Path] + localJars: List[PathRef] ) { def skipScala: Boolean = skip(FileType.Scala) def skipOpenapi: Boolean = skip(FileType.Openapi) def skipResources: Boolean = skip(FileType.Resource) def skipProto: Boolean = skip(FileType.Proto) + } sealed abstract class FileType(val name: String) diff --git a/modules/codegen/src/smithy4s/codegen/PathRef.scala b/modules/codegen/src/smithy4s/codegen/PathRef.scala new file mode 100644 index 000000000..7196a2439 --- /dev/null +++ b/modules/codegen/src/smithy4s/codegen/PathRef.scala @@ -0,0 +1,3 @@ +package smithy4s.codegen + +final case class PathRef(underlying: os.Path) diff --git a/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala b/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala index e5dc66988..9dfbd4f98 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala @@ -32,12 +32,12 @@ private[codegen] object CodegenImpl { self => def generate(args: CodegenArgs): CodegenResult = { val (classloader, model): (ClassLoader, Model) = internals.ModelLoader.load( - args.specs.map(_.toIO).toSet, + args.specs.map(_.underlying.toIO).toSet, args.dependencies, args.repositories, withBuiltinTransformers(args.transformers), args.discoverModels, - args.localJars + args.localJars.map(_.underlying) ) val (scalaFiles, smithyResources) = if (!args.skipScala) { @@ -56,7 +56,7 @@ private[codegen] object CodegenImpl { self => val resources = if (!skipResource) { SmithyResources.produce( args.resourceOutput, - args.specs, + args.specs.map(_.underlying), generatedNamespaces ) } else List.empty[CodegenEntry] diff --git a/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala b/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala index d57a9f653..69fe8a3cc 100644 --- a/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala +++ b/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala @@ -34,6 +34,7 @@ import mill.api.JarManifest import mill.scalalib.CrossVersion.Binary import mill.scalalib.CrossVersion.Constant import mill.scalalib.CrossVersion.Full +import smithy4s.codegen trait Smithy4sModule extends ScalaModule { @@ -190,6 +191,8 @@ trait Smithy4sModule extends ScalaModule { val specFiles = (smithy4sGeneratedSmithyFiles() ++ smithy4sInputDirs()) .map(_.path) .filter(os.exists(_)) + .toList + .map(codegen.PathRef(_)) val scalaOutput = smithy4sOutputDir().path val resourcesOutput = smithy4sResourceOutputDir().path @@ -205,10 +208,14 @@ trait Smithy4sModule extends ScalaModule { val skipSet = skipResources ++ skipOpenApi val allLocalJars = - smithy4sAllDependenciesAsJars().map(_.path).iterator.to(List) + smithy4sAllDependenciesAsJars() + .map(_.path) + .iterator + .to(List) + .map(codegen.PathRef(_)) val args = CodegenArgs( - specs = specFiles.toList, + specs = specFiles, output = scalaOutput, resourceOutput = resourcesOutput, skip = skipSet, From bd719c1464901f4fc240b54e03cb07516c0607b9 Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Wed, 24 Apr 2024 09:05:54 +0200 Subject: [PATCH 03/12] restore cache directory to factory generated --- .../src/smithy4s/codegen/Smithy4sCodegenPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index 576ccd2cf..4ce0f6d8e 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -445,7 +445,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { ) { Function.untupled { Tracked.lastOutput[(Boolean, CodegenArgs), Seq[File]]( - s.cacheDirectory / "smithy4s-output" + s.cacheStoreFactory.make("output") ) { case ((inputChanged, args), outputs) => if (inputChanged || outputs.isEmpty) { s.log.debug("Regenerating managed sources") From cd141bdbe14d3646930e275feeb758baf84d3c83 Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Wed, 24 Apr 2024 09:45:26 +0200 Subject: [PATCH 04/12] restore public api for CodegenArgs --- .../src/smithy4s/codegen/cli/CodegenCommand.scala | 5 ++--- .../src/smithy4s/codegen/cli/CommandParsingSpec.scala | 5 ++--- .../src/smithy4s/codegen/JsonConverters.scala | 8 ++++---- .../src/smithy4s/codegen/Smithy4sCodegenPlugin.scala | 4 ++-- modules/codegen/src/smithy4s/codegen/CodegenArgs.scala | 4 ++-- .../src/smithy4s/codegen/internals/CodegenImpl.scala | 6 +++--- .../src/smithy4s/codegen/mill/Smithy4sModule.scala | 3 --- 7 files changed, 15 insertions(+), 20 deletions(-) diff --git a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala index 6222c319e..39a89420f 100644 --- a/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala +++ b/modules/codegen-cli/src/smithy4s/codegen/cli/CodegenCommand.scala @@ -24,7 +24,6 @@ import smithy4s.codegen.CodegenArgs import smithy4s.codegen.FileType import Options._ -import smithy4s.codegen.PathRef object CodegenCommand { @@ -117,7 +116,7 @@ object CodegenCommand { defaultDependencies ++ dependencies.getOrElse(List.empty) } CodegenArgs( - specsArgs.map(PathRef(_)), + specsArgs, output.getOrElse(os.pwd), resourseOutput.getOrElse(os.pwd), skip, @@ -127,7 +126,7 @@ object CodegenCommand { repositories.getOrElse(List.empty), dependenciesWithDefaults, transformers.getOrElse(List.empty), - localJars.getOrElse(List.empty).map(PathRef(_)) + localJars.getOrElse(List.empty) ) } 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 dce995dac..9190935f8 100644 --- a/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala +++ b/modules/codegen-cli/test/src/smithy4s/codegen/cli/CommandParsingSpec.scala @@ -21,7 +21,6 @@ import smithy4s.codegen.FileType import weaver._ import Defaults.defaultDependencies -import smithy4s.codegen.PathRef object CommandParsingSpec extends FunSuite { @@ -82,7 +81,7 @@ object CommandParsingSpec extends FunSuite { specs = List( os.pwd / "sampleSpecs" / "pizza.smithy", os.pwd / "sampleSpecs" / "example.smithy" - ).map(PathRef(_)), + ), output = os.pwd / "target", resourceOutput = os.pwd / "target" / "openapi", skip = Set(FileType.Openapi, FileType.Scala), @@ -95,7 +94,7 @@ object CommandParsingSpec extends FunSuite { localJars = List( os.pwd / "lib1.jar", os.pwd / "lib2.jar" - ).map(PathRef(_)) + ) ) ) ) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala index 86e876b51..1c68e3229 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala @@ -75,7 +75,7 @@ private[smithy4s] object JsonConverters { // See https://github.com/disneystreaming/smithy4s/issues/1495 for reference on this decision implicit val codegenArgsIso = LList.iso[CodegenArgs, GenTarget]( { ca: CodegenArgs => - ("specs", ca.specs) :*: + ("specs", ca.specs.map(PathRef(_))) :*: ("output", ca.output) :*: ("resourceOutput", ca.resourceOutput) :*: ("skip", ca.skip) :*: @@ -85,7 +85,7 @@ private[smithy4s] object JsonConverters { ("repositories", ca.repositories) :*: ("dependencies", ca.dependencies) :*: ("transformers", ca.transformers) :*: - ("localJars", ca.localJars) :*: + ("localJars", ca.localJars.map(PathRef(_))) :*: LNil }, { @@ -101,7 +101,7 @@ private[smithy4s] object JsonConverters { (_, transformers) :*: (_, localJars) :*: LNil => CodegenArgs( - specs, + specs.map(_.underlying), output, resourceOutput, skip, @@ -111,7 +111,7 @@ private[smithy4s] object JsonConverters { repositories, dependencies, transformers, - localJars + localJars.map(_.underlying) ) } ) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index 4ce0f6d8e..d7df6996f 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -411,7 +411,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { (conf / smithy4sExcludedNamespaces).?.value.map(_.toSet) val localJars = (conf / smithy4sAllDependenciesAsJars).value.toList.sorted - .map(p => PathRef(os.Path(p))) + .map(p => os.Path(p)) val res = (conf / resolvers).value.toList.collect { case m: MavenRepository => m.root @@ -424,7 +424,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { val skipSet = skipResources val filePaths = inputFiles.map(_.getAbsolutePath()) - val specs = filePaths.sorted.map(p => PathRef(os.Path(p))).toList + val specs = filePaths.sorted.map(p => os.Path(p)).toList val codegenArgs = CodegenArgs( specs, output = os.Path(outputPath), diff --git a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala index 7e7cf08d6..22998b2d2 100644 --- a/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala +++ b/modules/codegen/src/smithy4s/codegen/CodegenArgs.scala @@ -20,7 +20,7 @@ import cats.data.ValidatedNel import cats.syntax.all._ final case class CodegenArgs( - specs: List[PathRef], + specs: List[os.Path], output: os.Path, resourceOutput: os.Path, skip: Set[FileType], @@ -30,7 +30,7 @@ final case class CodegenArgs( repositories: List[String], dependencies: List[String], transformers: List[String], - localJars: List[PathRef] + localJars: List[os.Path] ) { def skipScala: Boolean = skip(FileType.Scala) def skipOpenapi: Boolean = skip(FileType.Openapi) diff --git a/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala b/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala index 9dfbd4f98..e5dc66988 100644 --- a/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala +++ b/modules/codegen/src/smithy4s/codegen/internals/CodegenImpl.scala @@ -32,12 +32,12 @@ private[codegen] object CodegenImpl { self => def generate(args: CodegenArgs): CodegenResult = { val (classloader, model): (ClassLoader, Model) = internals.ModelLoader.load( - args.specs.map(_.underlying.toIO).toSet, + args.specs.map(_.toIO).toSet, args.dependencies, args.repositories, withBuiltinTransformers(args.transformers), args.discoverModels, - args.localJars.map(_.underlying) + args.localJars ) val (scalaFiles, smithyResources) = if (!args.skipScala) { @@ -56,7 +56,7 @@ private[codegen] object CodegenImpl { self => val resources = if (!skipResource) { SmithyResources.produce( args.resourceOutput, - args.specs.map(_.underlying), + args.specs, generatedNamespaces ) } else List.empty[CodegenEntry] diff --git a/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala b/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala index 69fe8a3cc..5367606c8 100644 --- a/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala +++ b/modules/mill-codegen-plugin/src/smithy4s/codegen/mill/Smithy4sModule.scala @@ -34,7 +34,6 @@ import mill.api.JarManifest import mill.scalalib.CrossVersion.Binary import mill.scalalib.CrossVersion.Constant import mill.scalalib.CrossVersion.Full -import smithy4s.codegen trait Smithy4sModule extends ScalaModule { @@ -192,7 +191,6 @@ trait Smithy4sModule extends ScalaModule { .map(_.path) .filter(os.exists(_)) .toList - .map(codegen.PathRef(_)) val scalaOutput = smithy4sOutputDir().path val resourcesOutput = smithy4sResourceOutputDir().path @@ -212,7 +210,6 @@ trait Smithy4sModule extends ScalaModule { .map(_.path) .iterator .to(List) - .map(codegen.PathRef(_)) val args = CodegenArgs( specs = specFiles, From 73d938fae471e9c37983d88cc0b7f64e61feea3b Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Thu, 25 Apr 2024 15:01:29 +0200 Subject: [PATCH 05/12] add missing headers --- .../codegen/src/smithy4s/codegen/PathRef.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/codegen/src/smithy4s/codegen/PathRef.scala b/modules/codegen/src/smithy4s/codegen/PathRef.scala index 7196a2439..f4bd5ee9d 100644 --- a/modules/codegen/src/smithy4s/codegen/PathRef.scala +++ b/modules/codegen/src/smithy4s/codegen/PathRef.scala @@ -1,3 +1,19 @@ +/* + * 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 smithy4s.codegen final case class PathRef(underlying: os.Path) From df5f6d13fc5baed378d7284cddf7d76ff49ddf23 Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Fri, 26 Apr 2024 12:00:40 +0200 Subject: [PATCH 06/12] adjust paths in scripted tests --- .../sbt-test/codegen-plugin/aws-newtype-flatten/test | 4 ++-- .../src/sbt-test/codegen-plugin/aws-specs/test | 2 +- .../src/sbt-test/codegen-plugin/custom-settings/test | 10 +++++----- .../src/sbt-test/codegen-plugin/defaults/test | 6 +++--- .../sbt-test/codegen-plugin/dependencies-only/test | 2 +- .../src/sbt-test/codegen-plugin/extra-configs/test | 4 ++-- .../src/sbt-test/codegen-plugin/multimodule-aws/test | 4 ++-- .../sbt-test/codegen-plugin/multimodule-staged/test | 4 ++-- .../src/sbt-test/codegen-plugin/multimodule/test | 12 ++++++------ .../src/sbt-test/codegen-plugin/scala3/test | 8 ++++---- .../src/sbt-test/codegen-plugin/smithy-rules/test | 2 +- .../src/sbt-test/codegen-plugin/wildcard-config/test | 8 ++++---- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-newtype-flatten/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-newtype-flatten/test index d853c9a95..c813c07d5 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-newtype-flatten/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-newtype-flatten/test @@ -2,7 +2,7 @@ > run # This new type was not flattened because it has range constraints -$ exists smithy_output/com/amazonaws/dynamodb/ListTablesInputLimit.scala +$ exists smithy_output/smithy4s/com/amazonaws/dynamodb/ListTablesInputLimit.scala # Flattened and removed by the projection transformer --$ exists smithy_output/com/amazonaws/dynamodb/Long.scala +-$ exists smithy_output/smithy4s/com/amazonaws/dynamodb/Long.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-specs/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-specs/test index 102f0d70c..e58e612c4 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-specs/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/aws-specs/test @@ -1,3 +1,3 @@ # check if smithy4sCodegen works > smithy4sCodegen -$ exists target/scala-2.13/src_managed/main/scala/com/amazonaws/dynamodb/AttributeValue.scala +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/com/amazonaws/dynamodb/AttributeValue.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/custom-settings/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/custom-settings/test index 4372b5970..0e740f87c 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/custom-settings/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/custom-settings/test @@ -1,10 +1,10 @@ # check if smithy4sCodegen works > show p1/smithy4sAllExternalDependencies > p1/compile -$ exists p1/smithy_output/aws/iam/ActionPermissionDescription.scala -$ exists p1/smithy_output/smithy4s/example/ObjectService.scala +$ exists p1/smithy_output/smithy4s/aws/iam/ActionPermissionDescription.scala +$ exists p1/smithy_output/smithy4s/smithy4s/example/ObjectService.scala > p2/compile -$ exists p2/smithy_output/aws/iam/ActionPermissionDescription.scala -$ exists p2/smithy_output/smithy4s/example/ObjectService.scala --$ exists p2/smithy_output/smithy4s/toexclude/StructureToExclude.scala +$ exists p2/smithy_output/smithy4s/aws/iam/ActionPermissionDescription.scala +$ exists p2/smithy_output/smithy4s/smithy4s/example/ObjectService.scala +-$ exists p2/smithy_output/smithy4s/smithy4s/toexclude/StructureToExclude.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test index 91e32b89f..3d835ed4e 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test @@ -1,14 +1,14 @@ # check if smithy4sCodegen works > compile -$ exists target/scala-2.13/src_managed/main/scala/smithy4s/example/ObjectService.scala -$ exists target/scala-2.13/resource_managed/main/smithy4s.example.ObjectService.json +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/smithy4s/example/ObjectService.scala +$ exists target/scala-2.13/resource_managed/main/smithy4s/smithy4s.example.ObjectService.json # check if code can run, this can reveal runtime issues # such as initialization errors > run $ copy-file example-added.smithy src/main/smithy/example-added.smithy > compile -$ exists target/scala-2.13/src_managed/main/scala/smithy4s/example/Added.scala +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/smithy4s/example/Added.scala # ensuring that removing existing files removes their outputs $ delete src/main/smithy/example.smithy diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/dependencies-only/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/dependencies-only/test index 7e6822104..1b03c2fca 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/dependencies-only/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/dependencies-only/test @@ -1,3 +1,3 @@ # check if smithy4sCodegen works > p1/compile -$ exists p1/smithy_output/aws/iam/ActionPermissionDescription.scala +$ exists p1/smithy_output/smithy4s/aws/iam/ActionPermissionDescription.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/extra-configs/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/extra-configs/test index b1811de51..4815ec114 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/extra-configs/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/extra-configs/test @@ -1,7 +1,7 @@ # check if main sources are generated > compile -$ exists target/scala-2.13/src_managed/main/scala/example/ExampleStruct.scala +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/example/ExampleStruct.scala # check if test sources are generated > Test/compile -$ exists target/scala-2.13/src_managed/test/scala/testexample/TestStruct.scala +$ exists target/scala-2.13/src_managed/test/scala/smithy4s/testexample/TestStruct.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-aws/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-aws/test index 322e41d85..883b4d0ac 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-aws/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-aws/test @@ -1,5 +1,5 @@ # check if smithy4sCodegen works with libraries that were built with Smithy4s > show bar/smithy4sAllExternalDependencies > compile -$ exists foo/target/scala-2.13/src_managed/main/scala/foo/Lambda.scala -$ absent bar/target/scala-2.13/src_managed/main/scala/foo/Lambda.scala +$ exists foo/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Lambda.scala +$ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Lambda.scala diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-staged/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-staged/test index a108f522d..183e549f6 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-staged/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule-staged/test @@ -2,8 +2,8 @@ > foo/publishLocal > upstream/publishLocal > bar/compile -$ exists bar/target/scala-2.13/src_managed/main/scala/bar/Bar.scala -$ absent bar/target/scala-2.13/src_managed/main/scala/foo/Foo.scala +$ exists bar/target/scala-2.13/src_managed/main/scala/smithy4s/bar/Bar.scala +$ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Foo.scala # check if code can run, this can reveal runtime issues# such as initialization errors > bar/run diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test index 264942144..ce2de2def 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test @@ -1,11 +1,11 @@ # check if smithy4sCodegen works in multimodule contexts > compile -$ exists bar/target/scala-2.13/src_managed/main/scala/bar/Bar.scala -$ absent bar/target/scala-2.13/src_managed/main/scala/foo/Foo.scala -$ absent bar/target/scala-2.13/src_managed/main/scala/foodir/FooDir.scala -$ exists foo/target/scala-2.13/src_managed/main/scala/foo/Foo.scala -$ exists foo/target/scala-2.13/src_managed/main/scala/foodir/FooDir.scala - +$ exists bar/target/scala-2.13/src_managed/main/scala/smithy4s/bar/Bar.scala +$ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Foo.scala +$ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foodir/FooDir.scala +$ exists foo/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Foo.scala +$ exists foo/target/scala-2.13/src_managed/main/scala/smithy4s/foodir/FooDir.scala +> pause # check if code can run, this can reveal runtime issues# such as initialization errors > bar/run diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/scala3/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/scala3/test index 3cd2331f1..c6fef7253 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/scala3/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/scala3/test @@ -1,10 +1,10 @@ # check if smithy4sCodegen works > compile -$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/errors/BadRequest.scala -$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/errors/InternalServerError.scala -$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/errors/ErrorService.scala -$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/errors/package.scala +$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/smithy4s/errors/BadRequest.scala +$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/smithy4s/errors/InternalServerError.scala +$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/smithy4s/errors/ErrorService.scala +$ exists target/scala-3.3.0/src_managed/main/scala/smithy4s/smithy4s/errors/package.scala # check if code can run > run diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-rules/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-rules/test index 764d41bbb..b2a89b735 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-rules/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-rules/test @@ -1,3 +1,3 @@ # check if smithy4sCodegen works > compile -$ exists target/scala-2.13/src_managed/main/scala/smithy/rules +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/smithy/rules diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test index 9dda2172e..bd8acf982 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test @@ -14,15 +14,15 @@ > ++2.13.10 root/compile $ exists target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-2.13/resource_managed/main/META-INF/smithy/generated-metadata.smithy +$ exists target/scala-2.13/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy > ++3.3.0 root/compile $ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy +$ exists target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy # ensure metadata file is re-generated after deleting $ delete target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy -$ delete target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy +$ delete target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy > ++3.3.0 root/compile $ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy +$ exists target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy \ No newline at end of file From 5bfb52f69c94477cfd5c30523a6d272b5aa46d8f Mon Sep 17 00:00:00 2001 From: Michal Pawlik Date: Fri, 26 Apr 2024 12:01:51 +0200 Subject: [PATCH 07/12] un-sort transforms --- .../src/smithy4s/codegen/Smithy4sCodegenPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index d7df6996f..8e14e9ccb 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -416,7 +416,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { (conf / resolvers).value.toList.collect { case m: MavenRepository => m.root } - val transforms = (conf / smithy4sModelTransformers).value.sorted + val transforms = (conf / smithy4sModelTransformers).value val s = (conf / streams).value val skipResources: Set[FileType] = if ((conf / smithy4sSmithyLibrary).value) Set.empty From 99254fe1bca4f01fa7e7fd0cb980237c76d07fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 26 Apr 2024 20:01:58 +0200 Subject: [PATCH 08/12] Don't nest resources --- .../src/sbt-test/codegen-plugin/defaults/test | 4 ++-- .../src/sbt-test/codegen-plugin/multimodule/test | 3 +-- .../src/sbt-test/codegen-plugin/wildcard-config/test | 8 ++++---- .../src/smithy4s/codegen/Smithy4sCodegenPlugin.scala | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test index 3d835ed4e..03ff1b43e 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/defaults/test @@ -1,7 +1,7 @@ # check if smithy4sCodegen works > compile $ exists target/scala-2.13/src_managed/main/scala/smithy4s/smithy4s/example/ObjectService.scala -$ exists target/scala-2.13/resource_managed/main/smithy4s/smithy4s.example.ObjectService.json +$ exists target/scala-2.13/resource_managed/main/smithy4s.example.ObjectService.json # check if code can run, this can reveal runtime issues # such as initialization errors @@ -15,4 +15,4 @@ $ delete src/main/smithy/example.smithy -> compile > smithy4sUpdateLSPConfig -> checkSmithyBuild \ No newline at end of file +> checkSmithyBuild diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test index ce2de2def..e48a23e0e 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/multimodule/test @@ -5,7 +5,6 @@ $ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Foo.scala $ absent bar/target/scala-2.13/src_managed/main/scala/smithy4s/foodir/FooDir.scala $ exists foo/target/scala-2.13/src_managed/main/scala/smithy4s/foo/Foo.scala $ exists foo/target/scala-2.13/src_managed/main/scala/smithy4s/foodir/FooDir.scala -> pause # check if code can run, this can reveal runtime issues# such as initialization errors > bar/run @@ -14,4 +13,4 @@ $ copy-file a.scala foo/src/main/scala/a.scala > bar/run > smithy4sUpdateLSPConfig -> checkSmithyBuild \ No newline at end of file +> checkSmithyBuild diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test index bd8acf982..9dda2172e 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test @@ -14,15 +14,15 @@ > ++2.13.10 root/compile $ exists target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-2.13/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy +$ exists target/scala-2.13/resource_managed/main/META-INF/smithy/generated-metadata.smithy > ++3.3.0 root/compile $ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy +$ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy # ensure metadata file is re-generated after deleting $ delete target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy -$ delete target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy +$ delete target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy > ++3.3.0 root/compile $ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-3.3.0/resource_managed/main/smithy4s/META-INF/smithy/generated-metadata.smithy \ No newline at end of file +$ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy diff --git a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala index 8e14e9ccb..61f0c656e 100644 --- a/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala +++ b/modules/codegen-plugin/src/smithy4s/codegen/Smithy4sCodegenPlugin.scala @@ -404,7 +404,7 @@ object Smithy4sCodegenPlugin extends AutoPlugin { .filter(_.exists()) .toList val outputPath = (conf / smithy4sOutputDir).value / "smithy4s" - val resourceOutputPath = (conf / smithy4sResourceDir).value / "smithy4s" + val resourceOutputPath = (conf / smithy4sResourceDir).value val allowedNamespaces = (conf / smithy4sAllowedNamespaces).?.value.map(_.toSet) val excludedNamespaces = From 3deb06883a5cfa5851c8214ca527eb9730480e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 17 May 2024 21:24:57 +0200 Subject: [PATCH 09/12] Fix new test --- .../src/sbt-test/codegen-plugin/smithy-build/test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-build/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-build/test index 0f186a0a1..442fb337b 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-build/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/smithy-build/test @@ -1,5 +1,5 @@ # check if smithy4sCodegen works > compile -$ exists target/scala-2.13/src_managed/main/scala/smithy4s/example/ObjectService.scala +$ exists target/scala-2.13/src_managed/main/scala/smithy4s/smithy4s/example/ObjectService.scala $ exists target/scala-2.13/resource_managed/main/smithy4s.example.ObjectService.json -> checkOpenApi \ No newline at end of file +> checkOpenApi From 70709ae596a3613d6ad3aeac4445de70ea820ea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 17 May 2024 22:06:37 +0200 Subject: [PATCH 10/12] Deleting output files won't trigger regenerating them --- .../src/sbt-test/codegen-plugin/wildcard-config/test | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test index 9dda2172e..42a1ffba5 100644 --- a/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test +++ b/modules/codegen-plugin/src/sbt-test/codegen-plugin/wildcard-config/test @@ -19,10 +19,3 @@ $ exists target/scala-2.13/resource_managed/main/META-INF/smithy/generated-metad > ++3.3.0 root/compile $ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy $ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy - -# ensure metadata file is re-generated after deleting -$ delete target/scala-2.13/src_managed/main/smithy/generated-metadata.smithy -$ delete target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy -> ++3.3.0 root/compile -$ exists target/scala-3.3.0/src_managed/main/smithy/generated-metadata.smithy -$ exists target/scala-3.3.0/resource_managed/main/META-INF/smithy/generated-metadata.smithy From 32bd0a29a608c21796544de227d80688fe9c2975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 17 May 2024 22:10:01 +0200 Subject: [PATCH 11/12] Add CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d446800b..ab0a1bc07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,8 @@ We apologize for the inconvenience. * `smithy4sUpdateLSPConfig`: Replace `imports` with `sources` to be more in line with idiomatic smithy-build config in https://github.com/disneystreaming/smithy4s/pull/1518 (see https://github.com/disneystreaming/smithy4s/issues/1459) * Update smithy: 1.45.0 to 1.49.0 (binary breaking) in https://github.com/disneystreaming/smithy4s/pull/1485 * Rendered type aliases are now sorted alphabetically in https://github.com/disneystreaming/smithy4s/pull/1523 -* Adds handlers construct to facilitate the decoupling of operation implementations in https://github.com/disneystreaming/smithy4s/pull/1522 +* Add handlers construct to facilitate the decoupling of operation implementations in https://github.com/disneystreaming/smithy4s/pull/1522 +* Improve cache in code generation (sbt) in https://github.com/disneystreaming/smithy4s/pull/1499 # 0.18.18 From acfd9ddcef09095f154acdb34abe202543da5483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Fri, 17 May 2024 22:18:47 +0200 Subject: [PATCH 12/12] Move PathRef to sbt --- .../src/smithy4s/codegen/PathRef.scala | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename modules/{codegen => codegen-plugin}/src/smithy4s/codegen/PathRef.scala (100%) diff --git a/modules/codegen/src/smithy4s/codegen/PathRef.scala b/modules/codegen-plugin/src/smithy4s/codegen/PathRef.scala similarity index 100% rename from modules/codegen/src/smithy4s/codegen/PathRef.scala rename to modules/codegen-plugin/src/smithy4s/codegen/PathRef.scala