Skip to content

Commit 9ab89a9

Browse files
authored
Simplify task caching (#4)
* Simplify task caching * fix
1 parent 49b2543 commit 9ab89a9

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

sbtPlugin/src/main/scala/org/polyvariant/smithytraitcodegen/SmithyTraitCodegenPlugin.scala

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ object SmithyTraitCodegenPlugin extends AutoPlugin {
6262
Keys.generateSmithyTraits := Def.task {
6363
import sbt.util.CacheImplicits.*
6464
val s = (Compile / streams).value
65-
val logger = sLog.value
6665

6766
val report = update.value
6867
val dependencies = smithyTraitCodegenDependencies.value
@@ -84,26 +83,12 @@ object SmithyTraitCodegenPlugin extends AutoPlugin {
8483
dependencies = jars.map(PathRef(_)).toList,
8584
externalProviders = smithyTraitCodegenExternalProviders.value,
8685
)
86+
8787
val cachedCodegen =
88-
Tracked.inputChanged[SmithyTraitCodegen.Args, SmithyTraitCodegen.Output](
89-
s.cacheStoreFactory.make("smithy-trait-codegen-args")
90-
) {
91-
Function.untupled(
92-
Tracked
93-
.lastOutput[(Boolean, SmithyTraitCodegen.Args), SmithyTraitCodegen.Output](
94-
s.cacheStoreFactory.make("smithy-trait-codegen-output")
95-
) { case ((inputChanged, codegenArgs), cached) =>
96-
cached
97-
.filter(_ => !inputChanged)
98-
.fold {
99-
SmithyTraitCodegen.generate(codegenArgs)
100-
} { last =>
101-
logger.info("Using cached result of smithy-trait-codegen")
102-
last
103-
}
104-
}
105-
)
88+
Cache.cached(s.cacheStoreFactory.make("smithy-trait-codegen")) {
89+
SmithyTraitCodegen.generate
10690
}
91+
10792
cachedCodegen(args)
10893
}.value,
10994
Compile / sourceGenerators += Def.task {

0 commit comments

Comments
 (0)