1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
# Module kotlin-gradle-plugin
`kotlin-gradle-plugin` artifact provides multiple plugins.
### kotlin
How to apply:
```
apply plugin: 'kotlin'
```
Tasks:
| Name | Type | Description
|------------------------------|--------------------|---------------|
| compileKotlin | [KotlinJvmCompile] | A task is created for `main` source set |
| compileTestKotlin | [KotlinJvmCompile] | A task is created for `test` source set |
| compile*SourceSetName*Kotlin | [KotlinJvmCompile] | A task is created for each additional source set |
Each [KotlinJvmCompile] task provides `kotlinOptions` ([KotlinJvmOptions]) extension:
```
compileKotlin {
kotlinOptions {
noStdlib = true
}
// kotlinOptions.noStdlib = true
}
```
### kotlin-android
A plugin that should be used for Android development.
How to apply:
```
apply plugin: 'kotlin-android'
```
Tasks:
| Name | Type | Description
|------------------------------|--------------------|---------------|
| compile*VariantName*Kotlin | [KotlinJvmCompile] | A task is created for each variant |
Note that tasks are created after evaluation, so all references to tasks should be done in `afterEvaluate` section:
```
afterEvaluate {
compileDebugKotlin {
kotlinOptions {
noStdlib = true
}
}
}
```
Android plugin also adds `kotlinOptions` extension to `android` section to set options for all kotlin tasks:
```
android {
kotlinOptions {
noStdlib = true
}
}
```
Task's `kotlinOptions` "override" ones in `android` section:
```
android {
kotlinOptions {
noStdlib = true
}
}
afterEvaluate {
compileDebugKotlin {
kotlinOptions {
noStdlib = false
}
}
}
// compileProductionKotlin.noStdlib == true
// compileDebugKotlin.noStdlib == false
```
### kotlin2js
How to apply:
```
apply plugin: 'kotlin2js'
```
Tasks:
| Name | Type | Description
|--------------------------------|--------------------|---------------|
| compileKotlin2Js | [KotlinJsCompile] | A task is created for `main` source set |
| compileTestKotlin2Js | [KotlinJsCompile] | A task is created for `test` source set |
| compile*SourceSetName*Kotlin2Js| [KotlinJsCompile] | A task is created for each additional source set |
Each [KotlinJsCompile] task provides `kotlinOptions` ([KotlinJsOptions]) extension:
```
compileKotlin2Js {
kotlinOptions {
noStdlib = true
}
// kotlinOptions.noStdlib = true
}
```
|