From c484b2d861604edaff7401f7d75ca856b4b416f0 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Thu, 2 Oct 2025 14:09:26 -0400 Subject: [PATCH] Fix Gradle task to properly detect Smithy model changes 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. --- buildSrc/src/main/kotlin/CodegenTestCommon.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/CodegenTestCommon.kt b/buildSrc/src/main/kotlin/CodegenTestCommon.kt index dc2b132fd9c..383b548a0d5 100644 --- a/buildSrc/src/main/kotlin/CodegenTestCommon.kt +++ b/buildSrc/src/main/kotlin/CodegenTestCommon.kt @@ -236,8 +236,13 @@ fun Project.registerGenerateSmithyBuildTask( this.tasks.register("generateSmithyBuild") { description = "generate smithy-build.json" outputs.file(project.projectDir.resolve("smithy-build.json")) - // NOTE: This is not working. - allCodegenTests.flatMap { it.imports }.forEach { inputs.file(project.projectDir.resolve(it)) } + // Declare Smithy model files as inputs so task reruns when they change + allCodegenTests.flatMap { it.imports }.forEach { + val resolvedPath = project.projectDir.resolve(it) + if (resolvedPath.exists()) { + inputs.file(resolvedPath) + } + } doFirst { project.projectDir.resolve("smithy-build.json")