GRADLE-3107 Fix for resource missing problem in master.

This fix makes it so that if a dependency can be found in the cache of any
repository, the cached dependency will always be used. If a dependency cannot
be found in the cache of _any_ repository, the actual repositories will be
queried, possibly over the network.

This will fix an issue where after 24h Gradle would do remote checks even
if an artifact exists (cached) in a repository further down the chain. In order to
test this, we've made the cacheMissingArtifactsFor timeout (which defaults
to 24h) configurable.

Credit for this fix goes to Graham Dennis.