Skip to content

Commit 3b73901

Browse files
committed
feat: migrate jsc-android to mavenCentral
1 parent df7b6ae commit 3b73901

File tree

13 files changed

+25
-254
lines changed

13 files changed

+25
-254
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: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,28 @@ internal object DependencyUtils {
2929
with(eachProject) {
3030
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
3131
val mavenLocalRepoPath = property(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO) as String
32-
mavenRepoFromURI(File(mavenLocalRepoPath).toURI()) { repo ->
33-
repo.content { it.excludeGroup("org.webkit") }
34-
}
32+
mavenRepoFromURI(File(mavenLocalRepoPath).toURI())
3533
}
3634
// We add the snapshot for users on nightlies.
37-
mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/") { repo ->
38-
repo.content { it.excludeGroup("org.webkit") }
39-
}
35+
mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/")
4036
repositories.mavenCentral { repo ->
41-
// We don't want to fetch JSC from Maven Central as there are older versions there.
42-
repo.content { it.excludeGroup("org.webkit") }
43-
4437
// If the user provided a react.internal.mavenLocalRepo, do not attempt to load
4538
// anything from Maven Central that is react related.
4639
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
4740
repo.content { it.excludeGroup("com.facebook.react") }
4841
}
4942
}
50-
// Android JSC is installed from npm
51-
mavenRepoFromURI(File(reactNativeDir, "../jsc-android/dist").toURI()) { repo ->
52-
repo.content { it.includeGroup("org.webkit") }
53-
}
5443
repositories.google { repo ->
5544
repo.content {
5645
// We don't want to fetch JSC or React from Google
57-
it.excludeGroup("org.webkit")
46+
it.excludeGroup("io.github.react-native-community")
5847
it.excludeGroup("com.facebook.react")
5948
}
6049
}
6150
mavenRepoFromUrl("https://www.jitpack.io") { repo ->
6251
repo.content {
6352
// We don't want to fetch JSC or React from JitPack
64-
it.excludeGroup("org.webkit")
53+
it.excludeGroup("io.github.react-native-community")
6554
it.excludeGroup("com.facebook.react")
6655
}
6756
}

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")
@@ -663,9 +655,10 @@ dependencies {
663655
compileOnly(libs.javax.annotation.api)
664656
api(libs.javax.inject)
665657

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

670663
testImplementation(libs.junit)
671664
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/ReactCommon/jsc/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
cmake_minimum_required(VERSION 3.13)
1111
set(CMAKE_VERBOSE_MAKEFILE on)
1212

13+
# Copy jsc headers into JavaScriptCore subdirectory
14+
get_target_property(JSC_PREFAB_INCLUDE_DIR jsc INTERFACE_INCLUDE_DIRECTORIES)
15+
set(JSC_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
16+
file(MAKE_DIRECTORY ${JSC_INCLUDE_DIR})
17+
file(GLOB JSC_HEADERS "${JSC_PREFAB_INCLUDE_DIR}/*.h")
18+
foreach(HEADER ${JSC_HEADERS})
19+
file(COPY ${HEADER} DESTINATION "${JSC_INCLUDE_DIR}/JavaScriptCore")
20+
endforeach()
21+
1322
add_compile_options(
1423
-fexceptions
1524
-frtti
@@ -25,6 +34,7 @@ add_library(jscruntime
2534
JSCRuntime.cpp)
2635

2736
target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
37+
target_include_directories(jscruntime PRIVATE ${JSC_INCLUDE_DIR})
2838
target_merge_so(jscruntime)
2939

3040
target_link_libraries(jscruntime

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.4.0"
2121
infer-annotation = "0.18.0"
2222
javax-annotation-api = "1.3.2"
2323
javax-inject = "1"
24+
jsc-android = "2026004.0.0"
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" }

0 commit comments

Comments
 (0)