use of org.gradle.internal.service.ServiceRegistry 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();
}
}
use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.
the class ProjectBuilderImpl method getUserHomeServices.
private ServiceRegistry getUserHomeServices(File userHomeDir) {
ServiceRegistry globalServices = getGlobalServices();
GradleUserHomeScopeServiceRegistry userHomeScopeServiceRegistry = globalServices.get(GradleUserHomeScopeServiceRegistry.class);
return userHomeScopeServiceRegistry.getServicesFor(userHomeDir);
}
use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.
the class BuildActionsFactory method runBuildInSingleUseDaemon.
private Runnable runBuildInSingleUseDaemon(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
//(SF) this is a workaround until this story is completed. I'm hardcoding setting the idle timeout to be max X mins.
//this way we avoid potential runaway daemons that steal resources on linux and break builds on windows.
//We might leave that in if we decide it's a good idea for an extra safety net.
int maxTimeout = 2 * 60 * 1000;
if (daemonParameters.getIdleTimeout() > maxTimeout) {
daemonParameters.setIdleTimeout(maxTimeout);
}
//end of workaround.
// Create a client that will not match any existing daemons, so it will always startup a new one
ServiceRegistry clientSharedServices = createGlobalClientServices();
ServiceRegistry clientServices = clientSharedServices.get(DaemonClientFactory.class).createSingleUseDaemonClientServices(loggingServices.get(OutputEventListener.class), daemonParameters, System.in);
DaemonClient client = clientServices.get(DaemonClient.class);
return runBuildAndCloseServices(startParameter, daemonParameters, client, clientSharedServices, clientServices);
}
use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.
the class ProviderConnection method createExecuter.
private BuildActionExecuter<ProviderOperationParameters> createExecuter(ProviderOperationParameters operationParameters, Parameters params) {
LoggingManagerInternal loggingManager;
BuildActionExecuter<BuildActionParameters> executer;
if (Boolean.TRUE.equals(operationParameters.isEmbedded())) {
loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
loggingManager.captureSystemSources();
executer = embeddedExecutor;
} else {
LoggingServiceRegistry loggingServices = LoggingServiceRegistry.newNestedLogging();
loggingManager = loggingServices.getFactory(LoggingManagerInternal.class).create();
InputStream standardInput = operationParameters.getStandardInput();
ServiceRegistry clientServices = daemonClientFactory.createBuildClientServices(loggingServices.get(OutputEventListener.class), params.daemonParams, standardInput == null ? SafeStreams.emptyInput() : standardInput);
executer = clientServices.get(DaemonClient.class);
}
return new LoggingBridgingBuildActionExecuter(new DaemonBuildActionExecuter(executer, params.daemonParams), loggingManager);
}
use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.
the class CommandLineActionFactory method convert.
/**
* <p>Converts the given command-line arguments to an {@link Action} which performs the action requested by the
* command-line args.
*
* @param args The command-line arguments.
* @return The action to execute.
*/
public Action<ExecutionListener> convert(List<String> args) {
ServiceRegistry loggingServices = createLoggingServices();
LoggingConfiguration loggingConfiguration = new DefaultLoggingConfiguration();
return new WithLogging(loggingServices, args, loggingConfiguration, new ExceptionReportingAction(new JavaRuntimeValidationAction(new ParseAndBuildAction(loggingServices, args)), new BuildExceptionReporter(loggingServices.get(StyledTextOutputFactory.class), loggingConfiguration, clientMetaData())));
}
Aggregations