Gradle will prefer an artifact with an pom/ivy descriptor over an artifact without. I think this is why gradle continues searching after it finds a match in the flatDir
repository. This may or may not solve your problem, but you could use a FileCollectionDependency instead of a ModuleDependency.
Eg:
ext {
libs = "${rootProject.projectDir}/libs"
testLibs = "${rootProject.projectDir}/test.libs"
}
dependencies {
compile files("${libs}/activation.jar", "${libs}/imap.jar")
compile files("${testLibs}/gson-2.2.4.jar")
...
}