diff --git a/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala b/modules/codegen-plugin/src/smithy4s/codegen/JsonConverters.scala index c571ae3deb..20190d640a 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 4f2c625ad9..c12c0a4baa 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 sources since") 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) } }