Skip to content

Commit 5a71f7b

Browse files
authored
Unify Groovy and Kotlin DSL code snippets (#3096)
Use common syntax where possible
1 parent 2d96dc9 commit 5a71f7b

File tree

1 file changed

+16
-30
lines changed

1 file changed

+16
-30
lines changed

README.md

+16-30
Original file line numberDiff line numberDiff line change
@@ -99,55 +99,39 @@ And make sure that you use the latest Kotlin version:
9999

100100
Add dependencies (you can also add other modules that you need):
101101

102-
```groovy
102+
```kotlin
103103
dependencies {
104-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
104+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
105105
}
106106
```
107107

108108
And make sure that you use the latest Kotlin version:
109109

110-
```groovy
111-
buildscript {
112-
ext.kotlin_version = '1.6.0'
110+
```kotlin
111+
plugins {
112+
// For build.gradle.kts (Kotlin DSL)
113+
kotlin("jvm") version "1.6.0"
114+
115+
// For build.gradle (Groovy DSL)
116+
id "org.jetbrains.kotlin.jvm" version "1.6.0"
113117
}
114118
```
115119

116120
Make sure that you have `mavenCentral()` in the list of repositories:
117121

118-
```
122+
```kotlin
119123
repositories {
120124
mavenCentral()
121125
}
122126
```
123127

124-
### Gradle Kotlin DSL
125-
126-
Add dependencies (you can also add other modules that you need):
127-
128-
```groovy
129-
dependencies {
130-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
131-
}
132-
```
133-
134-
And make sure that you use the latest Kotlin version:
135-
136-
```groovy
137-
plugins {
138-
kotlin("jvm") version "1.6.0"
139-
}
140-
```
141-
142-
Make sure that you have `mavenCentral()` in the list of repositories.
143-
144128
### Android
145129

146130
Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
147131
module as a dependency when using `kotlinx.coroutines` on Android:
148132

149-
```groovy
150-
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
133+
```kotlin
134+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
151135
```
152136

153137
This gives you access to the Android [Dispatchers.Main]
@@ -165,7 +149,8 @@ For more details see ["Optimization" section for Android](ui/kotlinx-coroutines-
165149
The `kotlinx-coroutines-core` artifact contains a resource file that is not required for the coroutines to operate
166150
normally and is only used by the debugger. To exclude it at no loss of functionality, add the following snippet to the
167151
`android` block in your Gradle file for the application subproject:
168-
```groovy
152+
153+
```kotlin
169154
packagingOptions {
170155
resources.excludes += "DebugProbesKt.bin"
171156
}
@@ -177,7 +162,8 @@ Core modules of `kotlinx.coroutines` are also available for
177162
[Kotlin/JS](https://kotlinlang.org/docs/reference/js-overview.html) and [Kotlin/Native](https://kotlinlang.org/docs/reference/native-overview.html).
178163

179164
In common code that should get compiled for different platforms, you can add a dependency to `kotlinx-coroutines-core` right to the `commonMain` source set:
180-
```groovy
165+
166+
```kotlin
181167
commonMain {
182168
dependencies {
183169
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")

0 commit comments

Comments
 (0)