Merge two SourceSets

Hi! I got two sourceSets in my project:

sourceSets {
    main {
        java { setSrcDirs(listOf("src/main/java")) }
        kotlin { setSrcDirs(listOf("src/main/kotlin")) }
        resources { setSrcDirs(listOf("src/main/resources")) }
    create("dev") {
        java { srcDir("src/dev/java") }
        kotlin { srcDir("src/dev/kotlin") }
        resources { srcDir("src/dev/resources") }
        compileClasspath = sourceSets.main.get().output
        runtimeClasspath = sourceSets.main.get().output

I want to use this as a way to overwrite the main sourceSet, for example:
if exists in “dev”, overwrite main’s version of it, or if icon.png exists in dev and so on.

I cant figure out how to integrate this in a jar build, could someone guide me in the right direction?