Compile dependency resolution does not always prefer source and build path?

In a multi project I get compile errors, because the order of execution of javac does not prefer the Java build path (compiled classes) of that same project but tries to resolve method calls in some classes to some other class by looking up the classes of external jars declared as dependencies.

The odd thing in my project sources (which I cannot change) is, that I have some classes which have exactly the same name and reside exactly the same package as their base classes, which come compiled from dependency jar (some people thought they are really clever when overwriting existing base classes).

Anyway, in the existing ANT scripts, this was no issue. But with Gradle it is. Is there any way to convince Gradle to first lookup the java sources of the project before trying to resolve dependencies by external jars?

My build.gradle looks like this:

dependencies {
   compile project(':com.x.y.z'') // some other project of this multi project
        compile files('../lib/xxx-depend.jar')
 // the library which has the base classes for my project
}

hint:

with ANT i can declare the classpath like this:

<pathelement location="${SW_DIR}/${SERVER_CORE}/build" />

where ${SERVER_CORE}/build is the directory of my compiled classes of the same project.