use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class AbstractLocator method find.
public File find() {
synchronized (this) {
if (cachedLocation == null) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ExecAction execAction = execActionFactory.newExecAction();
execAction.executable("xcrun");
execAction.workingDir(System.getProperty("user.dir"));
execAction.args(getXcrunFlags());
execAction.setStandardOutput(outputStream);
execAction.execute().assertNormalExitValue();
cachedLocation = new File(outputStream.toString().replace("\n", ""));
}
return cachedLocation;
}
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class AbstractMetadataProvider method runCompiler.
private Pair<String, String> runCompiler(File gccBinary, List<String> args) {
ExecAction exec = execActionFactory.newExecAction();
exec.executable(gccBinary.getAbsolutePath());
exec.setWorkingDir(gccBinary.getParentFile());
exec.args(args);
StreamByteBuffer buffer = new StreamByteBuffer();
StreamByteBuffer errorBuffer = new StreamByteBuffer();
exec.setStandardOutput(buffer.getOutputStream());
exec.setErrorOutput(errorBuffer.getOutputStream());
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return Pair.of(buffer.readAsString(), errorBuffer.readAsString());
} else {
return null;
}
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class DefaultCommandLineToolInvocationWorker method execute.
@Override
public void execute(CommandLineToolInvocation invocation) {
ExecAction toolExec = execActionFactory.newExecAction();
toolExec.executable(executable);
if (invocation.getWorkDirectory() != null) {
GFileUtils.mkdirs(invocation.getWorkDirectory());
toolExec.workingDir(invocation.getWorkDirectory());
}
toolExec.args(invocation.getArgs());
if (!invocation.getPath().isEmpty()) {
String pathVar = OperatingSystem.current().getPathVar();
String toolPath = Joiner.on(File.pathSeparator).join(invocation.getPath());
toolPath = toolPath + File.pathSeparator + System.getenv(pathVar);
toolExec.environment(pathVar, toolPath);
if (OperatingSystem.current().isWindows() && toolExec.getEnvironment().containsKey(pathVar.toUpperCase())) {
toolExec.getEnvironment().remove(pathVar.toUpperCase());
}
}
toolExec.environment(invocation.getEnvironment());
StreamByteBuffer errOutput = new StreamByteBuffer();
StreamByteBuffer stdOutput = new StreamByteBuffer();
toolExec.setErrorOutput(errOutput.getOutputStream());
toolExec.setStandardOutput(stdOutput.getOutputStream());
try {
toolExec.execute();
invocation.getLogger().operationSuccess(invocation.getDescription(), combineOutput(stdOutput, errOutput));
} catch (ExecException e) {
invocation.getLogger().operationFailed(invocation.getDescription(), combineOutput(stdOutput, errOutput));
throw new CommandLineToolInvocationFailure(invocation, String.format("%s failed while %s.", name, invocation.getDescription()));
}
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class JavadocExecHandleBuilder method getExecHandle.
public ExecAction getExecHandle() {
try {
options.write(optionsFile);
} catch (IOException e) {
throw new GradleException("Failed to store javadoc options.", e);
}
ExecAction execAction = execActionFactory.newExecAction();
execAction.workingDir(execDirectory);
execAction.executable(GUtil.elvis(executable, Jvm.current().getJavadocExecutable()));
execAction.args("@" + optionsFile.getAbsolutePath());
options.contributeCommandLineOptions(execAction);
return execAction;
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class GradleVsMavenBuildExperimentRunner method runMavenExperiment.
private void runMavenExperiment(MeasuredOperationList results, final MavenBuildExperimentSpec experiment, final MavenInvocationSpec buildSpec) {
File projectDir = buildSpec.getWorkingDirectory();
performMeasurements(new InvocationExecutorProvider() {
public Action<MeasuredOperation> runner(final BuildExperimentInvocationInfo invocationInfo, final InvocationCustomizer invocationCustomizer) {
return new Action<MeasuredOperation>() {
@Override
public void execute(MeasuredOperation measuredOperation) {
System.out.println("Run Maven using JVM opts: " + Iterables.concat(buildSpec.getMavenOpts(), buildSpec.getJvmOpts()));
List<String> cleanTasks = buildSpec.getCleanTasks();
if (!cleanTasks.isEmpty()) {
System.out.println("Cleaning up by running Maven tasks: " + Joiner.on(" ").join(buildSpec.getCleanTasks()));
ExecAction clean = createMavenInvocation(buildSpec, cleanTasks);
executeWithFileLogging(experiment, clean);
}
MavenInvocationSpec invocation = invocationCustomizer.customize(invocationInfo, buildSpec);
final ExecAction run = createMavenInvocation(invocation, invocation.getTasksToRun());
System.out.println("Measuring Maven tasks: " + Joiner.on(" ").join(buildSpec.getTasksToRun()));
DurationMeasurementImpl.measure(measuredOperation, new Runnable() {
@Override
public void run() {
executeWithFileLogging(experiment, run);
}
});
}
};
}
}, experiment, results, projectDir);
}
Aggregations