How to override Java-Classes with same package in two different source trees

For an android project I have to use existing java classes. These classes are managed in two different source trees.
So I have two different source trees. But couple of
classes in the second source tree shall override those in the first source tree. Unfortunately these classes have the same package. So I cannot use flavours in my gradle script.

For example the structure of the two source trees looks like:
project
source-tree-1/src/com/companyname/MyClass.java
source-tree-2/src/com/companyname/MyClass.java

In my gradle.build script I have added them both:

sourceSets {
    seccomdev {
        java {
            srcDirs '../../SecCommerce-Dev/'
    exclude '....'
    exclude '....'
    exclude '....'
        }
    }

    main {
        java {
            srcDirs '../../SecCommerce-Android/src/'
            srcDirs '../../SecCommerce-Android/gen/'
        }
    }
}

Putting them into one closure and compiling them I got (of course) the error
Error:(20, 8) error: duplicate class: com.companyname.MyClass

Putting them into two different closures as I did in my example Gradle wont compile the classes from the source set ‘seccomdev’

Using compileClasspath like

main {
    java {
       compileClasspath += seccomdev.output
       runtimeClasspath += seccomdev.output
    }
}

In this case I get the error: Error:(122, 0) Could not get unknown property ‘compileClasspath’ for …

Using dependencies like

dependencies {
    compile android.sourceSets.seccomdev
}

I get the error
Error:(134, 0) Cannot convert the provided notation to an object of type Dependency: source set seccomdev.

Unfortunately I cannot alter any file of the source trees of the structure itself. But I have to use the source.
So how can I use both source trees, compile them in one run but to specify that some of the classes shall not be used from the first source tree but from the second.