use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class GradleVsMavenBuildExperimentRunner method createMavenInvocation.
private ExecAction createMavenInvocation(MavenInvocationSpec buildSpec) {
ExecAction execAction = execActionFactory.newExecAction();
execAction.setWorkingDir(buildSpec.getWorkingDirectory());
execAction.executable(buildSpec.getInstallation().getMvn());
execAction.args(buildSpec.getArgs());
execAction.args(buildSpec.getTasksToRun());
execAction.environment("MAVEN_OPTS", Joiner.on(' ').join(Iterables.concat(buildSpec.getMavenOpts(), buildSpec.getJvmOpts())));
return execAction;
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class GccVersionDeterminer method transform.
private String transform(File gccBinary, List<String> args) {
ExecAction exec = execActionFactory.newExecAction();
exec.executable(gccBinary.getAbsolutePath());
exec.setWorkingDir(gccBinary.getParentFile());
exec.args(args);
StreamByteBuffer buffer = new StreamByteBuffer();
exec.setStandardOutput(buffer.getOutputStream());
exec.setErrorOutput(NullOutputStream.INSTANCE);
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return buffer.readAsString();
} else {
return null;
}
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class DefaultFileOperations method exec.
public ExecResult exec(Action<? super ExecSpec> action) {
ExecAction execAction = instantiator.newInstance(DefaultExecAction.class, fileResolver);
action.execute(execAction);
return execAction.execute();
}
use of org.gradle.process.internal.ExecAction in project gradle by gradle.
the class JavadocGenerator method execute.
@Override
public WorkResult execute(JavadocSpec spec) {
JavadocExecHandleBuilder javadocExecHandleBuilder = new JavadocExecHandleBuilder(execActionFactory);
javadocExecHandleBuilder.setExecutable(spec.getExecutable());
javadocExecHandleBuilder.execDirectory(spec.getWorkingDir()).options(spec.getOptions()).optionsFile(spec.getOptionsFile());
ExecAction execAction = javadocExecHandleBuilder.getExecHandle();
if (spec.isIgnoreFailures()) {
execAction.setIgnoreExitValue(true);
}
try {
execAction.execute();
} catch (ExecException e) {
LOG.info("Problems generating Javadoc." + "\n Command line issued: " + execAction.getCommandLine() + "\n Generated Javadoc options file has following contents:\n------\n{}------", GFileUtils.readFileQuietly(spec.getOptionsFile()));
throw new GradleException(String.format("Javadoc generation failed. Generated Javadoc options file (useful for troubleshooting): '%s'", spec.getOptionsFile()), e);
}
return new SimpleWorkResult(true);
}
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()));
}
}
Aggregations