use of org.gradle.process.internal.DefaultExecHandleBuilder in project gradle by gradle.
the class CommandLineJavaCompiler method createCompilerHandle.
private ExecHandle createCompilerHandle(String executable, JavaCompileSpec spec) {
ExecHandleBuilder builder = new DefaultExecHandleBuilder();
builder.setWorkingDir(spec.getWorkingDir());
builder.setExecutable(executable);
argumentsGenerator.collectArguments(spec, new ExecSpecBackedArgCollector(builder));
builder.setIgnoreExitValue(true);
return builder.build();
}
use of org.gradle.process.internal.DefaultExecHandleBuilder in project gradle by gradle.
the class ForkingGradleExecuter method createExecHandleBuilder.
private DefaultExecHandleBuilder createExecHandleBuilder() {
TestFile gradleHomeDir = getDistribution().getGradleHomeDir();
if (!gradleHomeDir.isDirectory()) {
fail(gradleHomeDir + " is not a directory.\n" + "If you are running tests from IDE make sure that gradle tasks that prepare the test image were executed. Last time it was 'intTestImage' task.");
}
NativeServicesTestFixture.initialize();
DefaultExecHandleBuilder builder = new DefaultExecHandleBuilder(TestFiles.resolver()) {
@Override
public File getWorkingDir() {
// the working directory is not canonicalised
return ForkingGradleExecuter.this.getWorkingDir();
}
};
// Clear the user's environment
builder.environment("GRADLE_HOME", "");
builder.environment("JAVA_HOME", "");
builder.environment("GRADLE_OPTS", "");
builder.environment("JAVA_OPTS", "");
GradleInvocation invocation = buildInvocation();
builder.environment(invocation.environmentVars);
builder.workingDir(getWorkingDir());
builder.setStandardInput(connectStdIn());
builder.args(invocation.args);
ExecHandlerConfigurer configurer = OperatingSystem.current().isWindows() ? new WindowsConfigurer() : new UnixConfigurer();
configurer.configure(builder);
getLogger().debug(String.format("Execute in %s with: %s %s", builder.getWorkingDir(), builder.getExecutable(), builder.getArgs()));
return builder;
}
use of org.gradle.process.internal.DefaultExecHandleBuilder in project gradle by gradle.
the class ProcessLauncherServer method launchExternalProcess.
/**
* This launches an external process in a thread and waits for it to exit.
*/
private void launchExternalProcess() {
Thread thread = new Thread(new Runnable() {
public void run() {
ExecutionInfo executionInfo = null;
ExecHandle execHandle = null;
ByteArrayOutputStream output = null;
try {
executionInfo = protocol.getExecutionInfo(getPort());
ExecHandleBuilder builder = new DefaultExecHandleBuilder();
builder.workingDir(executionInfo.getWorkingDirectory());
builder.commandLine((Object[]) executionInfo.getCommandLineArguments());
builder.environment(executionInfo.getEnvironmentVariables());
output = new ByteArrayOutputStream();
builder.setStandardOutput(output);
builder.setErrorOutput(output);
execHandle = builder.build();
setExternalProcess(execHandle);
execHandle.start();
} catch (Throwable e) {
LOGGER.error("Starting external process", e);
notifyClientExited(-1, e.getMessage());
setExternalProcess(null);
return;
}
ExecResult result = execHandle.waitForFinish();
LOGGER.debug("External process completed with exit code {}", result.getExitValue());
//clear our external process member variable (we're using our local variable below). This is so we know the process has already stopped.
setExternalProcess(null);
executionInfo.processExecutionComplete();
notifyClientExited(result.getExitValue(), output.toString());
}
});
thread.start();
}
Aggregations