Help migrating dependencies from Groovy to Kotlin

Hello,

I’m currently stuck trying to migrate the following dependency mapping for a custom configuration:

dependencies {
    implementation("org.codehaus.jettison:jettison:1.1")
    implementation("com.sun.jersey:jersey-json:1.19.4")
    ...
    runtimeOnly("commons-discovery:commons-discovery:0.2")
    testImplementation("junit:junit:4.12")

    // Integration dependencies: Same as compile and test
    integrationImplementation sourceSets.main.output
    integrationImplementation configurations.testImplementation
    integrationImplementation sourceSets.test.output
    integrationImplementation configurations.testRuntime
}

integrationImplementation is of type dependencyNotation,

So I tried to recreate the setting like this:

dependencies.add("integrationImplementation", {
    sourceSets {
        addAll(listOf(sourceSets.main.get(), sourceSets.test.get()))
    }
    configurations {
        addAll(listOf(configurations.testImplementation.get(), configurations.testRuntime.get()))
    }
})

But it doesn’t work.

Has anybody managed to do something like this in Kotlin?

Thanks.

I will answer my own question, the documentation here shows what to do