Skip to content

Commit

Permalink
Migrate jsc-android to mavenCentral (#47972)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Kudo authored and facebook-github-bot committed Dec 6, 2024
1 parent c9ac94a commit e42a3a6
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 243 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@ internal object DependencyUtils {
repo.content { it.excludeGroup("com.facebook.react") }
}
}
// Android JSC is installed from npm
mavenRepoFromURI(File(reactNativeDir, "../jsc-android/dist").toURI()) { repo ->
repo.content { it.includeGroup("org.webkit") }
}
repositories.google { repo ->
repo.content {
// We don't want to fetch JSC or React from Google
it.excludeGroup("org.webkit")
it.excludeGroup("io.github.react-native-community")
it.excludeGroup("com.facebook.react")
}
}
mavenRepoFromUrl("https://www.jitpack.io") { repo ->
repo.content {
// We don't want to fetch JSC or React from JitPack
it.excludeGroup("org.webkit")
it.excludeGroup("io.github.react-native-community")
it.excludeGroup("com.facebook.react")
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,6 @@ class DependencyUtilsTest {
.isNotNull()
}

@Test
fun configureRepositories_containsJscLocalMavenRepo() {
val projectFolder = tempFolder.newFolder()
val reactNativeDir = tempFolder.newFolder("react-native")
val jscAndroidDir = tempFolder.newFolder("jsc-android")
val repositoryURI = URI.create("file://${jscAndroidDir}/dist")
val project = createProject(projectFolder)

configureRepositories(project, reactNativeDir)

assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
.isNotNull()
}

@Test
fun configureRepositories_containsMavenCentral() {
val repositoryURI = URI.create("https://repo.maven.apache.org/maven2/")
Expand Down
4 changes: 2 additions & 2 deletions packages/helloworld/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def enableProguardInReleaseBuilds = false
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
* `def jscFlavor = "io.github.react-native-community:jsc-android-intl:2026004.+"`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
def jscFlavor = "io.github.react-native-community:jsc-android:2026004.+"

android {
ndkVersion rootProject.ext.ndkVersion
Expand Down
13 changes: 3 additions & 10 deletions packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,6 @@ val prepareGlog by
outputDir.set(File(thirdPartyNdkDir, "glog"))
}

// Create Android native library module based on jsc from npm
val prepareJSC by
tasks.registering(PrepareJSCTask::class) {
jscPackagePath.set(findNodeModulePath(projectDir, "jsc-android"))
outputDir = project.layout.buildDirectory.dir("third-party-ndk/jsc")
}

val prepareKotlinBuildScriptModel by
tasks.registering {
// This task is run when Gradle Sync is running.
Expand Down Expand Up @@ -577,7 +570,6 @@ android {
prepareFolly,
prepareGlog,
prepareGtest,
prepareJSC,
preparePrefab)
tasks.getByName("generateCodegenSchemaFromJavaScript").dependsOn(buildCodegenCLI)
prepareKotlinBuildScriptModel.dependsOn("preBuild")
Expand Down Expand Up @@ -664,9 +656,10 @@ dependencies {
compileOnly(libs.javax.annotation.api)
api(libs.javax.inject)

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

testImplementation(libs.junit)
testImplementation(libs.assertj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ endfunction()
# Third-party prefabs
find_package(hermes-engine REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_package(jsc-android REQUIRED CONFIG)
add_library(fbjni ALIAS fbjni::fbjni)
add_library(jsc ALIAS jsc-android::jsc)

# Third-party downloaded targets
add_react_third_party_ndk_subdir(glog)
Expand All @@ -52,7 +54,6 @@ add_react_third_party_ndk_subdir(double-conversion)
add_react_third_party_ndk_subdir(fast_float)
add_react_third_party_ndk_subdir(fmt)
add_react_third_party_ndk_subdir(folly)
add_react_third_party_ndk_subdir(jsc)
add_react_third_party_ndk_subdir(googletest)

# Common targets
Expand Down

This file was deleted.

2 changes: 2 additions & 0 deletions packages/react-native/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ fresco = "3.5.0"
infer-annotation = "0.18.0"
javax-annotation-api = "1.3.2"
javax-inject = "1"
jsc-android = "2026004.0.1"
jsr305 = "3.0.2"
junit = "4.13.2"
kotlin = "2.0.21"
Expand Down Expand Up @@ -66,6 +67,7 @@ okhttp3 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
javax-inject = { module = "javax.inject:javax.inject", version.ref = "javax-inject" }
javax-annotation-api = { module = "javax.annotation:javax.annotation-api", version.ref = "javax-annotation-api" }
jsc-android = { module = "io.github.react-native-community:jsc-android", version.ref = "jsc-android" }

junit = {module = "junit:junit", version.ref = "junit" }
assertj = {module = "org.assertj:assertj-core", version.ref = "assertj" }
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
"glob": "^7.1.1",
"invariant": "^2.2.4",
"jest-environment-node": "^29.6.3",
"jsc-android": "^250231.0.0",
"memoize-one": "^5.0.0",
"metro-runtime": "^0.81.0",
"metro-source-map": "^0.81.0",
Expand Down
11 changes: 2 additions & 9 deletions packages/rn-tester/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ val enableProguardInReleaseBuilds = true

/**
* The preferred build flavor of JavaScriptCore (JSC) For example, to use the international variant,
* you can use: `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
* you can use: `def jscFlavor = "io.github.react-native-community:jsc-android-intl:2026004.+"`
*/
val jscFlavor = "org.webkit:android-jsc:+"
val jscFlavor = "io.github.react-native-community:jsc-android:2026004.+"

/** This allows to customized the CMake version used for compiling RN Tester. */
val cmakeVersion =
Expand All @@ -86,13 +86,6 @@ fun reactNativeArchitectures(): List<String> {
return value?.toString()?.split(",") ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a")
}

repositories {
maven {
url = rootProject.file("node_modules/jsc-android/dist").toURI()
content { includeGroup("org.webkit") }
}
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()
buildToolsVersion = libs.versions.buildTools.get()
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5899,11 +5899,6 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==

jsc-android@^250231.0.0:
version "250231.0.0"
resolved "https://registry.yarnpkg.com/jsc-android/-/jsc-android-250231.0.0.tgz#91720f8df382a108872fa4b3f558f33ba5e95262"
integrity sha512-rS46PvsjYmdmuz1OAWXY/1kCYG7pnf1TBqeTiOJr1iDz7s5DLxxC9n/ZMknLDxzYzNVfI7R95MH10emSSG1Wuw==

jsc-safe-url@^0.2.2:
version "0.2.4"
resolved "https://registry.yarnpkg.com/jsc-safe-url/-/jsc-safe-url-0.2.4.tgz#141c14fbb43791e88d5dc64e85a374575a83477a"
Expand Down

0 comments on commit e42a3a6

Please sign in to comment.