@@ -733,10 +733,8 @@ To add a dependency on a library, set the dependency of the required [type](#dep
733
733
```kotlin
734
734
kotlin {
735
735
sourceSets {
736
- val commonMain by getting {
737
- dependencies {
738
- implementation(" com.example:my-library:1.0" )
739
- }
736
+ commonMain.dependencies {
737
+ implementation(" com.example:my-library:1.0" )
740
738
}
741
739
}
742
740
}
@@ -977,10 +975,8 @@ Kotlin/Native targets do not require additional test dependencies, and the `kotl
977
975
```kotlin
978
976
kotlin {
979
977
sourceSets {
980
- val commonTest by getting {
981
- dependencies {
982
- implementation(kotlin("test")) // This brings all the platform dependencies automatically
983
- }
978
+ commonTest.dependencies {
979
+ implementation(kotlin("test")) // This brings all the platform dependencies automatically
984
980
}
985
981
}
986
982
}
@@ -1032,10 +1028,8 @@ kotlin {
1032
1028
}
1033
1029
}
1034
1030
sourceSets {
1035
- val commonTest by getting {
1036
- dependencies {
1037
- implementation(kotlin("test"))
1038
- }
1031
+ commonTest.dependencies {
1032
+ implementation(kotlin("test"))
1039
1033
}
1040
1034
}
1041
1035
}
@@ -1108,24 +1102,21 @@ kotlin.test.infer.jvm.variant=false
1108
1102
1109
1103
If you have used a variant of `kotlin("test")` in your build script explicitly and your project build stopped working with
1110
1104
a compatibility conflict,
1111
- see [this issue in the Compatibility Guide ](compatibility-guide-15.md#do-not-mix-several-jvm-variants-of-kotlin-test-in-a-single-project).
1105
+ see [this issue in the Compatibility guide ](compatibility-guide-15.md#do-not-mix-several-jvm-variants-of-kotlin-test-in-a-single-project).
1112
1106
1113
1107
### Set a dependency on a kotlinx library
1114
1108
1115
- If you use a [`kotlinx` library](https://github.com/Kotlin/kotlinx.coroutines) and need a platform-specific dependency,
1116
- you can use platform-specific variants of libraries with suffixes such as `-jvm` or `-js`, for example,
1117
- `kotlinx-coroutines-core-jvm`. You can also use the library' s base artifact name instead – `kotlinx- coroutines- core`.
1109
+ If you use a multiplatform library and need to depend on the shared code, set the dependency only once in the shared
1110
+ source set. Use the library' s base artifact name, such as `kotlinx- coroutines- core` or `ktor- client- core`:
1118
1111
1119
1112
< tabs group= " build-script" >
1120
1113
< tab title= " Kotlin" group- key= " kotlin" >
1121
1114
1122
1115
```kotlin
1123
1116
kotlin {
1124
1117
sourceSets {
1125
- val jvmMain by getting {
1126
- dependencies {
1127
- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:%coroutinesVersion%" )
1128
- }
1118
+ commonMain.dependencies {
1119
+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:%coroutinesVersion%" )
1129
1120
}
1130
1121
}
1131
1122
}
@@ -1137,9 +1128,9 @@ kotlin {
1137
1128
```groovy
1138
1129
kotlin {
1139
1130
sourceSets {
1140
- jvmMain {
1131
+ commonMain {
1141
1132
dependencies {
1142
- implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm :%coroutinesVersion%'
1133
+ implementation ' org.jetbrains.kotlinx:kotlinx-coroutines-core:%coroutinesVersion%'
1143
1134
}
1144
1135
}
1145
1136
}
@@ -1149,19 +1140,17 @@ kotlin {
1149
1140
< / tab>
1150
1141
< / tabs>
1151
1142
1152
- If you use a multiplatform library and need to depend on the shared code, set the dependency only once, in the shared
1153
- source set. Use the library ' s base artifact name, such as `kotlinx-coroutines-core` or `ktor-client-core`.
1143
+ If you need a kotlinx library for a platform - specific dependency, you can still use the library ' s base artifact name in
1144
+ the corresponding platform source set:
1154
1145
1155
1146
<tabs group="build-script">
1156
1147
<tab title="Kotlin" group-key="kotlin">
1157
1148
1158
1149
```kotlin
1159
1150
kotlin {
1160
1151
sourceSets {
1161
- val commonMain by getting {
1162
- dependencies {
1163
- implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:%coroutinesVersion%")
1164
- }
1152
+ jvmMain.dependencies {
1153
+ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:%coroutinesVersion%")
1165
1154
}
1166
1155
}
1167
1156
}
@@ -1173,7 +1162,7 @@ kotlin {
1173
1162
```groovy
1174
1163
kotlin {
1175
1164
sourceSets {
1176
- commonMain {
1165
+ jvmMain {
1177
1166
dependencies {
1178
1167
implementation ' org.jetbrains.kotlinx: kotlinx- coroutines- core: % coroutinesVersion% '
1179
1168
}
0 commit comments