Deterministic ordering of dependencies on the classpath

You could remove the classes from the offending jar as part of your build.

configurations {
   jarCleanup { transitive = false } 
}
dependencies {
   jarCleanup 'foo:dirty-dependency:1.0'
   compile files({ tasks['cleanupJar'] }) 
} 
task cleanupJar(type: Jar) {
   archiveBaseName = 'clean-dependency' 
   from zipTree(configurations.jarCleanup.singleFile)
   exclude 'offending/package/**' 
}