Search in sources :

Example 6 with ServiceRegistry

use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.

the class ShutdownCoordinator method stop.

public void stop() {
    ServiceRegistry clientServices = clientFactory.createStopDaemonServices(outputEventListener, new DaemonParameters(new BuildLayoutParameters()));
    DaemonStopClient client = clientServices.get(DaemonStopClient.class);
    client.gracefulStop(daemons);
}
Also used : ServiceRegistry(org.gradle.internal.service.ServiceRegistry) BuildLayoutParameters(org.gradle.initialization.BuildLayoutParameters) DaemonParameters(org.gradle.launcher.daemon.configuration.DaemonParameters) DaemonStopClient(org.gradle.launcher.daemon.client.DaemonStopClient)

Example 7 with ServiceRegistry

use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.

the class DefaultGradleLauncherFactory method createChildInstance.

private GradleLauncher createChildInstance(StartParameter startParameter, GradleLauncher parent, BuildSessionScopeServices buildSessionScopeServices, List<?> servicesToStop) {
    ServiceRegistry services = parent.getGradle().getServices();
    BuildRequestMetaData requestMetaData = new DefaultBuildRequestMetaData(services.get(BuildClientMetaData.class));
    BuildCancellationToken cancellationToken = services.get(BuildCancellationToken.class);
    BuildEventConsumer buildEventConsumer = services.get(BuildEventConsumer.class);
    return doNewInstance(startParameter, parent, cancellationToken, requestMetaData, buildEventConsumer, buildSessionScopeServices, servicesToStop);
}
Also used : ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry)

Example 8 with ServiceRegistry

use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.

the class TestUtility method createMockProject.

/**
     * Creates a mock project with the specified properties.
     *
     * Note: depth is 0 for a root project. 1 for a root project's subproject, etc.
     */
public static Project createMockProject(JUnit4Mockery context, final String name, final String buildFilePath, final int depth, Project[] subProjectArray, Task[] tasks, String[] defaultTasks) {
    final ProjectInternal project = context.mock(ProjectInternal.class, "[project]_" + name + '_' + uniqueNameCounter++);
    final ServiceRegistry services = ServiceRegistryBuilder.builder().provider(new Object() {

        ProjectTaskLister createTaskLister() {
            return new DefaultProjectTaskLister();
        }
    }).build();
    context.checking(new Expectations() {

        {
            allowing(project).getName();
            will(returnValue(name));
            allowing(project).getDescription();
            will(returnValue(null));
            allowing(project).getBuildFile();
            will(returnValue(new File(buildFilePath)));
            allowing(project).getDepth();
            will(returnValue(depth));
            allowing(project).getServices();
            will(returnValue(services));
        }
    });
    attachSubProjects(context, project, subProjectArray);
    attachTasks(context, project, tasks);
    assignDefaultTasks(context, project, defaultTasks);
    return project;
}
Also used : Expectations(org.jmock.Expectations) DefaultProjectTaskLister(org.gradle.api.internal.project.DefaultProjectTaskLister) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) File(java.io.File)

Example 9 with ServiceRegistry

use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.

the class ProjectBuilderImpl method createProject.

public Project createProject(String name, File inputProjectDir, File gradleUserHomeDir) {
    File projectDir = prepareProjectDir(inputProjectDir);
    final File homeDir = new File(projectDir, "gradleHome");
    StartParameter startParameter = new StartParameter();
    File userHomeDir = gradleUserHomeDir == null ? new File(projectDir, "userHome") : FileUtils.canonicalize(gradleUserHomeDir);
    startParameter.setGradleUserHomeDir(userHomeDir);
    NativeServices.initialize(userHomeDir);
    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(getUserHomeServices(userHomeDir), startParameter, homeDir);
    GradleInternal gradle = CLASS_GENERATOR.newInstance(DefaultGradle.class, null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));
    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(), topLevelRegistry.get(FileResolver.class));
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild("root-project");
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);
    gradle.setRootProject(project);
    gradle.setDefaultProject(project);
    return project;
}
Also used : DefaultProjectDescriptorRegistry(org.gradle.initialization.DefaultProjectDescriptorRegistry) StartParameter(org.gradle.StartParameter) GradleInternal(org.gradle.api.internal.GradleInternal) IProjectFactory(org.gradle.api.internal.project.IProjectFactory) ServiceRegistryFactory(org.gradle.internal.service.scopes.ServiceRegistryFactory) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) LoggingServiceRegistry(org.gradle.internal.logging.services.LoggingServiceRegistry) FileResolver(org.gradle.api.internal.file.FileResolver) File(java.io.File) DefaultProjectDescriptor(org.gradle.initialization.DefaultProjectDescriptor)

Example 10 with ServiceRegistry

use of org.gradle.internal.service.ServiceRegistry in project gradle by gradle.

the class BuildActionsFactory method showDaemonStatus.

private Runnable showDaemonStatus(DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    ServiceRegistry clientSharedServices = createGlobalClientServices();
    ServiceRegistry clientServices = clientSharedServices.get(DaemonClientFactory.class).createStopDaemonServices(loggingServices.get(OutputEventListener.class), daemonParameters);
    ReportDaemonStatusClient statusClient = clientServices.get(ReportDaemonStatusClient.class);
    return new ReportDaemonStatusAction(statusClient);
}
Also used : ReportDaemonStatusClient(org.gradle.launcher.daemon.client.ReportDaemonStatusClient) DaemonClientFactory(org.gradle.launcher.daemon.client.DaemonClientFactory) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener)

Aggregations

ServiceRegistry (org.gradle.internal.service.ServiceRegistry)12 OutputEventListener (org.gradle.internal.logging.events.OutputEventListener)5 LoggingServiceRegistry (org.gradle.internal.logging.services.LoggingServiceRegistry)4 DaemonClientFactory (org.gradle.launcher.daemon.client.DaemonClientFactory)4 File (java.io.File)3 GradleUserHomeScopeServiceRegistry (org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry)3 DaemonClient (org.gradle.launcher.daemon.client.DaemonClient)3 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 DaemonStopClient (org.gradle.launcher.daemon.client.DaemonStopClient)2 InputStream (java.io.InputStream)1 StartParameter (org.gradle.StartParameter)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 FileResolver (org.gradle.api.internal.file.FileResolver)1 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)1 DefaultProjectTaskLister (org.gradle.api.internal.project.DefaultProjectTaskLister)1 IProjectFactory (org.gradle.api.internal.project.IProjectFactory)1 LoggingConfiguration (org.gradle.api.logging.configuration.LoggingConfiguration)1 BuildLayoutParameters (org.gradle.initialization.BuildLayoutParameters)1 DefaultProjectDescriptor (org.gradle.initialization.DefaultProjectDescriptor)1 DefaultProjectDescriptorRegistry (org.gradle.initialization.DefaultProjectDescriptorRegistry)1