2021-01-28 09:32:22 +08:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-09-13 15:27:42 +08:00
|
|
|
@file:Suppress("UnusedImport")
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
kotlin("jvm")
|
2020-09-19 20:33:34 +08:00
|
|
|
id("java-gradle-plugin")
|
|
|
|
id("com.gradle.plugin-publish")
|
2021-04-06 00:56:44 +08:00
|
|
|
groovy
|
2020-09-13 15:27:42 +08:00
|
|
|
id("java")
|
2020-09-19 20:33:34 +08:00
|
|
|
//signing
|
2020-09-13 15:27:42 +08:00
|
|
|
`maven-publish`
|
2020-09-19 20:33:34 +08:00
|
|
|
|
|
|
|
id("com.github.johnrengelman.shadow")
|
|
|
|
}
|
|
|
|
|
2021-04-06 00:56:44 +08:00
|
|
|
val integTest = sourceSets.create("integTest")
|
|
|
|
|
2021-08-08 14:33:32 +08:00
|
|
|
/**
|
|
|
|
* Because we use [compileOnly] for `kotlin-gradle-plugin`, it would be missing
|
|
|
|
* in `plugin-under-test-metadata.properties`. Here we inject the jar into TestKit plugin
|
|
|
|
* classpath via [PluginUnderTestMetadata] to avoid [NoClassDefFoundError].
|
|
|
|
*/
|
|
|
|
val kotlinVersionForIntegrationTest: Configuration by configurations.creating
|
|
|
|
|
2020-09-19 20:33:34 +08:00
|
|
|
dependencies {
|
|
|
|
compileOnly(gradleApi())
|
2020-11-28 13:53:53 +08:00
|
|
|
compileOnly(gradleKotlinDsl())
|
2021-08-08 14:33:32 +08:00
|
|
|
compileOnly(kotlin("gradle-plugin-api"))
|
|
|
|
compileOnly(kotlin("gradle-plugin"))
|
2020-09-19 20:33:34 +08:00
|
|
|
compileOnly(kotlin("stdlib"))
|
|
|
|
|
2021-03-29 23:57:16 +08:00
|
|
|
implementation("com.google.code.gson:gson:2.8.6")
|
|
|
|
|
2020-09-19 20:33:34 +08:00
|
|
|
api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
|
2020-11-12 09:42:18 +08:00
|
|
|
api(`jetbrains-annotations`)
|
2021-05-25 12:13:43 +08:00
|
|
|
api("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
|
2021-04-06 00:56:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
testApi(kotlin("test-junit5"))
|
|
|
|
testApi("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")
|
|
|
|
testApi("org.junit.jupiter:junit-jupiter-params:${Versions.junit}")
|
|
|
|
|
|
|
|
"integTestApi"(kotlin("test-junit5"))
|
|
|
|
"integTestApi"("org.junit.jupiter:junit-jupiter-api:${Versions.junit}")
|
|
|
|
"integTestApi"("org.junit.jupiter:junit-jupiter-params:${Versions.junit}")
|
|
|
|
"integTestImplementation"("org.junit.jupiter:junit-jupiter-engine:${Versions.junit}")
|
|
|
|
// "integTestImplementation"("org.spockframework:spock-core:1.3-groovy-2.5")
|
|
|
|
"integTestImplementation"(gradleTestKit())
|
2021-08-08 14:33:32 +08:00
|
|
|
|
|
|
|
kotlinVersionForIntegrationTest(kotlin("gradle-plugin", "1.5.21"))
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named<PluginUnderTestMetadata>("pluginUnderTestMetadata") {
|
|
|
|
pluginClasspath.from(kotlinVersionForIntegrationTest)
|
2020-09-13 15:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
version = Versions.console
|
|
|
|
description = "Gradle plugin for Mirai Console"
|
|
|
|
|
2020-11-28 13:57:58 +08:00
|
|
|
kotlin {
|
|
|
|
explicitApi()
|
|
|
|
}
|
|
|
|
|
2020-09-19 20:33:34 +08:00
|
|
|
pluginBundle {
|
|
|
|
website = "https://github.com/mamoe/mirai-console"
|
|
|
|
vcsUrl = "https://github.com/mamoe/mirai-console"
|
|
|
|
tags = listOf("framework", "kotlin", "mirai")
|
2020-09-13 15:27:42 +08:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:33:34 +08:00
|
|
|
gradlePlugin {
|
2021-04-06 00:56:44 +08:00
|
|
|
testSourceSets(integTest)
|
2020-09-19 20:33:34 +08:00
|
|
|
plugins {
|
|
|
|
create("miraiConsole") {
|
|
|
|
id = "net.mamoe.mirai-console"
|
|
|
|
displayName = "Mirai Console"
|
|
|
|
description = project.description
|
|
|
|
implementationClass = "net.mamoe.mirai.console.gradle.MiraiConsoleGradlePlugin"
|
|
|
|
}
|
|
|
|
}
|
2020-09-13 15:27:42 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 09:42:18 +08:00
|
|
|
kotlin.target.compilations.all {
|
|
|
|
kotlinOptions {
|
|
|
|
apiVersion = "1.3"
|
2021-11-18 11:05:49 +08:00
|
|
|
languageVersion = "1.4"
|
2020-09-13 15:27:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-06 00:56:44 +08:00
|
|
|
val integrationTestTask = tasks.register<Test>("integTest") {
|
|
|
|
description = "Runs the integration tests."
|
|
|
|
group = "verification"
|
|
|
|
testClassesDirs = integTest.output.classesDirs
|
|
|
|
classpath = integTest.runtimeClasspath
|
|
|
|
mustRunAfter(tasks.test)
|
|
|
|
}
|
|
|
|
tasks.check {
|
|
|
|
dependsOn(integrationTestTask)
|
|
|
|
}
|
|
|
|
|
2020-09-13 15:27:42 +08:00
|
|
|
tasks {
|
2020-09-19 20:33:34 +08:00
|
|
|
val compileKotlin by getting {}
|
|
|
|
|
|
|
|
val fillBuildConstants by registering {
|
|
|
|
group = "mirai"
|
|
|
|
doLast {
|
2021-11-18 11:11:27 +08:00
|
|
|
projectDir.resolve("src/main/kotlin/VersionConstants.kt").apply { createNewFile() }
|
|
|
|
.writeText(
|
|
|
|
projectDir.resolve("src/main/kotlin/VersionConstants.kt.template").readText()
|
|
|
|
.replace("$\$CONSOLE_VERSION$$", Versions.console)
|
|
|
|
.replace("$\$CORE_VERSION$$", Versions.core)
|
|
|
|
)
|
2020-09-19 20:33:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
compileKotlin.dependsOn(fillBuildConstants)
|
|
|
|
}
|