Pretty buildscript

This commit is contained in:
Him188 2020-11-12 09:42:18 +08:00
parent 6fe21b9286
commit 1d6dccb793
7 changed files with 84 additions and 227 deletions

View File

@ -13,80 +13,35 @@ plugins {
} }
version = Versions.console version = Versions.console
description = "Console backend for mirai" description = "Mirai Console Backend"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
kotlin { kotlin {
explicitApiWarning() explicitApiWarning()
sourceSets.all {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
//useIR = true
}
}
languageSettings.apply {
enableLanguageFeature("InlineClasses")
progressiveMode = true
useExperimentalAnnotation("kotlin.Experimental")
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalApi")
}
}
} }
dependencies { dependencies {
compileAndTestRuntime("net.mamoe:mirai-core:${Versions.core}") compileAndTestRuntime(`mirai-core`)
compileAndTestRuntime(kotlin("stdlib", Versions.kotlinStdlib)) compileAndTestRuntime(`kotlin-stdlib`)
compileAndTestRuntime(kotlin("stdlib-jdk8", Versions.kotlinStdlib)) compileAndTestRuntime(`kotlin-stdlib-jdk8`)
compileAndTestRuntime("org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}") compileAndTestRuntime(`kotlinx-atomicfu`)
compileAndTestRuntime(kotlinx("coroutines-core", Versions.coroutines)) compileAndTestRuntime(`kotlinx-coroutines-core`)
compileAndTestRuntime(kotlinx("serialization-core", Versions.serialization)) compileAndTestRuntime(`kotlinx-serialization-core`)
compileAndTestRuntime(kotlinx("serialization-json", Versions.serialization)) compileAndTestRuntime(`kotlinx-serialization-json`)
compileAndTestRuntime(kotlin("reflect")) compileAndTestRuntime(`kotlin-reflect`)
smartImplementation("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}") smartImplementation(yamlkt)
smartImplementation("org.jetbrains:annotations:19.0.0") smartImplementation(`jetbrains-annotations`)
smartApi(kotlinx("coroutines-jdk8", Versions.coroutines)) smartApi(`kotlinx-coroutines-jdk8`)
testApi("net.mamoe:mirai-core-qqandroid:${Versions.core}") testApi(`mirai-core-qqandroid`)
testApi(kotlin("stdlib-jdk8")) testApi(`kotlin-stdlib-jdk8`)
testApi(kotlin("test"))
testApi(kotlin("test-junit5"))
testApi("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
} }
tasks { tasks {
"test"(Test::class) {
useJUnitPlatform()
}
val compileKotlin by getting {} val compileKotlin by getting {}
val fillBuildConstants by registering { register("fillBuildConstants") {
group = "mirai" group = "mirai"
doLast { doLast {
(compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsoleBuildConstants.kt" }.single() (compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsoleBuildConstants.kt" }.single()
@ -109,8 +64,4 @@ tasks {
} }
} }
// region PUBLISHING
setupPublishing("mirai-console") setupPublishing("mirai-console")
// endregion

View File

@ -43,14 +43,22 @@ subprojects {
} }
val experimentalAnnotations = arrayOf( val experimentalAnnotations = arrayOf(
"kotlin.Experimental",
"kotlin.RequiresOptIn", "kotlin.RequiresOptIn",
"kotlin.ExperimentalUnsignedTypes", "kotlin.ExperimentalUnsignedTypes",
// "kotlin.ExperimentalStdlibApi", "kotlin.ExperimentalStdlibApi",
"kotlin.contracts.ExperimentalContracts", "kotlin.contracts.ExperimentalContracts",
"kotlin.time.ExperimentalTime",
"kotlin.experimental.ExperimentalTypeInference", "kotlin.experimental.ExperimentalTypeInference",
// "kotlinx.coroutines.ExperimentalCoroutinesApi", "kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"io.ktor.util.KtorExperimentalAPI", "io.ktor.util.KtorExperimentalAPI",
"kotlin.time.ExperimentalTime"
"net.mamoe.mirai.utils.MiraiInternalAPI",
"net.mamoe.mirai.utils.MiraiExperimentalAPI",
"net.mamoe.mirai.console.ConsoleFrontEndImplementation",
"net.mamoe.mirai.console.util.ConsoleExperimentalApi",
"net.mamoe.mirai.console.util.ConsoleInternalApi"
) )
@ -139,10 +147,11 @@ fun Project.configureSourceSets() {
fun Project.configureKotlinExperimentalUsages() { fun Project.configureKotlinExperimentalUsages() {
val sourceSets = kotlinSourceSets ?: return val sourceSets = kotlinSourceSets ?: return
for (target in sourceSets) { for (target in sourceSets) target.languageSettings.run {
enableLanguageFeature("InlineClasses")
progressiveMode = true
experimentalAnnotations.forEach { a -> experimentalAnnotations.forEach { a ->
target.languageSettings.useExperimentalAnnotation(a) useExperimentalAnnotation(a)
//target.languageSettings.enableLanguageFeature("InlineClasses")
} }
} }
} }

View File

@ -7,17 +7,21 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE * https://github.com/mamoe/mirai/blob/master/LICENSE
*/ */
@file:Suppress("MemberVisibilityCanBePrivate") @file:Suppress("MemberVisibilityCanBePrivate", "ObjectPropertyName", "unused")
object Versions { object Versions {
const val core = "1.3.3" const val core = "1.3.3"
const val console = "1.0-RC2-dev-3" const val console = "1.0-RC2-dev-4"
const val consoleGraphical = "0.0.7" const val consoleGraphical = "0.0.7"
const val consoleTerminal = console const val consoleTerminal = console
const val kotlinCompiler = "1.4.20-RC" const val kotlinCompiler = "1.4.20-RC"
const val kotlinStdlib = "1.4.10" const val kotlinStdlib = "1.4.10"
const val kotlinIntellijPlugin = "1.4.20-RC-IJ2020.2-1" // -release
const val intellij = "2020.2.1"
const val coroutines = "1.4.0" const val coroutines = "1.4.0"
const val serialization = "1.0.1" const val serialization = "1.0.1"
const val ktor = "1.4.1" const val ktor = "1.4.1"
@ -28,5 +32,34 @@ object Versions {
const val bintray = "1.8.5" const val bintray = "1.8.5"
const val blockingBridge = "1.4.1" const val blockingBridge = "1.4.1"
@Suppress("SpellCheckingInspection")
const val yamlkt = "0.7.1" const val yamlkt = "0.7.1"
const val intellijGradlePlugin = "0.4.16"
} }
const val `kotlin-compiler` = "org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}"
const val `kotlin-stdlib` = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlinStdlib}"
const val `kotlin-stdlib-jdk8` = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlinStdlib}"
const val `kotlin-reflect` = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlinStdlib}"
const val `kotlin-test` = "org.jetbrains.kotlin:kotlin-test:${Versions.kotlinStdlib}"
const val `kotlin-test-junit5` = "org.jetbrains.kotlin:kotlin-test-junit5:${Versions.kotlinStdlib}"
const val `kotlinx-coroutines-core` = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
const val `kotlinx-coroutines-jdk8` = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:${Versions.coroutines}"
const val `kotlinx-serialization-core` = "org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.serialization}"
const val `kotlinx-serialization-json` = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.serialization}"
const val `kotlinx-serialization-protobuf` = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf:${Versions.serialization}"
const val `kotlinx-atomicfu` = "org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}"
const val `mirai-core` = "net.mamoe:mirai-core:${Versions.core}"
const val `mirai-core-qqandroid` = "net.mamoe:mirai-core-qqandroid:${Versions.core}"
const val `mirai-core-api` = "net.mamoe:mirai-core-api:${Versions.core}"
const val yamlkt = "net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}"
const val `jetbrains-annotations` = "org.jetbrains:annotations:19.0.0"

View File

@ -14,61 +14,12 @@ repositories {
version = Versions.console version = Versions.console
description = "Mirai Console compiler common" description = "Mirai Console compiler common"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
kotlin {
sourceSets.all {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
//useIR = true
}
}
languageSettings.apply {
progressiveMode = true
useExperimentalAnnotation("kotlin.Experimental")
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalApi")
}
}
}
dependencies { dependencies {
api("org.jetbrains:annotations:19.0.0") api(`jetbrains-annotations`)
api(kotlinx("coroutines-jdk8", Versions.coroutines)) // api(`kotlinx-coroutines-jdk8`)
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}") compileOnly(`kotlin-compiler`)
testRuntimeOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}") testRuntimeOnly(`kotlin-compiler`)
testApi(kotlin("test"))
testApi(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
}
tasks {
"test"(Test::class) {
useJUnitPlatform()
}
} }
setupPublishing("mirai-console-compiler-common") setupPublishing("mirai-console-compiler-common")

