Entries in the dependency resolution cache are stored against the unique id of a repository. So we cache the fact that we couldn't find module-X in repository XYZ. This means the next time we use repository XYZ, we don't need to check since we know that module-X is missing.
The bug is that repository ids are not being correctly calculated for maven/mavenRepo and ivy repositories. Only the name is being taken into account; if not specified a common default name will be used. This means that different builds with different repository declarations may share the same cache entries. A example symptom of this is when a module will appear to be missing from a declared repository, even though it is actually present in that repository. This would be due to the cache recording the module as missing from a repository with the same name, in a previous build.
The only workaround for this bug is to run the build with '--refresh dependencies' whenever you switch between build scripts, and to ensure that you always declare the same repositories in the same order within a single build (including the buildscript block).