This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
88 lines (71 loc) · 2.45 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
plugins {
kotlin("jvm") version "1.3.71"
kotlin("plugin.serialization") version "1.3.70"
id("com.github.johnrengelman.shadow") version "5.2.0"
}
group = "com.github.dazecake"
version = "0.4.1"
repositories {
maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
maven(url = "https://mirrors.huaweicloud.com/repository/maven")
mavenCentral()
jcenter()
}
val miraiCoreVersion = "1.1.3"
val miraiConsoleVersion = "0.5.1"
val kotlinVersion = "1.3.71"
val ktorVersion = "1.3.2"
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
compileOnly("net.mamoe:mirai-core:$miraiCoreVersion")
compileOnly("net.mamoe:mirai-console:$miraiConsoleVersion")
implementation("io.ktor:ktor-client-websockets:$ktorVersion")
compileOnly(kotlin("serialization", kotlinVersion))
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
val runMiraiConsole by creating(JavaExec::class.java) {
group = "mirai"
dependsOn(shadowJar)
dependsOn(testClasses)
val testConsoleDir = "test"
doFirst {
fun removeOldVersions() {
File("$testConsoleDir/plugins/").walk()
.filter { it.name.matches(Regex("""${project.name}-.*-all.jar""")) }
.forEach {
it.delete()
println("deleting old files: ${it.name}")
}
}
fun copyBuildOutput() {
File("build/libs/").walk()
.filter { it.name.contains("-all") }
.maxBy { it.lastModified() }
?.let {
println("Coping ${it.name}")
it.inputStream().transferTo(File("$testConsoleDir/plugins/${it.name}").apply { createNewFile() }.outputStream())
println("Copied ${it.name}")
}
}
workingDir = File(testConsoleDir)
workingDir.mkdir()
File(workingDir, "plugins").mkdir()
removeOldVersions()
copyBuildOutput()
classpath = sourceSets["test"].runtimeClasspath
main = "mirai.RunMirai"
standardInput = System.`in`
args(miraiCoreVersion, miraiConsoleVersion)
}
}
}