From 2f20fb63e8937fac5bf13c03bcd3eeca4d3c4fe1 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Mon, 18 Mar 2024 18:28:00 +0100 Subject: [PATCH 1/5] fix: when copying React Native bundle source map, rely on input/output of copy task It worked previously, as Sentry Gradle plugin was making the mergeAssets run every time (breaking up to date state) --- WordPress/build.gradle | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 019b399b0663..419c1ae4ebbb 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -718,18 +718,14 @@ if (project.hasProperty("debugStoreFile")) { // service during the build process. android { applicationVariants.all { variant -> - variant.mergeAssetsProvider.configure { - doLast { - // Copy bundle and source map files - copy { - from(outputDir) - into("${buildDir}/react-native-bundle-source-map") - include("*.bundle", "*.bundle.map") - } + tasks.register("copy${variant.name.capitalize()}ReactNativeBundleSourceMap", Copy) { + from("${buildDir}/intermediates/assets/${variant.name}") + into("${buildDir}/react-native-bundle-source-map") + include("*.bundle", "*.bundle.map") + } - // Delete source maps - delete(fileTree(dir: outputDir, includes: ['**/*.bundle.map'])) - } + variant.mergeAssetsProvider.configure { + finalizedBy("copy${variant.name.capitalize()}ReactNativeBundleSourceMap") } } } From 5671a2df548e1a73bb54d9068b6fee5577f78b6a Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Tue, 19 Mar 2024 09:46:23 +0100 Subject: [PATCH 2/5] fix: bring back deleting `*.bundle.map` files for assets --- WordPress/build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 419c1ae4ebbb..e7a43bc9e931 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -718,10 +718,17 @@ if (project.hasProperty("debugStoreFile")) { // service during the build process. android { applicationVariants.all { variant -> + def variantAssets = "${buildDir}/intermediates/assets/${variant.name}" + + tasks.register("delete${variant.name.capitalize()}ReactNativeBundleSourceMap", Delete) { + delete(fileTree(dir: variantAssets, includes: ['**/*.bundle.map'])) + } + tasks.register("copy${variant.name.capitalize()}ReactNativeBundleSourceMap", Copy) { from("${buildDir}/intermediates/assets/${variant.name}") into("${buildDir}/react-native-bundle-source-map") include("*.bundle", "*.bundle.map") + finalizedBy("delete${variant.name.capitalize()}ReactNativeBundleSourceMap") } variant.mergeAssetsProvider.configure { From edf18af1f515c04f1e5e42bc92908f59f107c760 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Tue, 19 Mar 2024 09:52:46 +0100 Subject: [PATCH 3/5] build: configure react native bundle source map tasks lazily --- WordPress/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index e7a43bc9e931..d24e6a187d74 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -717,7 +717,7 @@ if (project.hasProperty("debugStoreFile")) { // Copy React Native JavaScript bundle and source map so they can be upload it to the Crash logging // service during the build process. android { - applicationVariants.all { variant -> + applicationVariants.configureEach { variant -> def variantAssets = "${buildDir}/intermediates/assets/${variant.name}" tasks.register("delete${variant.name.capitalize()}ReactNativeBundleSourceMap", Delete) { From 6ea143cef4e471a198fb8a192367e22e69e8962f Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Tue, 19 Mar 2024 11:11:51 +0100 Subject: [PATCH 4/5] refactor: use assets path from `mergeAssetsProvider` instead of hardcoded one --- WordPress/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index d24e6a187d74..85dcee987880 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -718,7 +718,7 @@ if (project.hasProperty("debugStoreFile")) { // service during the build process. android { applicationVariants.configureEach { variant -> - def variantAssets = "${buildDir}/intermediates/assets/${variant.name}" + def variantAssets = variant.mergeAssetsProvider.get().outputDir.get() tasks.register("delete${variant.name.capitalize()}ReactNativeBundleSourceMap", Delete) { delete(fileTree(dir: variantAssets, includes: ['**/*.bundle.map'])) From 60b25713d6c50109cbb2d4ac9b6b4c923aa8b564 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Tue, 19 Mar 2024 11:13:39 +0100 Subject: [PATCH 5/5] fix: use `variantAssets` var instead of hardcode path --- WordPress/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 85dcee987880..8dc5d49ac99c 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -725,7 +725,7 @@ android { } tasks.register("copy${variant.name.capitalize()}ReactNativeBundleSourceMap", Copy) { - from("${buildDir}/intermediates/assets/${variant.name}") + from(variantAssets) into("${buildDir}/react-native-bundle-source-map") include("*.bundle", "*.bundle.map") finalizedBy("delete${variant.name.capitalize()}ReactNativeBundleSourceMap")