Search in sources :

Example 1 with SessionLifecycleListener

use of org.gradle.initialization.SessionLifecycleListener in project gradle by gradle.

the class ServicesSetupBuildActionExecuter method execute.

@Override
public Object execute(BuildAction action, BuildRequestContext requestContext, BuildActionParameters actionParameters, ServiceRegistry contextServices) {
    StartParameter startParameter = action.getStartParameter();
    final ServiceRegistry userHomeServices = userHomeServiceRegistry.getServicesFor(startParameter.getGradleUserHomeDir());
    CrossBuildSessionScopeServices crossBuildSessionScopeServices = new CrossBuildSessionScopeServices(contextServices, startParameter);
    try {
        ServiceRegistry buildSessionScopeServices = new BuildSessionScopeServices(userHomeServices, crossBuildSessionScopeServices, startParameter, requestContext, actionParameters.getInjectedPluginClasspath());
        try {
            SessionLifecycleListener sessionLifecycleListener = buildSessionScopeServices.get(ListenerManager.class).getBroadcaster(SessionLifecycleListener.class);
            try {
                sessionLifecycleListener.afterStart();
                return delegate.execute(action, requestContext, actionParameters, buildSessionScopeServices);
            } finally {
                sessionLifecycleListener.beforeComplete();
            }
        } finally {
            CompositeStoppable.stoppable(buildSessionScopeServices).stop();
        }
    } finally {
        new CompositeStoppable().add(new Stoppable() {

            @Override
            public void stop() {
                userHomeServiceRegistry.release(userHomeServices);
            }
        }, crossBuildSessionScopeServices).stop();
    }
}
Also used : StartParameter(org.gradle.StartParameter) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) SessionLifecycleListener(org.gradle.initialization.SessionLifecycleListener) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) GradleUserHomeScopeServiceRegistry(org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry) BuildSessionScopeServices(org.gradle.internal.service.scopes.BuildSessionScopeServices) CrossBuildSessionScopeServices(org.gradle.internal.service.scopes.CrossBuildSessionScopeServices) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) ListenerManager(org.gradle.internal.event.ListenerManager)

Aggregations

StartParameter (org.gradle.StartParameter)1 SessionLifecycleListener (org.gradle.initialization.SessionLifecycleListener)1 CompositeStoppable (org.gradle.internal.concurrent.CompositeStoppable)1 Stoppable (org.gradle.internal.concurrent.Stoppable)1 ListenerManager (org.gradle.internal.event.ListenerManager)1 ServiceRegistry (org.gradle.internal.service.ServiceRegistry)1 BuildSessionScopeServices (org.gradle.internal.service.scopes.BuildSessionScopeServices)1 CrossBuildSessionScopeServices (org.gradle.internal.service.scopes.CrossBuildSessionScopeServices)1 GradleUserHomeScopeServiceRegistry (org.gradle.internal.service.scopes.GradleUserHomeScopeServiceRegistry)1