View File

@ -25,15 +25,7 @@ dependencies {
compileOnly(kotlin("stdlib")) compileOnly(kotlin("stdlib"))
api("com.github.jengelman.gradle.plugins:shadow:6.0.0") api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
api("org.jetbrains:annotations:19.0.0") api(`jetbrains-annotations`)
}
dependencies {
testApi(kotlin("test"))
testApi(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
} }
version = Versions.console version = Versions.console
@ -56,35 +48,16 @@ gradlePlugin {
} }
} }
kotlin { kotlin.target.compilations.all {
sourceSets.all { kotlinOptions {
target.compilations.all { apiVersion = "1.3"
kotlinOptions { languageVersion = "1.3"
apiVersion = "1.3"
languageVersion = "1.3"
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
}
}
languageSettings.apply {
progressiveMode = true
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
}
} }
} }
tasks { tasks {
"test"(Test::class) {
useJUnitPlatform()
}
val compileKotlin by getting {} val compileKotlin by getting {}
@Suppress("UNUSED_VARIABLE")
val fillBuildConstants by registering { val fillBuildConstants by registering {
group = "mirai" group = "mirai"
doLast { doLast {
@ -108,13 +81,4 @@ tasks {
compileKotlin.dependsOn(fillBuildConstants) compileKotlin.dependsOn(fillBuildConstants)
} }
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
setupPublishing("mirai-console-gradle") setupPublishing("mirai-console-gradle")

View File

@ -10,6 +10,6 @@
package net.mamoe.mirai.console.gradle package net.mamoe.mirai.console.gradle
internal object VersionConstants { internal object VersionConstants {
const val CONSOLE_VERSION = "1.0-RC2-dev-3" // value is written here automatically during build const val CONSOLE_VERSION = "1.0-RC2-dev-4" // value is written here automatically during build
const val CORE_VERSION = "1.3.3" // value is written here automatically during build const val CORE_VERSION = "1.3.3" // value is written here automatically during build
} }

View File

@ -6,8 +6,7 @@ plugins {
`maven-publish` `maven-publish`
id("com.jfrog.bintray") id("com.jfrog.bintray")
id("org.jetbrains.intellij") version "0.4.16" id("org.jetbrains.intellij") version Versions.intellijGradlePlugin
} }
repositories { repositories {
@ -17,23 +16,14 @@ repositories {
version = Versions.console version = Versions.console
description = "IntelliJ plugin for Mirai Console" description = "IntelliJ plugin for Mirai Console"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
// See https://github.com/JetBrains/gradle-intellij-plugin/ // See https://github.com/JetBrains/gradle-intellij-plugin/
intellij { intellij {
version = "2020.2.1" version = Versions.intellij
isDownloadSources = true isDownloadSources = true
updateSinceUntilBuild = false updateSinceUntilBuild = false
setPlugins( setPlugins(
"org.jetbrains.kotlin:1.4.20-RC-IJ2020.2-1@eap", "org.jetbrains.kotlin:${Versions.kotlinIntellijPlugin}@eap",
"java" "java"
) )
} }
@ -62,59 +52,18 @@ tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
</ul> </ul>
""".trimIndent()) """.trimIndent())
changeNotes(""" changeNotes("""
Initial release See https://github.com/mamoe/mirai-console/releases
""".trimIndent()) """.trimIndent())
} }
kotlin {
sourceSets.all {
target.compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
//useIR = true
}
}
languageSettings.apply {
progressiveMode = true
useExperimentalAnnotation("kotlin.Experimental")
useExperimentalAnnotation("kotlin.RequiresOptIn")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiInternalAPI")
useExperimentalAnnotation("net.mamoe.mirai.utils.MiraiExperimentalAPI")
useExperimentalAnnotation("net.mamoe.mirai.console.ConsoleFrontEndImplementation")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleExperimentalApi")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.experimental.ExperimentalTypeInference")
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlinx.serialization.ExperimentalSerializationApi")
useExperimentalAnnotation("net.mamoe.mirai.console.util.ConsoleInternalApi")
}
}
}
dependencies { dependencies {
api("org.jetbrains:annotations:19.0.0") api(`jetbrains-annotations`)
api(kotlinx("coroutines-jdk8", Versions.coroutines)) api(`kotlinx-coroutines-jdk8`)
api(project(":mirai-console-compiler-common")) api(project(":mirai-console-compiler-common"))
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}") compileOnly(`kotlin-compiler`)
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
compileOnly(files("libs/ide-common.jar")) compileOnly(files("libs/ide-common.jar"))
testApi(kotlin("test"))
testApi(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.2.0")
}
tasks {
"test"(Test::class) {
useJUnitPlatform()
}
} }
setupPublishing("mirai-console-intellij") setupPublishing("mirai-console-intellij")