Skip to content

Commit bbd4d31

Browse files
committed
First couple improvements
1 parent a456b89 commit bbd4d31

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ object SmithyTraitCodegen {
136136
.build()
137137
val plugin = new TraitCodegenPlugin()
138138
plugin.execute(context)
139-
os.move(genDir / "META-INF", metaDir / "META-INF")
139+
140+
// If there were no shapes to generate, this won't exist
141+
if (os.exists(genDir / "META-INF"))
142+
os.move(genDir / "META-INF", metaDir / "META-INF")
143+
140144
Output(metaDir = metaDir.toIO, javaDir = genDir.toIO)
141145
}
142146

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ object SmithyTraitCodegenPlugin extends AutoPlugin {
3939
"Dependencies to be added into codegen model"
4040
)
4141

42+
val smithyTraitCodegenSourceDirectory = settingKey[File](
43+
"The directory where the smithy sources are located"
44+
)
45+
46+
val smithyTraitCodegenTargetDirectory = settingKey[File](
47+
"The directory where the generated Java sources and resources will be placed"
48+
)
49+
4250
}
4351

4452
import autoImport.*
4553

4654
override def projectSettings: Seq[Setting[?]] = Seq(
55+
smithyTraitCodegenSourceDirectory := (Compile / resourceDirectory).value / "META-INF" / "smithy",
56+
smithyTraitCodegenTargetDirectory := (Compile / target).value,
4757
Keys.generateSmithyTraits := Def.task {
4858
import sbt.util.CacheImplicits.*
4959
val s = (Compile / streams).value
@@ -64,8 +74,8 @@ object SmithyTraitCodegenPlugin extends AutoPlugin {
6474
val args = SmithyTraitCodegen.Args(
6575
javaPackage = smithyTraitCodegenJavaPackage.value,
6676
smithyNamespace = smithyTraitCodegenNamespace.value,
67-
targetDir = os.Path((Compile / target).value),
68-
smithySourcesDir = PathRef((Compile / resourceDirectory).value / "META-INF" / "smithy"),
77+
targetDir = os.Path(smithyTraitCodegenTargetDirectory.value),
78+
smithySourcesDir = PathRef(smithyTraitCodegenSourceDirectory.value),
6979
dependencies = jars.map(PathRef(_)).toList,
7080
)
7181
val cachedCodegen =
@@ -82,7 +92,7 @@ object SmithyTraitCodegenPlugin extends AutoPlugin {
8292
.fold {
8393
SmithyTraitCodegen.generate(codegenArgs)
8494
} { last =>
85-
logger.info(s"Using cached result of smithy-trait-codegen")
95+
logger.info("Using cached result of smithy-trait-codegen")
8696
last
8797
}
8898
}

0 commit comments

Comments
 (0)