From 1a9fb6cb682aa5ff83462e1e2869eb99f3b873fd Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 28 Jul 2022 11:33:02 -0700 Subject: [PATCH] Make sure *.ts files are considered for task avoidance in the Gradle Plugin (#34296) Summary: I've realized that the gradle plugin is currently looking at `.js` files for task re-execution. This means that, while the *.ts would still be considered when the codegen is invoked, an edit on one of those file, won't retrigger the codegen on Android. This change fixes it so that we consider both `*.ts` and `*.js` files. ## Changelog [Android] [Fixed] - Make sure *.ts files are considered for task avoidance in the Gradle Plugin Pull Request resolved: https://github.com/facebook/react-native/pull/34296 Test Plan: Tests are attached. Reviewed By: cipolleschi Differential Revision: D38246125 Pulled By: cortinico fbshipit-source-id: 80efcc9ef747c598ca040d65b25d270593c8aed2 --- .../com/facebook/react/tasks/GenerateCodegenSchemaTask.kt | 1 + .../facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt index ba2eeb2ffd1687..ea4dfcb0b9a99e 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt @@ -33,6 +33,7 @@ abstract class GenerateCodegenSchemaTask : Exec() { val jsInputFiles = project.fileTree(jsRootDir) { it.include("**/*.js") + it.include("**/*.ts") it.exclude("**/generated/source/codegen/**/*") } diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt index 68af7866b0470c..74304b7d077fb6 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTaskTest.kt @@ -29,15 +29,17 @@ class GenerateCodegenSchemaTaskTest { val jsRootDir = tempFolder.newFolder("js").apply { File(this, "file.js").createNewFile() + File(this, "file.ts").createNewFile() File(this, "ignore.txt").createNewFile() } val task = createTestTask { it.jsRootDir.set(jsRootDir) } assertEquals(jsRootDir, task.jsInputFiles.dir) - assertEquals(setOf("**/*.js"), task.jsInputFiles.includes) - assertEquals(1, task.jsInputFiles.files.size) - assertEquals(setOf(File(jsRootDir, "file.js")), task.jsInputFiles.files) + assertEquals(setOf("**/*.js", "**/*.ts"), task.jsInputFiles.includes) + assertEquals(2, task.jsInputFiles.files.size) + assertEquals( + setOf(File(jsRootDir, "file.js"), File(jsRootDir, "file.ts")), task.jsInputFiles.files) } @Test