Add Kotlin Gradle DSL to configure coroutines from build.gradle

This commit is contained in:
Alexey Tsvetkov
2017-01-26 23:14:17 +03:00
parent 08caf0a011
commit 1420bd1b33
8 changed files with 118 additions and 25 deletions
@@ -16,6 +16,8 @@
package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.util.getFileByName
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.Test
import java.io.File
@@ -26,6 +28,24 @@ class CoroutinesIT: BaseGradleIT() {
private const val GRADLE_PROPERTIES = "gradle.properties"
}
@Test
fun testCoroutinesProjectDSL() {
val project = Project("coroutinesProjectDSL", GRADLE_VERSION)
project.build("assemble") {
assertSuccessful()
assertContains("-Xcoroutines=enable")
}
project.projectDir.getFileByName("build.gradle").modify {
it.replace("coroutines 'enable'", "coroutines 'error'")
}
project.build("assemble") {
assertFailed()
assertContains("-Xcoroutines=error")
}
}
@Test
fun testCoroutinesJvmEnabled() {
jvmProject.doTest("enable", GRADLE_PROPERTIES)
@@ -0,0 +1,25 @@
buildscript {
repositories {
mavenLocal()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "kotlin"
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
experimental {
coroutines 'enable'
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m
@@ -0,0 +1 @@
suspend fun <T> suspendCoroutine(): T = TODO()