@callstack/react-native-brownfield 6.0.1 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt +12 -12
  3. package/android/src/main/java/com/callstack/reactnativebrownfield/RetryableOnce.kt +27 -0
  4. package/android/src/test/java/com/callstack/reactnativebrownfield/RetryableOnceTest.kt +37 -0
  5. package/gradle-plugin/brownfield/build.gradle.kts +4 -0
  6. package/gradle-plugin/brownfield/gradle/libs.versions.toml +2 -0
  7. package/gradle-plugin/brownfield/gradle.properties +1 -1
  8. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNBrownfieldPlugin.kt +24 -7
  9. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt +4 -37
  10. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt +206 -104
  11. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/ResourceTaskProcessor.kt +201 -4
  12. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantHelper.kt +7 -0
  13. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/VariantTaskProvider.kt +4 -0
  14. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/GradleExclude.kt +31 -0
  15. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/MergeClassesTask.kt +2 -0
  16. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/shared/PublishingMetadataInjector.kt +28 -3
  17. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/Extension.kt +14 -1
  18. package/gradle-plugin/brownfield/src/main/kotlin/com/callstack/react/brownfield/utils/TaskOutputs.kt +40 -0
  19. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/plugin/AgpCompatibilityMatrixTest.kt +14 -6
  20. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/plugin/HardExcludePredicateTest.kt +28 -0
  21. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/ConfigureProcessJniTaskTest.kt +60 -0
  22. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/CopyExplodedResTaskTest.kt +368 -0
  23. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/JniLibsPlanTest.kt +252 -0
  24. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/MergeClassesLocalJarsTest.kt +73 -0
  25. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/MetroResDirWiringTest.kt +39 -0
  26. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/processors/ProcessAndCopyJniLibsTaskTest.kt +136 -0
  27. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/shared/GradleExcludesTest.kt +81 -0
  28. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/shared/PublishingMetadataInjectorTest.kt +56 -0
  29. package/gradle-plugin/brownfield/src/test/kotlin/com/callstack/react/brownfield/utils/ExtensionTest.kt +5 -0
  30. package/ios/ReactNativeBrownfield.swift +3 -1
  31. package/ios/ReactNativeBrownfieldModule.mm +35 -7
  32. package/lib/commonjs/expo-config-plugin/android/utils/constants.js +1 -1
  33. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  34. package/lib/commonjs/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  35. package/lib/commonjs/expo-config-plugin/template/android/build.gradle.kts +1 -1
  36. package/lib/commonjs/index.js +1 -1
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/scaffold/index.js +1 -1
  39. package/lib/commonjs/scaffold/index.js.map +1 -1
  40. package/lib/module/expo-config-plugin/android/utils/constants.js +1 -1
  41. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js +1 -1
  42. package/lib/module/expo-config-plugin/android/withAndroidModuleFiles.js.map +1 -1
  43. package/lib/module/expo-config-plugin/template/android/build.gradle.kts +1 -1
  44. package/lib/module/index.js +1 -1
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/scaffold/index.js +1 -1
  47. package/lib/module/scaffold/index.js.map +1 -1
  48. package/lib/typescript/commonjs/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  49. package/lib/typescript/commonjs/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  50. package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +6 -0
  51. package/lib/typescript/commonjs/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
  52. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/scaffold/index.d.ts.map +1 -1
  54. package/lib/typescript/module/src/expo-config-plugin/android/utils/constants.d.ts +2 -2
  55. package/lib/typescript/module/src/expo-config-plugin/android/withAndroidModuleFiles.d.ts.map +1 -1
  56. package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts +6 -0
  57. package/lib/typescript/module/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.d.ts.map +1 -1
  58. package/lib/typescript/module/src/index.d.ts.map +1 -1
  59. package/lib/typescript/module/src/scaffold/index.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/expo-config-plugin/android/utils/constants.ts +1 -1
  62. package/src/expo-config-plugin/android/withAndroidModuleFiles.ts +42 -0
  63. package/src/expo-config-plugin/template/android/build.gradle.kts +1 -1
  64. package/src/expo-config-plugin/types/android/BrownfieldPluginAndroidConfig.ts +7 -0
  65. package/src/index.ts +4 -2
  66. package/src/scaffold/index.ts +1 -0
@@ -40,6 +40,43 @@ function renderMissingDimensionStrategyBlock(
40
40
  return ` missingDimensionStrategy(${args})`;
41
41
  }
42
42
 
