GRADLE-767 - Fix problem where buildSrc build was attempting to recreate cache files while they were already in use by the main build. - Extracted CacheFactory out of DefaultCacheRepository, use a single instance shared by all builds. Manages cache instances used by each build. - Close caches used by a given build at the end of the build, to prevent file handle leaks. - Reworked some of the ServiceRegistry wiring. - Reworked the CacheRepository API.