Skip to content

Commit bab3bbb

Browse files
authored
Fix Gradle task to properly detect Smithy model changes (#4326)
The `generateSmithyBuild` task was not correctly declaring Smithy model files as inputs, causing it to not regenerate when models changed. This fixes the path resolution and adds an existence check for the input files. ## Problem When running `./gradlew codegen-server-test:assemble`, the task would not regenerate the server code when Smithy model files were modified because the Gradle task inputs were not properly declared. ## Solution - Fixed path resolution from `rootProject.projectDir.resolve(it)` to `project.projectDir.resolve(it)` since import paths are relative to the project directory - Added existence check to only register files as inputs if they actually exist - Updated comment to explain what the code does ## Testing - Verified that the task now properly detects changes to Smithy model files - Confirmed that `./gradlew codegen-server-test:assemble` regenerates code when models change
1 parent 4ac79e6 commit bab3bbb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

buildSrc/src/main/kotlin/CodegenTestCommon.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,13 @@ fun Project.registerGenerateSmithyBuildTask(
236236
this.tasks.register("generateSmithyBuild") {
237237
description = "generate smithy-build.json"
238238
outputs.file(project.projectDir.resolve("smithy-build.json"))
239-
// NOTE: This is not working.
240-
allCodegenTests.flatMap { it.imports }.forEach { inputs.file(project.projectDir.resolve(it)) }
239+
// Declare Smithy model files as inputs so task reruns when they change
240+
allCodegenTests.flatMap { it.imports }.forEach {
241+
val resolvedPath = project.projectDir.resolve(it)
242+
if (resolvedPath.exists()) {
243+
inputs.file(resolvedPath)
244+
}
245+
}
241246

242247
doFirst {
243248
project.projectDir.resolve("smithy-build.json")

0 commit comments

Comments
 (0)