Skip to content

Commit e42a3a6

Browse files
Kudofacebook-github-bot
authored andcommitted
Migrate jsc-android to mavenCentral (#47972)
Summary: Since people mostly use Hermes, it doesn't make sense to download jsc-android from npm even when jsc is not used. This PR migrates the jsc-android to [mavenCentral](https://repo1.maven.org/maven2/io/github/react-native-community/jsc-android/2026004.0.0/). The new jsc-android supports Android 16KB memory page sizes and packaged by prefab. Relevant PRs: - react-native-community/jsc-android-buildscripts#184 - react-native-community/jsc-android-buildscripts#185 ## Changelog: [ANDROID] [CHANGED] - Migrate jsc-android to mavenCentral Pull Request resolved: #47972 Test Plan: CI passed Reviewed By: cipolleschi Differential Revision: D66772407 Pulled By: cortinico fbshipit-source-id: e34d2d138996e394763ef67d7aad65bb3e7b13dc
1 parent c9ac94a commit e42a3a6

File tree

12 files changed

+13
-243
lines changed

12 files changed

+13
-243
lines changed

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/internal/PrepareJSCTask.kt

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,19 @@ internal object DependencyUtils {
4747
repo.content { it.excludeGroup("com.facebook.react") }
4848
}
4949
}
50-
// Android JSC is installed from npm
51-
mavenRepoFromURI(File(reactNativeDir, "../jsc-android/dist").toURI()) { repo ->
52-
repo.content { it.includeGroup("org.webkit") }
53-
}
5450
repositories.google { repo ->
5551
repo.content {
5652
// We don't want to fetch JSC or React from Google
5753
it.excludeGroup("org.webkit")
54+
it.excludeGroup("io.github.react-native-community")
5855
it.excludeGroup("com.facebook.react")
5956
}
6057
}
6158
mavenRepoFromUrl("https://www.jitpack.io") { repo ->
6259
repo.content {
6360
// We don't want to fetch JSC or React from JitPack
6461
it.excludeGroup("org.webkit")
62+
it.excludeGroup("io.github.react-native-community")
6563
it.excludeGroup("com.facebook.react")
6664
}
6765
}

packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt

Lines changed: 0 additions & 129 deletions
This file was deleted.

packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,6 @@ class DependencyUtilsTest {
5656
.isNotNull()
5757
}
5858

