use of org.gradle.initialization.GradleUserHomeDirProvider in project gradle by gradle.
the class DefaultGradleUserHomeScopeServiceRegistry method getServicesFor.
@Override
public ServiceRegistry getServicesFor(final File gradleUserHomeDir) {
lock.lock();
try {
Services services = servicesForHomeDir.get(gradleUserHomeDir);
if (services == null) {
if (servicesForHomeDir.size() == 1) {
Services otherServices = servicesForHomeDir.values().iterator().next();
if (otherServices.count == 0) {
// Other home dir cached and not in use, clean it up
CompositeStoppable.stoppable(otherServices.registry).stop();
servicesForHomeDir.clear();
}
}
ServiceRegistry userHomeServices = ServiceRegistryBuilder.builder().parent(sharedServices).displayName("services for Gradle user home dir " + gradleUserHomeDir).provider(new Object() {
GradleUserHomeDirProvider createGradleUserHomeDirProvider() {
return new GradleUserHomeDirProvider() {
@Override
public File getGradleUserHomeDirectory() {
return gradleUserHomeDir;
}
};
}
}).provider(provider).build();
services = new Services(userHomeServices);
servicesForHomeDir.put(gradleUserHomeDir, services);
}
services.count++;
return services.registry;
} finally {
lock.unlock();
}
}
Aggregations