Exclude mirai-core in :mirai-console:shadowJar

This commit is contained in:
Karlatemp 2020-06-23 22:05:46 +08:00
parent d204d1f28e
commit 5e3039f866
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8
2 changed files with 18 additions and 0 deletions

View File

@ -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) {

View File

@ -22,6 +22,7 @@ import kotlin.math.pow
class MiraiConsoleBuildPlugin : Plugin<Project> {
override fun apply(target: Project) = target.run {
apply<ShadowPlugin>()
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<Project> {
"Implementation-Version" to target.version.toString() + "-" + gitVersion
)
}
@Suppress("UNCHECKED_CAST")
kotlin.runCatching {
(ext["shadowJar"] as? ShadowJar.() -> Unit)?.invoke(this)
}
}
}