hey guys. is there a way to simplify this record? ...
# gradle
d
hey guys. is there a way to simplify this record?
Copy code
compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = [
                '-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi',
                '-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi',
                "-XXLanguage:+InlineClasses"
        ]
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = [
                '-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi',
                '-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi',
                "-XXLanguage:+InlineClasses"
        ]
    }
}
e
You may want to configure all
KotlinCompile
tasks the same way
Copy code
tasks.withType(KotlinCompile) {
    // configure all KotlinCompile tasks
}
d
it complains
Could not get unknown property 'KotlinCompile' for root project...
this one seems works
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile.class).all {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = [
                '-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi',
                '-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi',
                "-XXLanguage:+InlineClasses"
        ]
    }
}
e
yep, you either need to fully qualify the
KotlinCompile
class name or import it, also the
.all {
is not needed
g
Ehh, this should be Kotlin plugin extension DSL, not task, not freeCompilerArgs, , it's very painful to configure, especially for ones who not very familiar with Gradle
And still require knowledge how to do that for ones who familiar