Configure plugin in separate file using Kotlin DSL

Hello,

to differenciate diferent plugins configurations, I use separate files.

For example:

./build.gradle.kts
./detekt.gradle.kts
./settings.gradle.kts
./module1
./module2

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

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

buildscript {
    dependencies {
        classpath(io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.1.1)
    }
}

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?

Thanks.