diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts index edd2f129be8..5e05d842f2b 100644 --- a/packages/react-native-gradle-plugin/build.gradle.kts +++ b/packages/react-native-gradle-plugin/build.gradle.kts @@ -36,14 +36,14 @@ dependencies { // The KGP/AGP version is defined by React Native Gradle plugin. // Therefore we specify an implementation dep rather than a compileOnly. - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0") - implementation("com.android.tools.build:gradle:8.1.0") + implementation(libs.kotlin.gradle.plugin) + implementation(libs.android.gradle.plugin) - implementation("com.google.code.gson:gson:2.8.9") - implementation("com.google.guava:guava:31.0.1-jre") - implementation("com.squareup:javapoet:1.13.0") + implementation(libs.gson) + implementation(libs.guava) + implementation(libs.javapoet) - testImplementation("junit:junit:4.13.2") + testImplementation(libs.junit) testRuntimeOnly( files( diff --git a/packages/react-native-gradle-plugin/gradle/libs.versions.toml b/packages/react-native-gradle-plugin/gradle/libs.versions.toml new file mode 100644 index 00000000000..e6ece441071 --- /dev/null +++ b/packages/react-native-gradle-plugin/gradle/libs.versions.toml @@ -0,0 +1,15 @@ +[versions] +junit = "4.13.2" +kotlin = "1.8.0" +agp = "8.1.0" +gson = "2.8.9" +guava = "31.0.1-jre" +javapoet = "1.13.0" + +[libraries] +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" } +gson = { module = "com.google.code.gson:gson", version.ref = "gson" } +guava = { module = "com.google.guava:guava", version.ref = "guava" } +javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" } +junit = {module = "junit:junit", version.ref = "junit" } diff --git a/packages/react-native/ReactAndroid/build.gradle b/packages/react-native/ReactAndroid/build.gradle index cf466939059..f70998c0454 100644 --- a/packages/react-native/ReactAndroid/build.gradle +++ b/packages/react-native/ReactAndroid/build.gradle @@ -714,44 +714,43 @@ android { } dependencies { - api("androidx.appcompat:appcompat-resources:${ANDROIDX_APPCOMPAT_VERSION}") - api("androidx.appcompat:appcompat:${ANDROIDX_APPCOMPAT_VERSION}") - api("androidx.autofill:autofill:${ANDROIDX_AUTOFILL_VERSION}") - api("androidx.swiperefreshlayout:swiperefreshlayout:${SWIPEREFRESH_LAYOUT_VERSION}") - api("androidx.tracing:tracing:${ANDROIDX_TRACING_VERSION}") + api(libs.androidx.appcompat) + api(libs.androidx.appcompat.resources) + api(libs.androidx.autofill) + api(libs.androidx.swiperefreshlayout) + api(libs.androidx.tracing) - api("com.facebook.fbjni:fbjni:${FBJNI_VERSION}") - api("com.facebook.fresco:fresco:${FRESCO_VERSION}") - api("com.facebook.fresco:middleware:${FRESCO_VERSION}") - api("com.facebook.fresco:imagepipeline-okhttp3:${FRESCO_VERSION}") - api("com.facebook.fresco:ui-common:${FRESCO_VERSION}") - api("com.facebook.infer.annotation:infer-annotation:${INFER_ANNOTATIONS_VERSION}") - api("com.facebook.soloader:soloader:${SO_LOADER_VERSION}") - api("com.facebook.yoga:proguard-annotations:${PROGUARD_ANNOTATIONS_VERSION}") + api(libs.fbjni) + api(libs.fresco) + api(libs.fresco.middleware) + api(libs.fresco.imagepipeline.okhttp3) + api(libs.fresco.ui.common) + api(libs.infer.annotation) + api(libs.soloader) + api(libs.yoga.proguard.annotations) - api("com.google.code.findbugs:jsr305:${JSR305_VERSION}") - api("com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}") - api("com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}") - api("com.squareup.okio:okio:${OKIO_VERSION}") - api("javax.inject:javax.inject:${JAVAX_INJECT_VERSION}") + api(libs.jsr305) + api(libs.okhttp3.urlconnection) + api(libs.okhttp3) + api(libs.okio) + 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. compileOnly(project(":packages:react-native:ReactAndroid:hermes-engine")) - testImplementation("junit:junit:${JUNIT_VERSION}") - testImplementation("org.assertj:assertj-core:${ASSERTJ_VERSION}") - testImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}") - testImplementation("org.powermock:powermock-api-mockito2:${POWERMOCK_VERSION}") - testImplementation("org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}") - testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}") - testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}") - testImplementation("com.thoughtworks.xstream:xstream:1.4.20") + testImplementation(libs.junit) + testImplementation(libs.assertj) + testImplementation(libs.mockito) + testImplementation(libs.powermock.api.mockito2) + testImplementation(libs.powermock.classloading.xstream) + testImplementation(libs.powermock.module.junit4.rule) + testImplementation(libs.robolectric) + testImplementation(libs.thoughtworks) - androidTestImplementation(fileTree(dir: "src/main/third-party/java/buck-android-support/", include: ["*.jar"])) - androidTestImplementation("androidx.test:runner:${ANDROIDX_TEST_VERSION}") - androidTestImplementation("androidx.test:rules:${ANDROIDX_TEST_VERSION}") - androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}") + androidTestImplementation(libs.androidx.test.runner) + androidTestImplementation(libs.androidx.test.rules) + androidTestImplementation(libs.mockito) } react { diff --git a/packages/react-native/ReactAndroid/flipper-integration/build.gradle b/packages/react-native/ReactAndroid/flipper-integration/build.gradle index f7b6bea15ef..1f7001c48e3 100644 --- a/packages/react-native/ReactAndroid/flipper-integration/build.gradle +++ b/packages/react-native/ReactAndroid/flipper-integration/build.gradle @@ -43,11 +43,11 @@ android { dependencies { implementation project(':packages:react-native:ReactAndroid') - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") - debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { + debugImplementation(libs.flipper) + debugImplementation(libs.flipper.network.plugin) { exclude group:'com.squareup.okhttp3', module:'okhttp' } - debugImplementation("com.facebook.fresco:flipper-fresco-plugin:${FLIPPER_FRESCO_VERSION}") + debugImplementation(libs.flipper.fresco.plugin) } publishing { diff --git a/packages/react-native/ReactAndroid/flipper-integration/gradle.properties b/packages/react-native/ReactAndroid/flipper-integration/gradle.properties deleted file mode 100644 index aa09105bf10..00000000000 --- a/packages/react-native/ReactAndroid/flipper-integration/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Version of flipper SDK to use for this integration -FLIPPER_VERSION=0.201.0 -FLIPPER_FRESCO_VERSION=3.0.0 diff --git a/packages/react-native/ReactAndroid/gradle.properties b/packages/react-native/ReactAndroid/gradle.properties index 51049fd1f66..a32d36a5556 100644 --- a/packages/react-native/ReactAndroid/gradle.properties +++ b/packages/react-native/ReactAndroid/gradle.properties @@ -1,27 +1,6 @@ VERSION_NAME=1000.0.0 GROUP=com.facebook.react -# JVM Versions -ANDROIDX_APPCOMPAT_VERSION=1.4.1 -ANDROIDX_AUTOFILL_VERSION=1.1.0 -ANDROIDX_TEST_VERSION=1.1.0 -ANDROIDX_TRACING_VERSION=1.1.0 -ASSERTJ_VERSION=3.21.0 -FBJNI_VERSION=0.5.1 -FRESCO_VERSION=3.0.0 -INFER_ANNOTATIONS_VERSION=0.18.0 -JAVAX_INJECT_VERSION=1 -JSR305_VERSION=3.0.2 -JUNIT_VERSION=4.13.2 -MOCKITO_CORE_VERSION=2.28.2 -OKHTTP_VERSION=4.9.2 -OKIO_VERSION=2.9.0 -POWERMOCK_VERSION=2.0.9 -PROGUARD_ANNOTATIONS_VERSION=1.19.0 -ROBOLECTRIC_VERSION=4.9.2 -SO_LOADER_VERSION=0.10.5 -SWIPEREFRESH_LAYOUT_VERSION=1.0.0 - # Native Dependency Versions BOOST_VERSION=1_76_0 DOUBLE_CONVERSION_VERSION=1.1.6 diff --git a/packages/react-native/ReactAndroid/hermes-engine/build.gradle b/packages/react-native/ReactAndroid/hermes-engine/build.gradle index 16e65d634e9..411a0896483 100644 --- a/packages/react-native/ReactAndroid/hermes-engine/build.gradle +++ b/packages/react-native/ReactAndroid/hermes-engine/build.gradle @@ -247,10 +247,10 @@ android { } dependencies { - implementation("com.facebook.fbjni:fbjni:0.5.1") - implementation("com.facebook.soloader:soloader:0.10.5") - implementation("com.facebook.yoga:proguard-annotations:1.19.0") - implementation("androidx.annotation:annotation:1.3.0") + implementation(libs.fbjni) + implementation(libs.soloader) + implementation(libs.yoga.proguard.annotations) + implementation(libs.androidx.annotation) } packagingOptions { diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml new file mode 100644 index 00000000000..107bdefc905 --- /dev/null +++ b/packages/react-native/gradle/libs.versions.toml @@ -0,0 +1,66 @@ +[versions] +androidx-annotation = "1.3.0" +androidx-appcompat = "1.4.1" +androidx-autofill = "1.1.0" +androidx-swiperefreshlayout = "1.0.0" +androidx-test = "1.1.0" +androidx-tracing = "1.1.0" +assertj = "3.21.0" +fbjni = "0.5.1" +flipper = "0.201.0" +fresco = "3.0.0" +infer-annotation = "0.18.0" +javax-inject = "1" +jsr305 = "3.0.2" +junit = "4.13.2" +mockito = "2.28.2" +okhttp = "4.9.2" +okio = "2.9.0" +powermock = "2.0.9" +robolectric = "4.9.2" +soloader = "0.10.5" +xstream = "1.4.20" +yoga-proguard-annotations = "1.19.0" + +[libraries] +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" } +androidx-appcompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appcompat" } +androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" } +androidx-autofill = { module = "androidx.autofill:autofill", version.ref = "androidx-autofill" } +androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" } +androidx-tracing = { module = "androidx.tracing:tracing", version.ref = "androidx-tracing" } +androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" } +androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" } + +fbjni = { module = "com.facebook.fbjni:fbjni", version.ref = "fbjni" } +flipper = { module = "com.facebook.flipper:flipper", version.ref = "flipper" } +flipper-network-plugin = { module = "com.facebook.flipper:flipper-network-plugin", version.ref = "flipper" } +flipper-fresco-plugin = { module = "com.facebook.fresco:flipper-fresco-plugin", version.ref = "fresco" } +fresco = { module = "com.facebook.fresco:fresco", version.ref = "fresco" } +fresco-middleware = { module = "com.facebook.fresco:middleware", version.ref = "fresco" } +fresco-imagepipeline-okhttp3 = { module = "com.facebook.fresco:imagepipeline-okhttp3", version.ref = "fresco" } +fresco-ui-common = { module = "com.facebook.fresco:ui-common", version.ref = "fresco" } +infer-annotation = { module = "com.facebook.infer.annotation:infer-annotation", version.ref = "infer-annotation" } +soloader = { module = "com.facebook.soloader:soloader", version.ref = "soloader" } +yoga-proguard-annotations = { module = "com.facebook.yoga:proguard-annotations", version.ref = "yoga-proguard-annotations" } + +jsr305 = { module = "com.google.code.findbugs:jsr305", version.ref = "jsr305" } +okhttp3-urlconnection = { module = "com.squareup.okhttp3:okhttp-urlconnection", version.ref = "okhttp" } +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" } +junit = {module = "junit:junit", version.ref = "junit" } +assertj = {module = "org.assertj:assertj-core", version.ref = "assertj" } +mockito = {module = "org.mockito:mockito-core", version.ref = "mockito" } +powermock-api-mockito2 = {module = "org.powermock:powermock-api-mockito2", version.ref = "powermock" } +powermock-classloading-xstream = {module = "org.powermock:powermock-classloading-xstream", version.ref = "powermock" } +powermock-module-junit4-rule = {module = "org.powermock:powermock-module-junit4-rule", version.ref = "powermock" } +robolectric = {module = "org.robolectric:robolectric", version.ref = "robolectric" } +thoughtworks = {module = "com.thoughtworks.xstream:xstream", version.ref = "xstream" } + +[plugins] +binaryCompatibilityValidator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.13.2" } +download = { id = "de.undercouch.download", version = "5.4.0" } +gradleVersions = { id = "com.github.ben-manes.versions", version = "0.47.0" } +pluginPublishing = { id = "com.gradle.plugin-publish", version = "1.2.0" } +shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" } diff --git a/packages/react-native/settings.gradle.kts b/packages/react-native/settings.gradle.kts index c0748c7b488..49736a75197 100644 --- a/packages/react-native/settings.gradle.kts +++ b/packages/react-native/settings.gradle.kts @@ -19,6 +19,10 @@ pluginManagement { } } +dependencyResolutionManagement { + versionCatalogs { create("libs") { from(files("gradle/libs.versions.toml")) } } +} + rootProject.name = "react-native-github" include(":packages:react-native:ReactAndroid") diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index bc20f1a9c8c..a17104377ec 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -164,7 +164,7 @@ dependencies { jscImplementation jscFlavor - androidTestImplementation 'junit:junit:4.12' + testImplementation(libs.junit) } android { diff --git a/settings.gradle.kts b/settings.gradle.kts index 2f562866e1a..7bc7703c70a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,14 +17,15 @@ include( ":packages:react-native:ReactAndroid", ":packages:react-native:ReactAndroid:flipper-integration", ":packages:react-native:ReactAndroid:hermes-engine", - ":packages:react-native:ReactAndroid:external-artifacts") + ":packages:react-native:ReactAndroid:external-artifacts", + ":packages:rn-tester:android:app") -// If the ./packages folder exists, then we're inside the React Native repository. -// If not, a users is consuming this project for a build from source. -if (File("${rootDir}/packages").exists()) { - include(":packages:rn-tester:android:app") - // Include this to enable codegen Gradle plugin. - includeBuild("packages/react-native-gradle-plugin/") +includeBuild("packages/react-native-gradle-plugin/") + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { from(files("packages/react-native/gradle/libs.versions.toml")) } + } } rootProject.name = "react-native-github"