trying to change source sets for kotlin, is this t...
# gradle
e
trying to change source sets for kotlin, is this the best way to do it? UPD
Copy code
val SourceSet.kotlin: SourceDirectorySet
    get() = withConvention(KotlinSourceSet::class){ kotlin }

sourceSets {
    getByName("main") {
        kotlin.srcDirs("src")
        resources.srcDirs("resources")
    }

    getByName("test") {
        kotlin.srcDirs("test")
        resources.srcDirs("testresources")
    }
}
e
It’ll work. But there’s a built-in way that doesn’t require a kotlin extension, see https://docs.gradle.org/release-nightly/userguide/kotlin_dsl.html#about_conventions That example configures the Groovy convention of a source set, simply replace that with
KotlinSourceSet
.
e
Looks better now, thanks
Copy code
sourceSets {
    getByName("main") {
        withConvention(KotlinSourceSet::class){
            kotlin.srcDirs("src")
        }
        resources.srcDirs("resources")
    }

    getByName("test") {
        withConvention(KotlinSourceSet::class){
            kotlin.srcDirs("test")
        }
        resources.srcDirs("testresources")
    }
}
👍 1