gradlekotlingradle-kotlin-dsl

How to add new sourceset with gradle kotlin-dsl


I want to add a sourceset src/gen/java. With groovy this is rather easy and already described in https://discuss.gradle.org/t/how-to-use-gradle-with-generated-sources/9401/5

sourceSets {
   gen {
        java.srcDir "src/gen/java"
    }
}

But I stuck with the kotlin-dsl to add a new one. All I've got is:

java {
    sourceSets {

    }
}

Can anyone help here to


Solution

  • You should try the following:

    java.sourceSets.create("src/gen/java")
    

    Hope it's what you need!