-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
135 lines (113 loc) · 4.04 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
kotlin("jvm")
kotlin("plugin.serialization")
id("com.github.gmazzo.buildconfig")
id("suspend-transform.jvm-maven-publish")
}
//testWithEmbedded0()
dependencies {
compileOnly(kotlin("stdlib"))
implementation(kotlin("compiler"))
compileOnly(libs.kotlinx.coroutines.core)
api(libs.kotlinx.serialization.json)
// TODO 改成二进制的,比如 protobuf
testImplementation("junit:junit:4.13.2")
testImplementation(kotlin("stdlib"))
testImplementation(kotlin("test-junit5"))
testImplementation(kotlin("compiler"))
testImplementation(kotlin("reflect"))
// see https://github.com/Icyrockton/xjson
testImplementation(kotlin("compiler-internal-test-framework")) // compiler plugin test generator / test utils
testRuntimeOnly(kotlin("test"))
testRuntimeOnly(kotlin("script-runtime"))
testRuntimeOnly(kotlin("annotations-jvm"))
testImplementation(project(":runtime:suspend-transform-annotation"))
testImplementation(project(":runtime:suspend-transform-runtime"))
// testImplementation("com.github.tschuchortdev:kotlin-compile-testing:1.4.9")
// testImplementation("org.bitbucket.mstrobel:procyon-compilertools:0.6.0")
testImplementation(libs.kotlinx.coroutines.core)
}
//val compileKotlin: KotlinCompile by tasks
//compileKotlin.kotlinOptions.freeCompilerArgs += listOf(
// "-Xjvm-default=all",
// "-opt-in=kotlin.RequiresOptIn",
// "-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI",
//)
//tasks.withType<KotlinCompile> {
// kotlinOptions.jvmTarget = "1.8"
//}
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
optIn.addAll(
"kotlin.RequiresOptIn",
"org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI"
)
freeCompilerArgs.addAll(
"-Xjvm-default=all",
// "-opt-in=kotlin.RequiresOptIn",
// "-opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI",
)
}
}
tasks.withType(KotlinCompile::class.java).configureEach {
// see https://youtrack.jetbrains.com/issue/KTIJ-21563
// see https://youtrack.jetbrains.com/issue/KT-57297
// kotlinOptions {
// languageVersion = "1.9"
// apiVersion = "1.9"
// }
}
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
mavenContent {
snapshotsOnly()
}
}
}
buildConfig {
useKotlinOutput {
internalVisibility = true
}
withoutPackage()
buildConfigField("String", "KOTLIN_PLUGIN_ID", "\"${rootProject.extra["kotlin_plugin_id"]}\"")
}
sourceSets {
test{
kotlin.srcDir("src/test")
kotlin.srcDir("src/test-gen")
java.srcDir("src/test-gen")
}
}
task<JavaExec>("generateTest") {
classpath = sourceSets.test.get().runtimeClasspath
mainClass = "love.forte.plugin.suspendtrans.GenerateTestsKt"
}
// add following properties for test
tasks.test {
useJUnitPlatform()
doFirst {
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-annotations-jvm", "kotlin-annotations-jvm")
}
}
fun Test.setLibraryProperty(propName: String, jarName: String) {
val path = project.configurations
.testRuntimeClasspath.get()
.files
.find { """$jarName-\d.*jar""".toRegex().matches(it.name) }
?.absolutePath
?: return
systemProperty(propName, path)
}
/*
上面与测试相关的一些内容参考自 https://github.com/Icyrockton/xjson
*/