From acf827e00162ce5dc04f4720725d4980fc59e226 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 4 Dec 2023 12:22:58 -0800 Subject: [PATCH] Integrate binary-compatibility-validator into RN Android build system Summary: In this diff I'm integrating 'org.jetbrains.kotlinx.binary-compatibility-validator' into RN Android build gradle system. The tool allows dumping binary API of a JVM part of a Kotlin library that is public in the sense of Kotlin visibilities and ensures that the public binary API wasn't changed in a way that makes this change binary incompatible More context on https://github.com/Kotlin/binary-compatibility-validator#building-the-project-locally bypass-github-export-checks Reviewed By: cortinico Differential Revision: D51262577 fbshipit-source-id: 1894f4e55a4019e3ce1585e9df12dee69944e5ce --- build.gradle.kts | 26 +++++++++++++++++++ .../react-native/gradle/libs.versions.toml | 2 ++ 2 files changed, 28 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 8114a09effe628..142687c413d695 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.download) apply false alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.binary.compatibility.validator) apply true } val reactAndroidProperties = java.util.Properties() @@ -19,6 +20,31 @@ File("$rootDir/packages/react-native/ReactAndroid/gradle.properties").inputStrea reactAndroidProperties.load(it) } +apiValidation { + ignoredPackages.addAll( + listOf( + "com.facebook.fbreact", + "com.facebook.react.flipper", + "com.facebook.debug", + "com.facebook.hermes", + "com.facebook.perftest", + "com.facebook.proguard", + "com.facebook.react.module.processing", + "com.facebook.systrace", + "com.facebook.yoga", + "com.facebook.react.internal", + "com.facebook.react.bridgeless.internal")) + + ignoredClasses.addAll(listOf("com.facebook.react.BuildConfig")) + + nonPublicMarkers.addAll( + listOf( + "com.facebook.react.common.annotations.UnstableReactNativeAPI", + "com.facebook.react.common.annotations.VisibleForTesting")) + + validationDisabled = true +} + version = if (project.hasProperty("isSnapshot") && (project.property("isSnapshot") as? String).toBoolean()) { diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml index b95a8de23c2755..16195010aaf540 100644 --- a/packages/react-native/gradle/libs.versions.toml +++ b/packages/react-native/gradle/libs.versions.toml @@ -13,6 +13,7 @@ androidx-swiperefreshlayout = "1.1.0" androidx-test = "1.5.0" androidx-tracing = "1.1.0" assertj = "3.21.0" +binary-compatibility-validator = "0.13.2" download = "5.4.0" fbjni = "0.5.1" fresco = "3.1.3" @@ -76,3 +77,4 @@ android-library = { id = "com.android.library", version.ref = "agp" } download = { id = "de.undercouch.download", version.ref = "download" } nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator" }