2
0
Эх сурвалжийг харах

Add binary compatibility validator

Him188 4 жил өмнө
parent
commit
f1c6677af9

+ 36 - 0
binary-compatibility-validator/build.gradle.kts

@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019-2021 Mamoe Technologies and contributors.
+ *
+ *  此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
+ *  Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
+ *
+ *  https://github.com/mamoe/mirai/blob/master/LICENSE
+ */
+
+@file:Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
+
+/*
+* Copyright 2019-2021 Mamoe Technologies and contributors.
+*
+*  此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
+*  Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
+*
+*  https://github.com/mamoe/mirai/blob/master/LICENSE
+*/
+
+plugins {
+    kotlin("jvm")
+    kotlin("plugin.serialization")
+
+    id("kotlinx-atomicfu")
+    id("net.mamoe.kotlin-jvm-blocking-bridge")
+}
+
+description = "Mirai API binary compatibility validator"
+
+tasks.withType(kotlinx.validation.KotlinApiBuildTask::class) {
+    inputClassesDirs = files(inputClassesDirs.files, project(":mirai-core-api").buildDir)
+}
+
+// tasks["apiDump"].dependsOn(project(":mirai-core-api").tasks["build"])
+// this dependency is set in mirai-core-api since binary validator is configured before mirai-core-api

+ 13 - 2
build.gradle.kts

@@ -44,8 +44,19 @@ plugins {
 }
 }
 
 
 // https://github.com/kotlin/binary-compatibility-validator
 // https://github.com/kotlin/binary-compatibility-validator
-//apply(plugin = "binary-compatibility-validator")
-
+apply(plugin = "binary-compatibility-validator")
+
+configure<kotlinx.validation.ApiValidationExtension> {
+    ignoredProjects.add("mirai-core")
+    ignoredProjects.add("mirai-core-api")
+    ignoredProjects.add("mirai-core-utils")
+    ignoredProjects.add("mirai-core-all")
+    ignoredProjects.add("mirai")
+
+    ignoredPackages.add("net.mamoe.mirai.internal")
+    nonPublicMarkers.add("net.mamoe.mirai.MiraiInternalApi")
+    nonPublicMarkers.add("net.mamoe.mirai.MiraiExperimentalApi")
+}
 
 
 project.ext.set("isAndroidSDKAvailable", false)
 project.ext.set("isAndroidSDKAvailable", false)
 
 

+ 1 - 1
buildSrc/src/main/kotlin/Versions.kt

@@ -23,7 +23,7 @@ object Versions {
     const val serialization = "1.0.1"
     const val serialization = "1.0.1"
     const val ktor = "1.5.0"
     const val ktor = "1.5.0"
 
 
-    const val binaryValidator = "0.2.3"
+    const val binaryValidator = "0.3.0"
 
 
     const val io = "0.1.16"
     const val io = "0.1.16"
     const val coroutinesIo = "0.1.16"
     const val coroutinesIo = "0.1.16"

+ 5 - 1
mirai-core-api/build.gradle.kts

@@ -111,4 +111,8 @@ fun org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler.api1(dependencyNo
         exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
         exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core-metadata")
     }
     }
 
 
-configureMppPublishing()
+configureMppPublishing()
+
+afterEvaluate {
+    project(":binary-compatibility-validator").tasks["apiBuild"].dependsOn(project(":mirai-core-api").tasks["build"])
+}

+ 4 - 2
settings.gradle.kts

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright 2019-2020 Mamoe Technologies and contributors.
+ * Copyright 2019-2021 Mamoe Technologies and contributors.
  *
  *
  *  此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  *  此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  *  Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  *  Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -26,4 +26,6 @@ rootProject.name = "mirai"
 include(":mirai-core-utils")
 include(":mirai-core-utils")
 include(":mirai-core-api")
 include(":mirai-core-api")
 include(":mirai-core")
 include(":mirai-core")
-include(":mirai-core-all")
+include(":mirai-core-all")
+
+include(":binary-compatibility-validator")