diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index aedd296d40eea5..2a2f242c31ca26 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -29,13 +29,17 @@ 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()) + mavenRepoFromURI(File(mavenLocalRepoPath).toURI()) { repo -> + repo.content { it.excludeGroup("org.webkit") } + } } // We add the snapshot for users on nightlies. - mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/") + mavenRepoFromUrl("https://oss.sonatype.org/content/repositories/snapshots/") { repo -> + repo.content { it.excludeGroup("org.webkit") } + } repositories.mavenCentral { repo -> // We don't want to fetch JSC from Maven Central as there are older versions there. - repo.content { it.excludeModule("org.webkit", "android-jsc") } + 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. @@ -44,9 +48,23 @@ internal object DependencyUtils { } } // Android JSC is installed from npm - mavenRepoFromURI(File(reactNativeDir, "../jsc-android/dist").toURI()) - repositories.google() - mavenRepoFromUrl("https://www.jitpack.io") + 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("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("com.facebook.react") + } + } } } } @@ -134,9 +152,21 @@ internal object DependencyUtils { return Pair(versionString, groupString) } - fun Project.mavenRepoFromUrl(url: String): MavenArtifactRepository = - project.repositories.maven { it.url = URI.create(url) } + fun Project.mavenRepoFromUrl( + url: String, + action: (MavenArtifactRepository) -> Unit = {} + ): MavenArtifactRepository = + project.repositories.maven { + it.url = URI.create(url) + action(it) + } - fun Project.mavenRepoFromURI(uri: URI): MavenArtifactRepository = - project.repositories.maven { it.url = uri } + fun Project.mavenRepoFromURI( + uri: URI, + action: (MavenArtifactRepository) -> Unit = {} + ): MavenArtifactRepository = + project.repositories.maven { + it.url = uri + action(it) + } } diff --git a/packages/rn-tester/android/app/build.gradle.kts b/packages/rn-tester/android/app/build.gradle.kts index 6af90f8bf68352..bcc1b40e4bbc63 100644 --- a/packages/rn-tester/android/app/build.gradle.kts +++ b/packages/rn-tester/android/app/build.gradle.kts @@ -84,7 +84,12 @@ fun reactNativeArchitectures(): List { return value?.toString()?.split(",") ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a") } -repositories { maven { url = rootProject.file("node_modules/jsc-android/dist").toURI() } } +repositories { + maven { + url = rootProject.file("node_modules/jsc-android/dist").toURI() + content { includeGroup("org.webkit") } + } +} android { compileSdk = libs.versions.compileSdk.get().toInt()