59-
@Test
60-
fun configureRepositories_containsJscLocalMavenRepo() {
61-
val projectFolder = tempFolder.newFolder()
62-
val reactNativeDir = tempFolder.newFolder("react-native")
63-
val jscAndroidDir = tempFolder.newFolder("jsc-android")
64-
val repositoryURI = URI.create("file://${jscAndroidDir}/dist")
65-
val project = createProject(projectFolder)
66-
67-
configureRepositories(project, reactNativeDir)
68-
69-
assertThat(
70-
project.repositories.firstOrNull {
71-
it is MavenArtifactRepository && it.url == repositoryURI
72-
})
73-
.isNotNull()
74-
}
75-
7659
@Test
7760
fun configureRepositories_containsMavenCentral() {
7861
val repositoryURI = URI.create("https://repo.maven.apache.org/maven2/")

packages/helloworld/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def enableProguardInReleaseBuilds = false
8181
* The preferred build flavor of JavaScriptCore (JSC)
8282
*
8383
* For example, to use the international variant, you can use:
84-
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
84+
* `def jscFlavor = "io.github.react-native-community:jsc-android-intl:2026004.+"`
8585
*
8686
* The international variant includes ICU i18n library and necessary data
8787
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
8888
* give correct results when using with locales other than en-US. Note that
8989
* this variant is about 6MiB larger per architecture than default.
9090
*/
91-
def jscFlavor = 'org.webkit:android-jsc:+'
91+
def jscFlavor = "io.github.react-native-community:jsc-android:2026004.+"
9292

9393
android {
9494
ndkVersion rootProject.ext.ndkVersion

packages/react-native/ReactAndroid/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,6 @@ val prepareGlog by
396396
outputDir.set(File(thirdPartyNdkDir, "glog"))
397397
}
398398

399-
// Create Android native library module based on jsc from npm
400-
val prepareJSC by
401-
tasks.registering(PrepareJSCTask::class) {
402-
jscPackagePath.set(findNodeModulePath(projectDir, "jsc-android"))
403-
outputDir = project.layout.buildDirectory.dir("third-party-ndk/jsc")
404-
}
405-
406399
val prepareKotlinBuildScriptModel by
407400
tasks.registering {
408401
// This task is run when Gradle Sync is running.
@@ -577,7 +570,6 @@ android {
577570
prepareFolly,
578571
prepareGlog,
579572
prepareGtest,
580-
prepareJSC,
581573
preparePrefab)
582574
tasks.getByName("generateCodegenSchemaFromJavaScript").dependsOn(buildCodegenCLI)
583575
prepareKotlinBuildScriptModel.dependsOn("preBuild")
@@ -664,9 +656,10 @@ dependencies {
664656
compileOnly(libs.javax.annotation.api)
665657
api(libs.javax.inject)
666658

667-
// It's up to the consumer to decide if hermes should be included or not.
668-
// Therefore hermes-engine is a compileOnly dependency.
659+
// It's up to the consumer to decide if hermes/jsc should be included or not.
660+
// Therefore hermes-engine and jsc are compileOnly dependencies.
669661
compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine"))
662+
compileOnly(libs.jsc.android)
670663

671664
testImplementation(libs.junit)
672665
testImplementation(libs.assertj)

packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ endfunction()
4343
# Third-party prefabs
4444
find_package(hermes-engine REQUIRED CONFIG)
4545
find_package(fbjni REQUIRED CONFIG)
46+
find_package(jsc-android REQUIRED CONFIG)
4647
add_library(fbjni ALIAS fbjni::fbjni)
48+
add_library(jsc ALIAS jsc-android::jsc)
4749

4850
# Third-party downloaded targets
4951
add_react_third_party_ndk_subdir(glog)
@@ -52,7 +54,6 @@ add_react_third_party_ndk_subdir(double-conversion)
5254
add_react_third_party_ndk_subdir(fast_float)
5355
add_react_third_party_ndk_subdir(fmt)
5456
add_react_third_party_ndk_subdir(folly)
55-
add_react_third_party_ndk_subdir(jsc)
5657
add_react_third_party_ndk_subdir(googletest)
5758

5859
# Common targets

packages/react-native/ReactAndroid/src/main/jni/third-party/jsc/CMakeLists.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/react-native/gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ fresco = "3.5.0"
2121
infer-annotation = "0.18.0"
2222
javax-annotation-api = "1.3.2"
2323
javax-inject = "1"
24+
jsc-android = "2026004.0.1"
2425
jsr305 = "3.0.2"
2526
junit = "4.13.2"
2627
kotlin = "2.0.21"
@@ -66,6 +67,7 @@ okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
6667
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
6768
javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject" }
6869
javax-annotation-api = { module = "javax.annotation:javax.annotation-api", version.ref = "javax-annotation-api" }
70+
jsc-android = { module = "io.github.react-native-community:jsc-android", version.ref = "jsc-android" }
6971

7072
junit = {module = "junit:junit", version.ref = "junit" }
7173
assertj = {module = "org.assertj:assertj-core", version.ref = "assertj" }

packages/react-native/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@
128128
"glob": "^7.1.1",
129129
"invariant": "^2.2.4",
130130
"jest-environment-node": "^29.6.3",
131-
"jsc-android": "^250231.0.0",
132131
"memoize-one": "^5.0.0",
133132
"metro-runtime": "^0.81.0",
134133
"metro-source-map": "^0.81.0",

0 commit comments

Comments
 (0)