You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add gradle task to automatically copy the codegen artifacts for paper (#2168)
## Description
When changing native props on Fabric, codegen generates corresponding
interfaces and delegates. To make sure both implementations are
consistent, we implement those interfaces on Paper too. Currently, after
generating interfaces using codegen, developer needs to copy
corresponding files for paper manually. This task adds Gradle task, that
automates this.
## Changes
Add new task to build Gradle and necessary properties:
- codegen artifacts dir and paper dir
- flag in both fabric apps that indicates that copying should be
performed (we do want this task to be performed only when developing the
library)
## Test code and steps to reproduce
Remove `textColor` from `src/fabric/SearchBarNativeComponent.ts` and run
` ./gradlew generateCodegenArtifactsFromSchema` in
`/react-native-screens/FabricExample/android`. That should automatically
copy regenerated files to paper directory.
---------
Co-authored-by: Kacper Kafara <kacper.kafara@swmansion.com>
if (!project.hasProperty('codegenArtifactsPaperDestination')) {
202
+
thrownewException('[RNScreens] Please fill codegenArtifactsPaperDestination variable in android/gradle.properties correct path to paper paper destination')
if (!existingFilesMap.containsKey(generatedFile.name)) {
248
+
logger.warn("[RNScreens] ${generatedFile.name} not found in paper dir, if it's used in Android you need to copy it manually and implement yourself before using auto-copy feature")
249
+
}
250
+
}
251
+
252
+
if (existingFiles.size() ==0) {
253
+
logger.warn("[RNScreens] Paper destination with codegen interfaces is empty. This might be okay if you don't have any interfaces/delegates used in Android, if that's not the case please check if codegenArtifactsPaperDestination in android/gradle.properties is correct")
254
+
}
255
+
256
+
if (existingFiles.size() > generatedFiles.size()) {
257
+
thrownewException("[RNScreens] Number od generated artifacts should be greather then or equal to paper interfaces. Please check if codegenArtifactsSource in android/gradle.properties is correct")
258
+
}
259
+
260
+
copy {
261
+
from absoluteCodegenArtifactsSource
262
+
include existingFiles.collect { it.name }
263
+
into absoluteCodegenArtifactsPaperDestination
264
+
}
265
+
}
266
+
}
267
+
268
+
if (isScreensExampleApp() && isNewArchitectureEnabled()) {
Copy file name to clipboardExpand all lines: android/gradle.properties
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -21,3 +21,10 @@ android.useAndroidX=true
21
21
android.enableJetifier=true
22
22
23
23
kotlin.code.style=official
24
+
25
+
# Path to codegen output directory with this library view manager's interfaces & delegates. Used by `copyCodegenArtifacts` task that helps to synchronise newly generated files with their Paper conterparts.
# Path to directory with view manager's interfaces & delegates used while running on Paper architecture. This property is used as output path for `copyCodegenArtifacts` task.
29
+
# Used for task (copyCodegenArtifacts) that automates copying those interfaces/delegates when codegen is run
0 commit comments