Repository navigation
Move from bcv plugin to KGP api validation #6362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package io.sentry.gradle | ||
|
|
||
| import org.gradle.api.provider.SetProperty | ||
|
|
||
| /** Configuration for the `io.sentry.api-validation` convention plugin. */ | ||
| abstract class ApiValidationExtension { | ||
| /** | ||
| * Packages that are public to the JVM but not part of the SDK's API, and so are left out of the | ||
| * dump. Subpackages are left out too. | ||
| */ | ||
| abstract val ignoredPackages: SetProperty<String> | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||
| package io.sentry.gradle | ||||||
|
|
||||||
| import org.gradle.api.GradleException | ||||||
| import org.gradle.api.Plugin | ||||||
| import org.gradle.api.Project | ||||||
| import org.gradle.api.plugins.ExtensionAware | ||||||
| import org.gradle.kotlin.dsl.create | ||||||
| import org.jetbrains.kotlin.gradle.dsl.abi.AbiValidationExtension | ||||||
| import org.jetbrains.kotlin.gradle.dsl.abi.AbiValidationMultiplatformExtension | ||||||
| import org.jetbrains.kotlin.gradle.dsl.abi.AbiValidationVariantSpec | ||||||
| import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation | ||||||
|
|
||||||
| private val KOTLIN_PLUGIN_IDS = | ||||||
| listOf( | ||||||
| "org.jetbrains.kotlin.jvm", | ||||||
| "org.jetbrains.kotlin.android", | ||||||
| "org.jetbrains.kotlin.multiplatform", | ||||||
| ) | ||||||
|
|
||||||
| /** | ||||||
| * Checks the public ABI of a module against the dump checked into its `api` directory, using the | ||||||
| * Kotlin Gradle plugin's own ABI validation. Adds `checkKotlinAbi`, which `check` depends on, and | ||||||
| * `updateKotlinAbi`, which rewrites the dump. | ||||||
| */ | ||||||
| @OptIn(ExperimentalAbiValidation::class) | ||||||
| class SentryApiValidationPlugin : Plugin<Project> { | ||||||
| override fun apply(project: Project) { | ||||||
| val extension = project.extensions.create<ApiValidationExtension>("sentryApiValidation") | ||||||
|
|
||||||
| // The abiValidation extension only exists once a Kotlin plugin has been applied, and a module | ||||||
| // may list this plugin before that one. | ||||||
| KOTLIN_PLUGIN_IDS.forEach { | ||||||
| project.pluginManager.withPlugin(it) { enable(project, extension) } | ||||||
| } | ||||||
|
|
||||||
| // Aliases for backwards compat with the old binary-compatibility-validator plugin. | ||||||
| project.tasks.register("apiDump") { dependsOn("updateKotlinAbi") } | ||||||
| project.tasks.register("apiCheck") { dependsOn("checkKotlinAbi") } | ||||||
| } | ||||||
|
|
||||||
| private fun enable(project: Project, extension: ApiValidationExtension) { | ||||||
| val kotlin = project.extensions.getByName("kotlin") as ExtensionAware | ||||||
| val spec: AbiValidationVariantSpec = | ||||||
| when (val abi = kotlin.extensions.getByName("abiValidation")) { | ||||||
| is AbiValidationMultiplatformExtension -> abi.also { it.enabled.set(true) } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sad we can't do this. i bet we could though if this was a
Suggested change
|
||||||
| is AbiValidationExtension -> abi.also { it.enabled.set(true) } | ||||||
| else -> throw GradleException("Unexpected abiValidation extension: ${abi.javaClass.name}") | ||||||
| } | ||||||
| // Lazy, because the module configures the extension after this plugin has been applied. | ||||||
| val ignored = extension.ignoredPackages.map { packages -> packages.map { "$it.**" } } | ||||||
| spec.filters { exclude { byNames.addAll(ignored) } } | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you move this up to line 48 like so? filters { exclude { byNames.addAll(....) } } |
||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ plugins { | |
| alias(libs.plugins.spotless) apply false | ||
| alias(libs.plugins.detekt) | ||
| `maven-publish` | ||
| alias(libs.plugins.binary.compatibility.validator) | ||
| alias(libs.plugins.vanniktech.maven.publish) apply false | ||
| alias(libs.plugins.kotlin.android) apply false | ||
| alias(libs.plugins.kotlin.multiplatform) apply false | ||
|
|
@@ -47,52 +46,6 @@ buildscript { | |
| } | ||
| } | ||
|
|
||
| apiValidation { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where was this consumed? was it the root plugin |
||
| ignoredPackages.addAll( | ||
| setOf( | ||
| "io.sentry.android.core.internal" | ||
| ) | ||
| ) | ||
| ignoredProjects.addAll( | ||
| listOf( | ||
| "sentry-samples-android", | ||
| "sentry-samples-console", | ||
| "sentry-samples-console-opentelemetry-noagent", | ||
| "sentry-samples-jul", | ||
| "sentry-samples-log4j2", | ||
| "sentry-samples-logback", | ||
| "sentry-samples-openfeign", | ||
| "sentry-samples-servlet", | ||
| "sentry-samples-spring", | ||
| "sentry-samples-spring-jakarta", | ||
| "sentry-samples-spring-7", | ||
| "sentry-samples-spring-boot", | ||
| "sentry-samples-spring-boot-opentelemetry", | ||
| "sentry-samples-spring-boot-opentelemetry-noagent", | ||
| "sentry-samples-spring-boot-jakarta", | ||
| "sentry-samples-spring-boot-jakarta-log4j2", | ||
| "sentry-samples-spring-boot-jakarta-opentelemetry", | ||
| "sentry-samples-spring-boot-jakarta-opentelemetry-noagent", | ||
| "sentry-samples-spring-boot-webflux", | ||
| "sentry-samples-spring-boot-webflux-jakarta", | ||
| "sentry-samples-spring-boot-4", | ||
| "sentry-samples-spring-boot-4-log4j2", | ||
| "sentry-samples-spring-boot-4-opentelemetry", | ||
| "sentry-samples-spring-boot-4-opentelemetry-noagent", | ||
| "sentry-samples-spring-boot-4-otlp", | ||
| "sentry-samples-spring-boot-4-webflux", | ||
| "sentry-samples-ktor-client", | ||
| "sentry-uitest-android", | ||
| "sentry-uitest-android-critical", | ||
| "test-app-size", | ||
| "sentry-samples-netflix-dgs", | ||
| "sentry-samples-console-otlp", | ||
| "sentry-test-support", | ||
| "sentry-system-test-support" | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| allprojects { | ||
| group = Config.Sentry.group | ||
| version = providers.gradleProperty(Config.Sentry.versionNameProp).get() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would remove the backwards compatibility here. having more than one way or doing something is confusing for humans and agents.