Skip to content

Commit

Permalink
feat: migrate jsc-android to mavenCentral
Browse files Browse the repository at this point in the history
  • Loading branch information
Kudo committed Nov 26, 2024
1 parent df7b6ae commit 3b73901
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 254 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,28 @@ internal object DependencyUtils {
with(eachProject) {
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
val mavenLocalRepoPath = property(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO) as String
mavenRepoFromURI(File(mavenLocalRepoPath).toURI()) { repo ->
repo.content { it.excludeGroup("org.webkit") }
}
mavenRepoFromURI(File(mavenLocalRepoPath).toURI())
}
// We add the snapshot for users on nightlies.
mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/") { repo ->
repo.content { it.excludeGroup("org.webkit") }
}
mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/")
repositories.mavenCentral { repo ->
// We don't want to fetch JSC from Maven Central as there are older versions there.
repo.content { it.excludeGroup("org.webkit") }

// If the user provided a react.internal.mavenLocalRepo, do not attempt to load
// anything from Maven Central that is react related.
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
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 @@ -663,9 +655,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.

10 changes: 10 additions & 0 deletions packages/react-native/ReactCommon/jsc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

# Copy jsc headers into JavaScriptCore subdirectory
get_target_property(JSC_PREFAB_INCLUDE_DIR jsc INTERFACE_INCLUDE_DIRECTORIES)
set(JSC_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
file(MAKE_DIRECTORY ${JSC_INCLUDE_DIR})
file(GLOB JSC_HEADERS "${JSC_PREFAB_INCLUDE_DIR}/*.h")
foreach(HEADER ${JSC_HEADERS})
file(COPY ${HEADER} DESTINATION "${JSC_INCLUDE_DIR}/JavaScriptCore")
endforeach()

add_compile_options(
-fexceptions
-frtti
Expand All @@ -25,6 +34,7 @@ add_library(jscruntime
JSCRuntime.cpp)

target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(jscruntime PRIVATE ${JSC_INCLUDE_DIR})
target_merge_so(jscruntime)

target_link_libraries(jscruntime
Expand Down
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.4.0"
infer-annotation = "0.18.0"
javax-annotation-api = "1.3.2"
javax-inject = "1"
jsc-android = "2026004.0.0"
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
Loading

0 comments on commit 3b73901

Please sign in to comment.