xref: /aosp_15_r20/external/kotlinx.atomicfu/integration-testing/build.gradle.kts (revision 68017707106cb9da9fed635c150bc497c09c160f)
1 import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
2 
<lambda>null3 plugins {
4     kotlin("jvm")
5 }
6 
<lambda>null7 repositories {
8     mavenLocal()
9     maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev")
10     mavenCentral()
11 }
12 
<lambda>null13 java {
14     toolchain {
15         languageVersion.set(JavaLanguageVersion.of(11))
16     }
17 }
18 
<lambda>null19 kotlin {
20     jvmToolchain(11)
21 }
22 
23 val kotlin_version = providers.gradleProperty("kotlin_version").orNull
24 val atomicfu_snapshot_version = providers.gradleProperty("version").orNull
25 
<lambda>null26 sourceSets {
27     create("mavenTest") {
28         compileClasspath += files(sourceSets.main.get().output, configurations.testRuntimeClasspath)
29         runtimeClasspath += output + compileClasspath
30     }
31 
32     create("functionalTest") {
33         compileClasspath += files(sourceSets.main.get().output, configurations.testRuntimeClasspath)
34         runtimeClasspath += output + compileClasspath
35     }
36 }
37 
<lambda>null38 dependencies {
39     // common dependencies
40     implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
41     testImplementation("org.jetbrains.kotlin:kotlin-test")
42     implementation("org.jetbrains.kotlin:kotlin-script-runtime")
43     implementation(kotlin("script-runtime"))
44 
45     // mavenTest dependencies
46     "mavenTestImplementation"("org.jetbrains.kotlinx:atomicfu-jvm:$atomicfu_snapshot_version")
47 
48     // functionalTest dependencies
49     "functionalTestImplementation"(gradleTestKit())
50     "functionalTestApi"("org.ow2.asm:asm:9.3")
51     "functionalTestApi"("org.ow2.asm:asm-commons:9.3")
52 }
53 
<lambda>null54 val mavenTest by tasks.registering(Test::class) {
55     testClassesDirs = sourceSets["mavenTest"].output.classesDirs
56     classpath = sourceSets["mavenTest"].runtimeClasspath
57 
58     dependsOn(":atomicfu:publishToMavenLocal")
59 
60     outputs.upToDateWhen { false }
61 }
62 
<lambda>null63 val functionalTest by tasks.registering(Test::class) {
64     testClassesDirs = sourceSets["functionalTest"].output.classesDirs
65     classpath = sourceSets["functionalTest"].runtimeClasspath
66 
67     systemProperties["kotlinVersion"] = kotlin_version
68     systemProperties["atomicfuVersion"] = atomicfu_snapshot_version
69 
70     dependsOn(":atomicfu-gradle-plugin:publishToMavenLocal")
71     // atomicfu-transformer and atomicfu artifacts should also be published as it's required by atomicfu-gradle-plugin.
72     dependsOn(":atomicfu-transformer:publishToMavenLocal")
73     dependsOn(":atomicfu:publishToMavenLocal")
74 
75     outputs.upToDateWhen { false }
76 }
77 
<lambda>null78 tasks.check { dependsOn(mavenTest, functionalTest) }
79 
80 // Setup K/N infrastructure to use klib utility in tests
81 // TODO: klib checks are skipped for now because of this problem KT-61143
82 val Project.konanHome: String
83 get() = rootProject.properties["kotlin.native.home"]?.toString()
84         ?: NativeCompilerDownloader(project).compilerDirectory.absolutePath
85 
86 val embeddableJar = File(project.konanHome).resolve("konan/lib/kotlin-native-compiler-embeddable.jar")
87 
<lambda>null88 tasks.withType<Test> {
89     // Pass the path to native jars
90     systemProperty("kotlin.native.jar", embeddableJar)
91 }
92