mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 10:30:13 +08:00
Improve BuildMiraiPluginTask
This commit is contained in:
parent
4308c59da2
commit
8b7dc78a5d
@ -1,24 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.console.gradle
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.tasks.CacheableTask
|
||||
import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||
import java.io.File
|
||||
|
||||
@CacheableTask
|
||||
public open class BuildMiraiPluginTask : ShadowJar() {
|
||||
@Internal
|
||||
public var targetField: KotlinTarget? = null
|
||||
|
||||
@get:Internal
|
||||
public val target: KotlinTarget
|
||||
get() = targetField!!
|
||||
|
||||
public open class BuildMiraiPluginTask(
|
||||
@field:Internal
|
||||
internal val target: KotlinTarget
|
||||
) : ShadowJar() {
|
||||
/**
|
||||
* ShadowJar 打包结果
|
||||
*/
|
||||
@get:Internal
|
||||
@get:OutputFile
|
||||
public val output: File
|
||||
get() = outputs.files.singleFile
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
* Kotlin 单平台或 Java 时的默认 task 名.
|
||||
*/
|
||||
public const val DEFAULT_NAME: String = "buildPlugin"
|
||||
}
|
||||
}
|
@ -102,9 +102,8 @@ public class MiraiConsoleGradlePlugin : Plugin<Project> {
|
||||
tasks.findByName("shadowJar")?.enabled = false
|
||||
|
||||
fun registerBuildPluginTask(target: KotlinTarget, isSingleTarget: Boolean) {
|
||||
tasks.create("buildPlugin".wrapNameWithPlatform(target, isSingleTarget), BuildMiraiPluginTask::class.java).apply shadow@{
|
||||
tasks.create("buildPlugin".wrapNameWithPlatform(target, isSingleTarget), BuildMiraiPluginTask::class.java, target).apply shadow@{
|
||||
group = "mirai"
|
||||
targetField = target
|
||||
|
||||
archiveExtension.set("mirai.jar")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user