Skip to content

Commit 88f0676

Browse files
Legion2facebook-github-bot
authored andcommitted
use correct gradle packageTask and asserts dir for android libraries (#32026)
Summary: Fixes #29577 and react-native-community/upgrade-support#93, when building an android library the package task has a different name, which was not handled correctly in the react.gradle file. The fix uses the existing `packageTask` variable which is correctly set for applications and libraries. This PR also copies the bundled js file into the correct assets directory, which is different from the assets directory of applications. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [Android] [Fixed] - Fixed Android library builds with react.gradle file Pull Request resolved: #32026 Test Plan: Tested with my android library build which includes the `react.gradle` file and the build succeeded. Reviewed By: sshic, ShikaSD Differential Revision: D30368771 Pulled By: cortinico fbshipit-source-id: 8f0df8c4d0fa38d85f7c0b9af56d88799571191d
1 parent 9187e20 commit 88f0676

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

react.gradle

+18-12
Original file line numberDiff line numberDiff line change
@@ -284,25 +284,32 @@ afterEvaluate {
284284
into(file(config."jsBundleDir${targetName}"))
285285
} else {
286286
into ("$buildDir/intermediates")
287-
into ("assets/${targetPath}") {
288-
from(jsBundleDir)
289-
}
287+
if (isAndroidLibrary) {
288+
into ("library_assets/${variant.name}/out") {
289+
from(jsBundleDir)
290+
}
291+
} else {
292+
into ("assets/${targetPath}") {
293+
from(jsBundleDir)
294+
}
290295

291-
// Workaround for Android Gradle Plugin 3.2+ new asset directory
292-
into ("merged_assets/${variant.name}/merge${targetName}Assets/out") {
293-
from(jsBundleDir)
294-
}
296+
// Workaround for Android Gradle Plugin 3.2+ new asset directory
297+
into ("merged_assets/${variant.name}/merge${targetName}Assets/out") {
298+
from(jsBundleDir)
299+
}
295300

296-
// Workaround for Android Gradle Plugin 3.4+ new asset directory
297-
into ("merged_assets/${variant.name}/out") {
298-
from(jsBundleDir)
301+
// Workaround for Android Gradle Plugin 3.4+ new asset directory
302+
into ("merged_assets/${variant.name}/out") {
303+
from(jsBundleDir)
304+
}
299305
}
300306
}
301307

302308
// mergeAssets must run first, as it clears the intermediates directory
303309
dependsOn(variant.mergeAssetsProvider.get())
304310

305311
enabled(currentBundleTask.enabled)
312+
dependsOn(currentBundleTask)
306313
}
307314

308315
// mergeResources task runs before the bundle file is copied to the intermediate asset directory from Android plugin 4.1+.
@@ -352,8 +359,7 @@ afterEvaluate {
352359
}
353360

354361
if (enableVmCleanup) {
355-
def task = tasks.findByName("package${targetName}")
356-
task.doFirst(vmSelectionAction)
362+
packageTask.doFirst(vmSelectionAction)
357363
}
358364
}
359365
}

0 commit comments

Comments
 (0)