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
description = "Console backend for mirai"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile::class.java) {
options.encoding = "UTF8"
}
description = "Mirai Console Backend"
kotlin {
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 {
compileAndTestRuntime("net.mamoe:mirai-core:${Versions.core}")
compileAndTestRuntime(kotlin("stdlib", Versions.kotlinStdlib))
compileAndTestRuntime(kotlin("stdlib-jdk8", Versions.kotlinStdlib))
compileAndTestRuntime(`mirai-core`)
compileAndTestRuntime(`kotlin-stdlib`)
compileAndTestRuntime(`kotlin-stdlib-jdk8`)
compileAndTestRuntime("org.jetbrains.kotlinx:atomicfu:${Versions.atomicFU}")
compileAndTestRuntime(kotlinx("coroutines-core", Versions.coroutines))
compileAndTestRuntime(kotlinx("serialization-core", Versions.serialization))
compileAndTestRuntime(kotlinx("serialization-json", Versions.serialization))
compileAndTestRuntime(kotlin("reflect"))
compileAndTestRuntime(`kotlinx-atomicfu`)
compileAndTestRuntime(`kotlinx-coroutines-core`)
compileAndTestRuntime(`kotlinx-serialization-core`)
compileAndTestRuntime(`kotlinx-serialization-json`)
compileAndTestRuntime(`kotlin-reflect`)
smartImplementation("net.mamoe.yamlkt:yamlkt:${Versions.yamlkt}")
smartImplementation("org.jetbrains:annotations:19.0.0")
smartApi(kotlinx("coroutines-jdk8", Versions.coroutines))
smartImplementation(yamlkt)
smartImplementation(`jetbrains-annotations`)
smartApi(`kotlinx-coroutines-jdk8`)
testApi("net.mamoe:mirai-core-qqandroid:${Versions.core}")
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")
testApi(`mirai-core-qqandroid`)
testApi(`kotlin-stdlib-jdk8`)
}
tasks {
"test"(Test::class) {
useJUnitPlatform()
}
val compileKotlin by getting {}
val fillBuildConstants by registering {
register("fillBuildConstants") {
group = "mirai"
doLast {
(compileKotlin as KotlinCompile).source.filter { it.name == "MiraiConsoleBuildConstants.kt" }.single()
@ -109,8 +64,4 @@ tasks {
}
}
// region PUBLISHING
setupPublishing("mirai-console")
// endregion
setupPublishing("mirai-console")

View File

@ -43,14 +43,22 @@ subprojects {
}
val experimentalAnnotations = arrayOf(
"kotlin.Experimental",
"kotlin.RequiresOptIn",
"kotlin.ExperimentalUnsignedTypes",
// "kotlin.ExperimentalStdlibApi",
"kotlin.ExperimentalStdlibApi",
"kotlin.contracts.ExperimentalContracts",
"kotlin.time.ExperimentalTime",
"kotlin.experimental.ExperimentalTypeInference",
// "kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"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() {
val sourceSets = kotlinSourceSets ?: return
for (target in sourceSets) {
for (target in sourceSets) target.languageSettings.run {
enableLanguageFeature("InlineClasses")
progressiveMode = true
experimentalAnnotations.forEach { a ->
target.languageSettings.useExperimentalAnnotation(a)
//target.languageSettings.enableLanguageFeature("InlineClasses")
useExperimentalAnnotation(a)
}
}
}

View File

@ -7,17 +7,21 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@file:Suppress("MemberVisibilityCanBePrivate")
@file:Suppress("MemberVisibilityCanBePrivate", "ObjectPropertyName", "unused")
object Versions {
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 consoleTerminal = console
const val kotlinCompiler = "1.4.20-RC"
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 serialization = "1.0.1"
const val ktor = "1.4.1"
@ -28,5 +32,34 @@ object Versions {
const val bintray = "1.8.5"
const val blockingBridge = "1.4.1"
@Suppress("SpellCheckingInspection")
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
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 {
api("org.jetbrains:annotations:19.0.0")
api(kotlinx("coroutines-jdk8", Versions.coroutines))
api(`jetbrains-annotations`)
// api(`kotlinx-coroutines-jdk8`)
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
testRuntimeOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
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()
}
compileOnly(`kotlin-compiler`)
testRuntimeOnly(`kotlin-compiler`)
}
setupPublishing("mirai-console-compiler-common")

View File

@ -25,15 +25,7 @@ dependencies {
compileOnly(kotlin("stdlib"))
api("com.github.jengelman.gradle.plugins:shadow:6.0.0")
api("org.jetbrains:annotations:19.0.0")
}
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")
api(`jetbrains-annotations`)
}
version = Versions.console
@ -56,35 +48,16 @@ gradlePlugin {
}
}
kotlin {
sourceSets.all {
target.compilations.all {
kotlinOptions {
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")
}
kotlin.target.compilations.all {
kotlinOptions {
apiVersion = "1.3"
languageVersion = "1.3"
}
}
tasks {
"test"(Test::class) {
useJUnitPlatform()
}
val compileKotlin by getting {}
@Suppress("UNUSED_VARIABLE")
val fillBuildConstants by registering {
group = "mirai"
doLast {
@ -108,13 +81,4 @@ tasks {
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")

View File

@ -10,6 +10,6 @@
package net.mamoe.mirai.console.gradle
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
}

View File

@ -6,8 +6,7 @@ plugins {
`maven-publish`
id("com.jfrog.bintray")
id("org.jetbrains.intellij") version "0.4.16"
id("org.jetbrains.intellij") version Versions.intellijGradlePlugin
}
repositories {
@ -17,23 +16,14 @@ repositories {
version = Versions.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/
intellij {
version = "2020.2.1"
version = Versions.intellij
isDownloadSources = true
updateSinceUntilBuild = false
setPlugins(
"org.jetbrains.kotlin:1.4.20-RC-IJ2020.2-1@eap",
"org.jetbrains.kotlin:${Versions.kotlinIntellijPlugin}@eap",
"java"
)
}
@ -62,59 +52,18 @@ tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
</ul>
""".trimIndent())
changeNotes("""
Initial release
See https://github.com/mamoe/mirai-console/releases
""".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 {
api("org.jetbrains:annotations:19.0.0")
api(kotlinx("coroutines-jdk8", Versions.coroutines))
api(`jetbrains-annotations`)
api(`kotlinx-coroutines-jdk8`)
api(project(":mirai-console-compiler-common"))
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
compileOnly("org.jetbrains.kotlin:kotlin-compiler:${Versions.kotlinCompiler}")
compileOnly(`kotlin-compiler`)
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")