Use version catalog to consolidate versions for JVM dependencies (#38836)

Summary:
As we had version numbers scattered all over the places, I'm consolidating them to use a version catalog: https://docs.gradle.org/current/userguide/platforms.html

## Changelog:

[INTERNAL] - Use version catalog to consolidate versions for JVM dependencies

Pull Request resolved: https://github.com/facebook/react-native/pull/38836

Test Plan: CI

Reviewed By: cipolleschi

Differential Revision: D48150285

Pulled By: cortinico

fbshipit-source-id: 83a1867aace5395d9a10fadd6c6ab11c31fa14b5
This commit is contained in:
Nicola Corti
2023-08-08 11:37:43 -07:00
committed by Facebook GitHub Bot
parent 639b4892b4
commit e563f0f3fc
11 changed files with 136 additions and 75 deletions
@@ -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(
@@ -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" }
+29 -30
View File
@@ -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 {
@@ -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 {
@@ -1,3 +0,0 @@
# Version of flipper SDK to use for this integration
FLIPPER_VERSION=0.201.0
FLIPPER_FRESCO_VERSION=3.0.0
@@ -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
@@ -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 {
@@ -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" }
@@ -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")
+1 -1
View File
@@ -164,7 +164,7 @@ dependencies {
jscImplementation jscFlavor
androidTestImplementation 'junit:junit:4.12'
testImplementation(libs.junit)
}
android {
+8 -7
View File
@@ -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"