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);
}
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;
}
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);
}
}
Aggregations