diff --git a/backend/mirai-console/build.gradle.kts b/backend/mirai-console/build.gradle.kts index c04b32633..b25d48cf8 100644 --- a/backend/mirai-console/build.gradle.kts +++ b/backend/mirai-console/build.gradle.kts @@ -71,6 +71,19 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0") } +ext { + // 傻逼 compileAndRuntime 没 exclude 掉 + val x: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.() -> Unit = { + dependencyFilter.exclude { + when ("${it.moduleGroup}:${it.moduleName}") { + "net.mamoe:mirai-core" -> true + "net.mamoe:mirai-core-qqandroid" -> true + else -> false + } + } + } + this.set("shadowJar", x) +} tasks { "test"(Test::class) { diff --git a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt index 2362c8ead..3713068b7 100644 --- a/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt +++ b/buildSrc/src/main/kotlin/MiraiConsoleBuildPlugin.kt @@ -22,6 +22,7 @@ import kotlin.math.pow class MiraiConsoleBuildPlugin : Plugin { override fun apply(target: Project) = target.run { apply() + val ext = target.extensions.getByName("ext") as org.gradle.api.plugins.ExtraPropertiesExtension if (tasks.none { it.name == "shadowJar" }) { return@run @@ -40,6 +41,10 @@ class MiraiConsoleBuildPlugin : Plugin { "Implementation-Version" to target.version.toString() + "-" + gitVersion ) } + @Suppress("UNCHECKED_CAST") + kotlin.runCatching { + (ext["shadowJar"] as? ShadowJar.() -> Unit)?.invoke(this) + } } }