From 79873748df2f5e5ed1ef438beded8b8a81cf54e9 Mon Sep 17 00:00:00 2001 From: "Deven T. Corzine" Date: Sat, 28 Dec 2024 15:42:44 -0500 Subject: [PATCH] Fix registerGenerateCargoWorkspaceTask() to declare the output file. (#3954) ## Motivation and Context When I tried to build the main branch with `./gradlew assemble`, I got the following error. This commit fixes the problem. ``` FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':aws:sdk-adhoc-test:generateCargoWorkspace'. > java.io.FileNotFoundException: /home/deven/git/smithy-rs/aws/sdk-adhoc-test/build/smithyprojections/sdk-adhoc-test/Cargo.toml (No such file or directory) ``` ## Description Fixes `registerGenerateCargoWorkspaceTask()` to declare the output file correctly when creating the `Cargo.toml` file, so Gradle can track the dependencies properly. ## Testing Without this change, `./gradlew clean; ./gradlew assemble` failed every time. With this change, it works. ## Checklist ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --- buildSrc/src/main/kotlin/CodegenTestCommon.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/CodegenTestCommon.kt b/buildSrc/src/main/kotlin/CodegenTestCommon.kt index 1ee6ee7972..7b05e6651f 100644 --- a/buildSrc/src/main/kotlin/CodegenTestCommon.kt +++ b/buildSrc/src/main/kotlin/CodegenTestCommon.kt @@ -271,9 +271,10 @@ fun Project.registerGenerateCargoWorkspaceTask( val properties = PropertyRetriever(rootProject, this) project.tasks.register("generateCargoWorkspace") { description = "generate Cargo.toml workspace file" + val path = project.buildDir.resolve("$workingDirUnderBuildDir/Cargo.toml") + outputs.file(path) doFirst { - project.buildDir.resolve("$workingDirUnderBuildDir/Cargo.toml") - .writeText(generateCargoWorkspace(pluginName, codegenTests(properties, allCodegenTests))) + path.writeText(generateCargoWorkspace(pluginName, codegenTests(properties, allCodegenTests))) } } }