Skip to content

Commit

Permalink
Recursively return all the generated files
Browse files Browse the repository at this point in the history
  • Loading branch information
keynmol committed May 15, 2022
1 parent fb8f87a commit 780cb3c
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions modules/codegen-plugin/src/smithy4s/codegen/CodegenPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,42 @@ object Smithy4sCodegenPlugin extends AutoPlugin {
}
val transforms = (conf / smithy4sModelTransformers).value

val fileChangesReport = (conf / smithy4sCodegen).inputFileChanges

if (fileChangesReport.hasChanges) {
val out = streams.value
val cacheFile =
out.cacheDirectory / s"smithy4s_${scalaBinaryVersion.value}"

val schemas = ((conf / smithy4sInputDir).value ** "*.smithy").get().toSet

out.log.debug(s"[Smithy4s] discovered specs: $schemas")

val compile = FileFunction
.cached(
cacheFile,
inStyle = FilesInfo.lastModified,
outStyle = FilesInfo.exists
) { (filePaths: Set[File]) =>
val codegenArgs = CodegenArgs(
filePaths.map(os.Path(_)).toList,
output = os.Path(outputPath),
openapiOutput = os.Path(openApiOutputPath),
skipScala = false,
skipOpenapi = false,
allowedNS = allowedNamespaces,
excludedNS = excludedNamespaces,
repositories = res,
dependencies = dependencies,
transforms
)

import fileChangesReport.*
val resPaths = smithy4s.codegen.Codegen
.processSpecs(codegenArgs)
.map(_.toIO)

val filePaths = modified ++ created ++ unmodified
out.log.debug(s"[Smithy4s] generated files: $resPaths")

val codegenArgs = CodegenArgs(
filePaths.map(os.Path(_)).toList,
output = os.Path(outputPath),
openapiOutput = os.Path(openApiOutputPath),
skipScala = false,
skipOpenapi = false,
allowedNS = allowedNamespaces,
excludedNS = excludedNamespaces,
repositories = res,
dependencies = dependencies,
transforms
)

val resPaths = smithy4s.codegen.Codegen
.processSpecs(codegenArgs)
.toList
resPaths
}

resPaths.map(path => new File(path.toString))
} else (conf / smithy4sOutputDir).value.listFiles().toSeq
compile(schemas).toSeq
}
}

0 comments on commit 780cb3c

Please sign in to comment.