aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src/main/kotlin/org/jetbrains/binaryCompatibility.kt
blob: fb686e1d511c60a7f37d25a174be90a6cf967c67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package org.jetbrains

import kotlinx.validation.ApiValidationExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

internal object BinaryCompatibilityConfig {
    val ignoredPublications = setOf("kotlinAnalysisIntelliJ", "kotlinAnalysis", "kotlinAnalysisCompiler")
    val ignoredSubprojects = setOf(
        "search-component",
        "compiler-dependency",
        "intellij-dependency",
        "kotlin-analysis",
        "frontend"
    )
}

internal fun Project.registerBinaryCompatibilityCheck(publicationName: String) {
    publicationName.takeIf {
        it !in BinaryCompatibilityConfig.ignoredPublications
    }?.let {
        if (tasks.findByName("apiBuild") == null) {
            plugins.apply(kotlinx.validation.BinaryCompatibilityValidatorPlugin::class.java)
            configure<ApiValidationExtension> {
                ignoredProjects.addAll(
                    BinaryCompatibilityConfig.ignoredSubprojects.intersect(allprojects.map { it.name })
                )
            }
        }
    }
}