From b20d49f6cec099bfc82f40b7062f1737dea105d8 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 16 Apr 2021 12:52:55 +0800 Subject: [PATCH] Fix buildPlugin, fix #335 --- .../mirai/console/gradle/AbstractTest.groovy | 2 +- .../console/gradle/TestBuildPlugin.groovy | 22 +++++++++++++++++++ .../src/main/kotlin/BuildMiraiPluginTask.kt | 2 -- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/TestBuildPlugin.groovy diff --git a/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/AbstractTest.groovy b/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/AbstractTest.groovy index 14f18b826..d1255cc2a 100644 --- a/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/AbstractTest.groovy +++ b/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/AbstractTest.groovy @@ -23,7 +23,7 @@ abstract class AbstractTest { File settingsFile File propertiesFile - def gradleRunner() { + GradleRunner gradleRunner() { println(PluginUnderTestMetadataReading.readImplementationClasspath()) GradleRunner.create() .withProjectDir(tempDir) diff --git a/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/TestBuildPlugin.groovy b/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/TestBuildPlugin.groovy new file mode 100644 index 000000000..8d4a2366f --- /dev/null +++ b/tools/gradle-plugin/src/integTest/groovy/net/mamoe/mirai/console/gradle/TestBuildPlugin.groovy @@ -0,0 +1,22 @@ +/* + * 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 org.junit.jupiter.api.Test + +class TestBuildPlugin extends AbstractTest { + + @Test + void "can build plugin"() { + gradleRunner() + .withArguments("buildPlugin", "--stacktrace") + .build() + } +} diff --git a/tools/gradle-plugin/src/main/kotlin/BuildMiraiPluginTask.kt b/tools/gradle-plugin/src/main/kotlin/BuildMiraiPluginTask.kt index 0abbdb7e1..c7ce5b512 100644 --- a/tools/gradle-plugin/src/main/kotlin/BuildMiraiPluginTask.kt +++ b/tools/gradle-plugin/src/main/kotlin/BuildMiraiPluginTask.kt @@ -11,7 +11,6 @@ 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.OutputFile import org.jetbrains.kotlin.gradle.plugin.KotlinTarget import java.io.File import javax.inject.Inject @@ -23,7 +22,6 @@ public open class BuildMiraiPluginTask @Inject constructor( /** * ShadowJar 打包结果 */ - @get:OutputFile public val output: File get() = outputs.files.singleFile