https://kotlinlang.org logo
Title
p

plastiv

10/31/2018, 1:46 PM
How to declare kotlin compile args globally without copy-paste for every subproject? Currently using this snippet
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        allWarningsAsErrors = true
        freeCompilerArgs = ["-Xprogressive"]
    }
}
g

gildor

10/31/2018, 1:51 PM
Put to root project and wrap to
allprojects
block
c

Czar

10/31/2018, 2:17 PM
In kotlin-dsl, I use more concise and idiomatic syntax, like this:
tasks.withType<KotlinCompile> {
	kotlinOptions {
		allWarningsAsErrors = true
		freeCompilerArgs = listOf("-Xjsr305=strict", "-Xprogressive")
	}
}
configure(allprojects)
is still needed of course, I'm only commenting on the
withType
part
👍 1