Kotlin-compiler-embeddable and kotlinx.coroutines


#1

I have a project where both kotlin-compiler-embeddable and kotlinx.coroutines are used. Below is the current working (albeit stripped down) build.gradle.

buildscript {
    ext {
        kotlinVersion = '1.1.51'
        kotlinCoroutinesVersion = '0.19.3'
    }
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
    }
}

apply plugin: 'kotlin'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion")
    compile("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
    compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion")
    compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion")
    compile("org.jetbrains.kotlinx:kotlinx-coroutines-rx2:$kotlinCoroutinesVersion")
}

Today I tried to update to Kotlin 1.2.0:

kotlinVersion = '1.2.0'
kotlinCoroutinesVersion = '0.20'

In IDEA everything looks fine, however, when I tried to compile the project code like this had errors about No value passed for parameter 'context'.

import kotlinx.coroutines.experimental.launch

launch { foo() }

After a bit of digging I noticed kotlin-compiler-embeddable has started to ship with kotlinx.coroutines version 0.14 (!)

While 0.14 seems to be working fine with slight changes to code (I didn’t do any extensive testing) it feels backwards to use such old version. Are there plans to update to more recent version or should I be using different dependencies or something?


#2

With 1.2.20 the situation is the same.

Workaround: remove the kotlinx.coroutines from kotlin-compiler-embeddable and repack as 1.2.20.Hack, fake the version in local .m2 repository; update your pom.xml

Everything seems to work, but it’s definitely not ideal.


#3

I made a ticket (KT-22196) about this to Kotlin issue tracker and this should be solved in 1.2.30