43
+ const COORDINATE_PART = /^[A-Za-z0-9._-]+$/;
44
+
45
+ /**
46
+ * Renders `excludeDependencies` as a `configurations.all` block. The Brownfield Gradle plugin
47
+ * leaves anything excluded this way out of the published POM and module.json. Entries become
48
+ * Kotlin string literals, so anything but a plain coordinate is rejected.
49
+ */
50
+ function renderExcludeDependenciesBlock(excludeDependencies: string[]): string {
51
+ // It comes from user JSON, so the type isn't guaranteed.
52
+ if (!Array.isArray(excludeDependencies)) {
53
+ throw new Error(
54
+ 'android.excludeDependencies must be a list of "group:module" or "group" strings.'
55
+ );
56
+ }
57
+ if (excludeDependencies.length === 0) {
58
+ return '';
59
+ }
60
+
61
+ const lines = excludeDependencies.map((entry) => {
62
+ const parts = entry.split(':');
63
+ if (
64
+ parts.length > 2 ||
65
+ !parts.every((part) => COORDINATE_PART.test(part))
66
+ ) {
67
+ throw new Error(
68
+ `android.excludeDependencies: '${entry}' is not in the form "group:module" or "group".`
69
+ );
70
+ }
71
+ const [group, module] = parts;
72
+ return module
73
+ ? ` exclude(group = "${group}", module = "${module}")`
74
+ : ` exclude(group = "${group}")`;
75
+ });
76
+
77
+ return `configurations.all {\n${lines.join('\n')}\n}\n\n`;
78
+ }
79
+
43
80
  export function resolveCompileSdkVersionExpression(
44
81
  config: ResolvedBrownfieldPluginConfigWithAndroid
45
82
  ): string {
@@ -154,6 +191,10 @@ export function createAndroidModule({
154
191
  android.missingDimensionStrategies
155
192
  );
156
193
 
194
+ const excludeDependenciesBlock = renderExcludeDependenciesBlock(
195
+ android.excludeDependencies
196
+ );
197
+
157
198
  // generate module files
158
199
  const files: RenderedTemplateFile[] = [
159
200
  {
@@ -171,6 +212,7 @@ export function createAndroidModule({
171
212
  '{{IS_MINIFY_ENABLED}}': minifyEnabled.toString(),
172
213
  '{{MISSING_DIMENSION_STRATEGIES}}': missingDimensionStrategiesList,
173
214
  '{{MISSING_DIMENSION_STRATEGY_BLOCK}}': missingDimensionStrategyBlock,
215
+ '{{EXCLUDE_DEPENDENCIES_BLOCK}}': excludeDependenciesBlock,
174
216
  }),
175
217
  },
176
218
  {
@@ -47,7 +47,7 @@ reactBrownfield {
47
47
  missingDimensionStrategies = listOf({{MISSING_DIMENSION_STRATEGIES}})
48
48
  }
49
49
 
50
- react {
50
+ {{EXCLUDE_DEPENDENCIES_BLOCK}}react {
51
51
  autolinkLibrariesWithApp()
52
52
  }
53
53
 
@@ -69,6 +69,13 @@ export interface BrownfieldPluginAndroidConfig {
69
69
  * @default []
70
70
  */
71
71
  missingDimensionStrategies?: string[];
72
+
73
+ /**
74
+ * Dependencies to keep out of the published AAR's POM and module.json, as
75
+ * "group:module" or "group" for a whole group, e.g. "com.caverock:androidsvg".
76
+ * @default []
77
+ */
78
+ excludeDependencies?: string[];
72
79
  }
73
80
 
74
81
  /**
package/src/index.ts CHANGED
@@ -96,11 +96,13 @@ const ReactNativeBrownfield = {
96
96
  ): { remove: () => void } => {
97
97
  const subscription = ReactNativeBrownfieldModule.onBrownfieldMessage(
98
98
  (payload) => {
99
+ let data: unknown;
99
100
  try {
100
- callback({ data: JSON.parse(payload.text) });
101
+ data = JSON.parse(payload.text);
101
102
  } catch {
102
- callback({ data: payload.text });
103
+ data = payload.text;
103
104
  }
105
+ callback({ data });
104
106
  }
105
107
  );
106
108
  return { remove: () => subscription.remove() };
@@ -301,6 +301,7 @@ export async function scaffoldBrownfieldInRncCliProject(
301
301
  useLocalGradlePlugin: false,
302
302
  useLocalMaven: false,
303
303
  missingDimensionStrategies: [],
304
+ excludeDependencies: [],
304
305
  },
305
306
  ios: null,
306
307
  debug: options.debug ?? false,