Search in sources :

Example 1 with Stoppable

use of org.gradle.internal.concurrent.Stoppable in project gradle by gradle.

the class BuildActionsFactory method runBuildAndCloseServices.

private Runnable runBuildAndCloseServices(StartParameter startParameter, DaemonParameters daemonParameters, BuildActionExecuter<BuildActionParameters> executer, ServiceRegistry sharedServices, Object... stopBeforeSharedServices) {
    BuildActionParameters parameters = createBuildActionParamters(startParameter, daemonParameters);
    Stoppable stoppable = new CompositeStoppable().add(stopBeforeSharedServices).add(sharedServices);
    return new RunBuildAction(executer, startParameter, clientMetaData(), getBuildStartTime(), parameters, sharedServices, stoppable);
}
Also used : BuildActionParameters(org.gradle.launcher.exec.BuildActionParameters) DefaultBuildActionParameters(org.gradle.launcher.exec.DefaultBuildActionParameters) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable) Stoppable(org.gradle.internal.concurrent.Stoppable) CompositeStoppable(org.gradle.internal.concurrent.CompositeStoppable)

Example 2 with Stoppable

use of org.gradle.internal.concurrent.Stoppable in project gradle by gradle.

the class DefaultGradleLauncherFactory method newInstance.

@Override
public GradleLauncher newInstance(StartParameter startParameter, BuildRequestContext requestContext, ServiceRegistry parentRegistry) {
    // This should only be used for top-level builds
    if (rootBuild != null) {
        throw new IllegalStateException("Cannot have a current build");
    }
    if (!(parentRegistry instanceof BuildSessionScopeServices)) {
        throw new IllegalArgumentException("Service registry must be of build session scope");
    }
    BuildSessionScopeServices sessionScopeServices = (BuildSessionScopeServices) parentRegistry;
    DefaultGradleLauncher launcher = doNewInstance(startParameter, null, requestContext.getCancellationToken(), requestContext, requestContext.getEventConsumer(), sessionScopeServices, ImmutableList.of(new Stoppable() {

        @Override
        public void stop() {
            rootBuild = null;
        }
    }));
    rootBuild = launcher;
    DeploymentRegistry deploymentRegistry = parentRegistry.get(DeploymentRegistry.class);
    deploymentRegistry.onNewBuild(launcher.getGradle());
    GlobalScopeFileTimeStampInspector timeStampInspector = sessionScopeServices.get(GlobalScopeFileTimeStampInspector.class);
    launcher.addListener(timeStampInspector);
    return launcher;
}
Also used : GlobalScopeFileTimeStampInspector(org.gradle.api.internal.changedetection.state.GlobalScopeFileTimeStampInspector) DeploymentRegistry(org.gradle.deployment.internal.DeploymentRegistry) Stoppable(org.gradle.internal.concurrent.Stoppable) BuildSessionScopeServices(org.gradle.internal.service.scopes.BuildSessionScopeServices)

Example 3 with Stoppable

use of org.gradle.internal.concurrent.Stoppable in project gradle by gradle.

the class SimpleHttpFileServerFactory method start.

public HttpFileServer start(File contentRoot, int port) {
    Container container = new SimpleFileServerContainer(new FileContext(contentRoot));
    try {
        final Server server = new ContainerServer(container);
        Connection connection = new SocketConnection(server);
        InetSocketAddress address = new InetSocketAddress(port);
        InetSocketAddress usedAddress = (InetSocketAddress) connection.connect(address);
        return new SimpleHttpFileServer(contentRoot, usedAddress.getPort(), new Stoppable() {

            public void stop() {
                try {
                    server.stop();
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
        });
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : SimpleFileServerContainer(org.gradle.plugins.javascript.envjs.http.simple.internal.SimpleFileServerContainer) ContainerServer(org.simpleframework.http.core.ContainerServer) Container(org.simpleframework.http.core.Container) SimpleFileServerContainer(org.gradle.plugins.javascript.envjs.http.simple.internal.SimpleFileServerContainer) Server(org.simpleframework.transport.Server) HttpFileServer(org.gradle.plugins.javascript.envjs.http.HttpFileServer) ContainerServer(org.simpleframework.http.core.ContainerServer) SocketConnection(org.simpleframework.transport.connect.SocketConnection) InetSocketAddress(java.net.InetSocketAddress) Connection(org.simpleframework.transport.connect.Connection) SocketConnection(org.simpleframework.transport.connect.SocketConnection) Stoppable(org.gradle.internal.concurrent.Stoppable) UncheckedIOException(org.gradle.api.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException) FileContext(org.simpleframework.http.resource.FileContext)

Aggregations

Stoppable (org.gradle.internal.concurrent.Stoppable)3 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 GlobalScopeFileTimeStampInspector (org.gradle.api.internal.changedetection.state.GlobalScopeFileTimeStampInspector)1 DeploymentRegistry (org.gradle.deployment.internal.DeploymentRegistry)1 CompositeStoppable (org.gradle.internal.concurrent.CompositeStoppable)1 BuildSessionScopeServices (org.gradle.internal.service.scopes.BuildSessionScopeServices)1 BuildActionParameters (org.gradle.launcher.exec.BuildActionParameters)1 DefaultBuildActionParameters (org.gradle.launcher.exec.DefaultBuildActionParameters)1 HttpFileServer (org.gradle.plugins.javascript.envjs.http.HttpFileServer)1 SimpleFileServerContainer (org.gradle.plugins.javascript.envjs.http.simple.internal.SimpleFileServerContainer)1 Container (org.simpleframework.http.core.Container)1 ContainerServer (org.simpleframework.http.core.ContainerServer)1 FileContext (org.simpleframework.http.resource.FileContext)1 Server (org.simpleframework.transport.Server)1 Connection (org.simpleframework.transport.connect.Connection)1 SocketConnection (org.simpleframework.transport.connect.SocketConnection)1