@@ -11,6 +11,7 @@ plugins {
1111
1212// testWithEmbedded0()
1313
14+
1415dependencies {
1516 compileOnly(kotlin(" stdlib" ))
1617 compileOnly(kotlin(" compiler" ))
@@ -22,25 +23,41 @@ dependencies {
2223 kapt(libs.google.auto.service)
2324 compileOnly(libs.google.auto.service.annotations)
2425
26+ testImplementation(" junit:junit:4.13.2" )
2527 testImplementation(kotlin(" stdlib" ))
26- testImplementation(kotlin(" test-junit" ))
27- testImplementation(kotlin(" compiler-embeddable" ))
28- testImplementation(kotlin(" reflect" ))
29- // testImplementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
28+ testImplementation(kotlin(" test-junit5" ))
3029
30+ testImplementation(kotlin(" compiler" ))
31+ testImplementation(kotlin(" reflect" ))
32+ // see https://github.com/Icyrockton/xjson
33+ testImplementation(kotlin(" compiler-internal-test-framework" )) // compiler plugin test generator / test utils
34+ testRuntimeOnly(kotlin(" test" ))
35+ testRuntimeOnly(kotlin(" script-runtime" ))
36+ testRuntimeOnly(kotlin(" annotations-jvm" ))
3137 testImplementation(project(" :runtime:suspend-transform-annotation" ))
3238 testImplementation(project(" :runtime:suspend-transform-runtime" ))
3339
34- testImplementation(" com.github.tschuchortdev:kotlin-compile-testing:1.4.9" )
40+ // testImplementation("com.github.tschuchortdev:kotlin-compile-testing:1.4.9")
3541// testImplementation("org.bitbucket.mstrobel:procyon-compilertools:0.6.0")
36- // testImplementation("com.bennyhuo.kotlin:kotlin-compile-testing-extensions:1.7.10.2-SNAPSHOT")
3742
3843 testImplementation(libs.kotlinx.coroutines.core)
39- // testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
4044}
4145
4246val compileKotlin: KotlinCompile by tasks
43- compileKotlin.kotlinOptions.freeCompilerArgs + = listOf (" -Xjvm-default=all" , " -opt-in=kotlin.RequiresOptIn" )
47+ compileKotlin.kotlinOptions.freeCompilerArgs + = listOf (
48+ " -Xjvm-default=all" ,
49+ " -opt-in=kotlin.RequiresOptIn" ,
50+ " -opt-in=org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI" ,
51+ )
52+
53+ tasks.withType(KotlinCompile ::class .java).configureEach {
54+ // see https://youtrack.jetbrains.com/issue/KTIJ-21563
55+ // see https://youtrack.jetbrains.com/issue/KT-57297
56+ // kotlinOptions {
57+ // languageVersion = "1.9"
58+ // apiVersion = "1.9"
59+ // }
60+ }
4461
4562repositories {
4663 maven {
@@ -62,3 +79,44 @@ buildConfig {
6279tasks.withType<KotlinCompile > {
6380 kotlinOptions.jvmTarget = " 1.8"
6481}
82+
83+
84+ sourceSets {
85+ test{
86+ kotlin.srcDir(" src/test" )
87+ kotlin.srcDir(" src/test-gen" )
88+ java.srcDir(" src/test-gen" )
89+ }
90+ }
91+
92+ task<JavaExec >(" generateTest" ) {
93+ classpath = sourceSets.test.get().runtimeClasspath
94+ mainClass = " love.forte.plugin.suspendtrans.GenerateTestsKt"
95+ }
96+
97+ // add following properties for test
98+ tasks.test {
99+ useJUnitPlatform()
100+ doFirst {
101+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-stdlib" , " kotlin-stdlib" )
102+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-stdlib-jdk8" , " kotlin-stdlib-jdk8" )
103+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-reflect" , " kotlin-reflect" )
104+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-test" , " kotlin-test" )
105+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-script-runtime" , " kotlin-script-runtime" )
106+ setLibraryProperty(" org.jetbrains.kotlin.test.kotlin-annotations-jvm" , " kotlin-annotations-jvm" )
107+ }
108+ }
109+
110+ fun Test.setLibraryProperty (propName : String , jarName : String ) {
111+ val path = project.configurations
112+ .testRuntimeClasspath.get()
113+ .files
114+ .find { """ $jarName -\d.*jar""" .toRegex().matches(it.name) }
115+ ?.absolutePath
116+ ? : return
117+ systemProperty(propName, path)
118+ }
119+
120+ /*
121+ 上面与测试相关的一些内容参考自 https://github.com/Icyrockton/xjson
122+ */
0 commit comments