xref: /aosp_15_r20/external/kotlinx.coroutines/buildSrc/src/main/kotlin/Projects.kt (revision 7a7160fed73afa6648ef8aa100d4a336fe921d9a)
1 @file:JvmName("Projects")
2 
3 import org.gradle.api.*
4 import org.gradle.api.tasks.*
5 
Projectnull6 fun Project.version(target: String): String {
7     if (target == "kotlin") {
8         getOverriddenKotlinVersion(this)?.let { return it }
9     }
10     return property("${target}_version") as String
11 }
12 
13 val Project.jdkToolchainVersion: Int get() = property("jdk_toolchain_version").toString().toInt()
14 
15 /**
16  * TODO: check if this is still relevant.
17  * It was introduced in <https://github.com/Kotlin/kotlinx.coroutines/pull/2389>, and the project for which this was
18  * done is already long finished.
19  */
20 val Project.nativeTargetsAreEnabled: Boolean get() = rootProject.properties["disable_native_targets"] == null
21 
22 val Project.sourceSets: SourceSetContainer
23     get() = extensions.getByName("sourceSets") as SourceSetContainer
24 
25 val coreModule = "kotlinx-coroutines-core"
26 val jdk8ObsoleteModule = "kotlinx-coroutines-jdk8"
27 val testUtilsModule = "test-utils"
28 
29 // Not applicable for Kotlin plugin
30 val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom")
31 
32 // Not published
33 val unpublished = setOf("kotlinx.coroutines", "benchmarks", "android-unit-tests", testUtilsModule)
34 
35 val Project.isMultiplatform: Boolean get() = name in setOf(coreModule, "kotlinx-coroutines-test", testUtilsModule)
36 val Project.isBom: Boolean get() = name == "kotlinx-coroutines-bom"
37 
38 // Projects that we do not check for Android API level 14 check due to various limitations
39 val androidNonCompatibleProjects = setOf(
40     "kotlinx-coroutines-debug",
41     "kotlinx-coroutines-swing",
42     "kotlinx-coroutines-javafx",
43     "kotlinx-coroutines-jdk8",
44     "kotlinx-coroutines-jdk9",
45     "kotlinx-coroutines-reactor",
46     "kotlinx-coroutines-test"
47 )
48