Configure plugin in separate file using Kotlin DSL


to differenciate diferent plugins configurations, I use separate files.

For example:


In the root build.gradle.kts I have this:

plugins {
    id("io.gitlab.arturbosch.detekt") version DependencyVersion.Detekt

buildscript {
    dependencies {

And to configure it I go to the detekt.gradle.kts and put:

apply(plugin = "io.gitlab.arturbosch.detekt")

detekt {
    // configure

But detekt lambda is not found. Also tried with:

apply(plugin = "io.gitlab.arturbosch.detekt")

configure<io.gitlab.arturbosch.detekt.Detekt> {
    // configure

But it doesn’t find .Detekt.

With JaCoCo I haven’t got any problems using the second approach, but it doesn’t work with Detekt or SonarQube.

How can I configure plugins in a separate file?