Skip to content

Commit 803f8ca

Browse files
artus9033hurali97
andauthored
fix: duplicate .so resources on cold builds (#414)
* fix: duplicate .so resources on cold builds * fix(ci): fix Android CI cache gates to run whenever gradle plugin files are changed * chore: bump BGP * chore: changeset --------- Co-authored-by: Hur Ali <hurali97@gmail.com>
1 parent dee9559 commit 803f8ca

10 files changed

Lines changed: 26 additions & 11 deletions

File tree

.changeset/plenty-camels-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@callstack/react-native-brownfield': patch
3+
---
4+
5+
fix: duplicated JNI libs on cold publish

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
expo56: ${{ steps.filter.outputs.expo56 }}
2727
androidapp: ${{ steps.filter.outputs.androidapp }}
2828
appleapp: ${{ steps.filter.outputs.appleapp }}
29+
gradle-plugins: ${{ steps.filter.outputs.gradle-plugins }}
2930
ci: ${{ steps.filter.outputs.ci }}
3031
steps:
3132
- name: Checkout
@@ -52,6 +53,8 @@ jobs:
5253
appleapp:
5354
- 'apps/AppleApp/**'
5455
- 'apps/brownfield-example-shared-tests/**'
56+
gradle-plugins:
57+
- 'gradle-plugins/**'
5558
ci:
5659
- '.github/**'
5760
@@ -139,6 +142,7 @@ jobs:
139142
needs.filter.outputs.expo56 == 'true' ||
140143
needs.filter.outputs.androidapp == 'true' ||
141144
needs.filter.outputs.packages == 'true' ||
145+
needs.filter.outputs.gradle-plugins == 'true' ||
142146
needs.filter.outputs.ci == 'true'
143147
) &&
144148
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped')
@@ -169,6 +173,7 @@ jobs:
169173
needs.filter.outputs.rnapp == 'true' ||
170174
needs.filter.outputs.androidapp == 'true' ||
171175
needs.filter.outputs.packages == 'true' ||
176+
needs.filter.outputs.gradle-plugins == 'true' ||
172177
needs.filter.outputs.ci == 'true'
173178
) &&
174179
(needs.build-lint.result == 'success' || needs.build-lint.result == 'skipped')

apps/RNApp/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
classpath("com.android.tools.build:gradle")
1717
classpath("com.facebook.react:react-native-gradle-plugin")
1818
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
19-
classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha04-SNAPSHOT")
19+
classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha05-SNAPSHOT")
2020
}
2121
}
2222

apps/scripts/prepare-android-build-gradle-for-ci.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!projectDirName) {
99

1010
const __filename = fileURLToPath(import.meta.url);
1111
const __dirname = path.dirname(__filename);
12-
const SNAPSHOT_VERSION = '2.0.0-alpha04-SNAPSHOT';
12+
const SNAPSHOT_VERSION = '2.0.0-alpha05-SNAPSHOT';
1313
const targetPath = path.resolve(
1414
__dirname,
1515
'..',

gradle-plugins/react/brownfield/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROJECT_ID=com.callstack.react.brownfield
22
ARTIFACT_ID=brownfield-gradle-plugin
3-
VERSION=2.0.0-alpha04
3+
VERSION=2.0.0-alpha05
44
GROUP=com.callstack.react
55
IMPLEMENTATION_CLASS=com.callstack.react.brownfield.plugin.RNBrownfieldPlugin
66

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/plugin/RNSourceSets.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ object RNSourceSets {
7171
val appBuildDir = getAppBuildDir()
7272
sourceSet.assets.srcDirs(bundlePathSegments.map { "$appBuildDir/generated/assets/$it" })
7373
sourceSet.res.srcDirs(bundlePathSegments.map { "$appBuildDir/generated/res/$it" })
74-
sourceSet.jniLibs.srcDirs("libs${variantName.capitalized()}")
74+
if (extension.useStrippedSoFiles) {
75+
val capitalizedVariantName = variantName.capitalized()
76+
val libsDir = project.layout.projectDirectory.dir("libs$capitalizedVariantName")
77+
val copyTaskName = "copy${capitalizedVariantName}LibSources"
78+
sourceSet.jniLibs.srcDir(
79+
project.files(libsDir).builtBy(copyTaskName),
80+
)
81+
}
7582
if (Utils.hasExpoUpdates(appProject, variant.name)) {
7683
val updateResourcesTask = appProject.tasks.named(updateResourcesPathSegment)
7784
sourceSet.assets.srcDir(

gradle-plugins/react/brownfield/src/main/kotlin/com/callstack/react/brownfield/processors/JNILibsProcessor.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ class JNILibsProcessor(val project: Project) {
2525
}
2626

2727
val androidExtension = project.extensions.getByName("android") as LibraryExtension
28-
val copyTask = copySoLibsTask(variantName)
28+
copySoLibsTask(variantName)
2929

3030
mergeJniLibsTask.configure {
31-
it.dependsOn(copyTask)
32-
3331
it.doFirst {
3432
val projectExt = project.extensions.getByType(Extension::class.java)
3533
val existingJNILibs =

packages/react-native-brownfield/src/expo-config-plugin/android/__tests__/gradleHelpers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('gradleHelpers', () => {
1616
}`;
1717

1818
expect(modifyRootBuildGradle(contents)).toContain(
19-
'classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha04")'
19+
'classpath("com.callstack.react:brownfield-gradle-plugin:2.0.0-alpha05")'
2020
);
2121
});
2222

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const BROWNFIELD_PLUGIN_VERSION = '2.0.0-alpha04';
1+
export const BROWNFIELD_PLUGIN_VERSION = '2.0.0-alpha05';
22
export const brownfieldGradlePluginDependency = `classpath("com.callstack.react:brownfield-gradle-plugin:${BROWNFIELD_PLUGIN_VERSION}")`;

scripts/__tests__/generate-brownfield-gradle-plugin-release-notes.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ test('supports prerelease versions when finding the previous plugin tag', () =>
2525
const previousTag = findPreviousPluginTag(
2626
[
2727
'brownfield-gradle-plugin/v2.0.0-alpha01',
28-
'brownfield-gradle-plugin/v2.0.0-alpha04',
28+
'brownfield-gradle-plugin/v2.0.0-alpha05',
2929
'brownfield-gradle-plugin/v2.0.0-beta01',
3030
'brownfield-gradle-plugin/v2.0.0',
3131
],
3232
'2.0.0-beta01'
3333
);
3434

35-
assert.equal(previousTag, 'brownfield-gradle-plugin/v2.0.0-alpha04');
35+
assert.equal(previousTag, 'brownfield-gradle-plugin/v2.0.0-alpha05');
3636
});
3737

3838
test('treats a stable release as newer than its prereleases', () => {

0 commit comments

Comments
 (0)