this.startParameter = startParameter;
}
public CompilerDaemonClient startDaemon(File workingDir, DaemonForkOptions forkOptions) {
LOG.debug("Starting Gradle compiler daemon with fork options {}.", forkOptions);
Clock clock = new Clock();
WorkerProcessBuilder builder = workerFactory.create();
builder.setLogLevel(startParameter.getLogLevel()); // NOTE: might make sense to respect per-compile-task log level
builder.applicationClasspath(forkOptions.getClasspath());
builder.sharedPackages(forkOptions.getSharedPackages());
JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
javaCommand.setMinHeapSize(forkOptions.getMinHeapSize());
javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize());
javaCommand.setJvmArgs(forkOptions.getJvmArgs());
javaCommand.setWorkingDir(workingDir);
WorkerProcess process = builder.worker(new CompilerDaemonServer()).setBaseName("Gradle Compiler Daemon").build();
process.start();
CompilerDaemonServerProtocol server = process.getConnection().addOutgoing(CompilerDaemonServerProtocol.class);
CompilerDaemonClient client = new CompilerDaemonClient(forkOptions, process, server);
process.getConnection().addIncoming(CompilerDaemonClientProtocol.class, client);
process.getConnection().connect();
LOG.info("Started Gradle compiler daemon ({}) with fork options {}.", clock.getTime(), forkOptions);
return client;
}