How to pass compiler arguments to Kotlin Compiler with Gradle

You can specify compiler args inside kotlinOptions closure on tasks of KotlinCompile type. For all of them, for instance:

allprojects {
    ...

    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions {
            jvmTarget = '1.6'
            freeCompilerArgs += '-include-runtime'
        }
    }
}

Kotlin docs: using Gradle


Try this:

compileKotlin {
    kotlinOptions.includeRuntime = true
}

UPD btw this exact option includeRuntime couldn't work because it is not Gradle way. There are many options to build jar with dependencies in Gradle: Gradle – Create a Jar file with dependencies, Gradle Shadow

Tags:

Gradle

Kotlin