本文整理汇总了Java中org.gradle.process.ExecResult.getExitValue方法的典型用法代码示例。如果您正苦于以下问题:Java ExecResult.getExitValue方法的具体用法?Java ExecResult.getExitValue怎么用?Java ExecResult.getExitValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.process.ExecResult
的用法示例。
在下文中一共展示了ExecResult.getExitValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForStop
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
protected ExecutionResult waitForStop(boolean expectFailure) {
ExecHandle execHandle = getExecHandle();
ExecResult execResult = execHandle.waitForFinish();
if (durationMeasurement != null) {
durationMeasurement.stop();
}
execResult.rethrowFailure(); // nop if all ok
String output = getStandardOutput();
String error = getErrorOutput();
boolean didFail = execResult.getExitValue() != 0;
if (didFail != expectFailure) {
String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n",
expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error);
throw new UnexpectedBuildFailure(message);
}
ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error);
resultAssertion.execute(executionResult);
return executionResult;
}
示例2: transform
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
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;
}
}
示例3: getGitTags
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
static Integer getGitTags(final Project project) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ExecResult res = project.exec(new Action<ExecSpec>() {
@Override
public void execute(final ExecSpec execSpec) {
execSpec.commandLine("git", "tag");
execSpec.setStandardOutput(baos);
}
});
System.out.println(String.format("getGitTags:exit '%d'", res.getExitValue()));
if (res.getExitValue() == 0) {
final String str = baos.toString().trim();
final int numTags = (str == null || str.length() == 0) ? 1 : str.split("\n").length;
System.out.println(String.format("getGitTags 'num=%d'", numTags));
return numTags;
} else {
return 1;
}
}
示例4: waitForStop
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
protected ExecutionResult waitForStop(boolean expectFailure) {
ExecHandle execHandle = getExecHandle();
ExecResult execResult = execHandle.waitForFinish();
execResult.rethrowFailure(); // nop if all ok
String output = getStandardOutput();
String error = getErrorOutput();
boolean didFail = execResult.getExitValue() != 0;
if (didFail != expectFailure) {
String message = String.format("Gradle execution %s in %s with: %s %s%nOutput:%n%s%n-----%nError:%n%s%n-----%n",
expectFailure ? "did not fail" : "failed", execHandle.getDirectory(), execHandle.getCommand(), execHandle.getArguments(), output, error);
throw new UnexpectedBuildFailure(message);
}
ExecutionResult executionResult = expectFailure ? toExecutionFailure(output, error) : toExecutionResult(output, error);
resultAssertion.execute(executionResult);
return executionResult;
}
示例5: transform
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
private String transform(File gccBinary, List<String> args) {
ExecAction exec = execActionFactory.newExecAction();
exec.executable(gccBinary.getAbsolutePath());
exec.setWorkingDir(gccBinary.getParentFile());
exec.args(args);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exec.setStandardOutput(baos);
exec.setErrorOutput(new ByteArrayOutputStream());
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return new String(baos.toByteArray());
} else {
return null;
}
}
示例6: transform
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
public String transform(File gccBinary) {
ExecAction exec = execActionFactory.newExecAction();
exec.executable(gccBinary.getAbsolutePath());
exec.setWorkingDir(gccBinary.getParentFile());
exec.args("-dM", "-E", "-");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exec.setStandardOutput(baos);
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return new String(baos.toByteArray());
} else {
return null;
}
}
示例7: getMetadataInternal
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
private EnumMap<SysProp, String> getMetadataInternal(File jdkPath) {
JavaExecAction exec = factory.newJavaExecAction();
exec.executable(javaExe(jdkPath, "java"));
File workingDir = Files.createTempDir();
exec.setWorkingDir(workingDir);
exec.setClasspath(new SimpleFileCollection(workingDir));
try {
writeProbe(workingDir);
exec.setMain(JavaProbe.CLASSNAME);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
exec.setStandardOutput(baos);
ByteArrayOutputStream errorOutput = new ByteArrayOutputStream();
exec.setErrorOutput(errorOutput);
exec.setIgnoreExitValue(true);
ExecResult result = exec.execute();
int exitValue = result.getExitValue();
if (exitValue == 0) {
return parseExecOutput(baos.toString());
}
return error("Command returned unexpected result code: " + exitValue + "\nError output:\n" + errorOutput);
} catch (ExecException ex) {
return error(ex.getMessage());
} finally {
try {
FileUtils.deleteDirectory(workingDir);
} catch (IOException e) {
throw new GradleException("Unable to delete temp directory", e);
}
}
}
示例8: executeCompiler
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
private void executeCompiler(ExecHandle handle) {
handle.start();
ExecResult result = handle.waitForFinish();
if (result.getExitValue() != 0) {
throw new CompilationFailedException(result.getExitValue());
}
}
示例9: stopExecution
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
public static Action<ExecResult> stopExecution() {
return new Action<ExecResult>() {
public void execute(ExecResult exec) {
if (exec.getExitValue() != 0) {
LOG.info("External process returned exit code: {}. Stopping the execution of the task.");
//Cleanly stop executing the task, without making the task failed.
throw new StopExecutionException();
}
}
};
}
示例10: mapJarFile
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
public void mapJarFile(File input, File output, ModGradleExtension extension) {
ExecResult result = getProject().javaexec(new Closure<JavaExecSpec>(this) {
public JavaExecSpec call() {
JavaExecSpec exec = (JavaExecSpec) getDelegate();
exec.args(
Constants.SPECIALSOURCE_JAR.getAbsolutePath(),
"map",
"-i",
input.getAbsolutePath(),
"-m",
Constants.MAPPING_SRG.get(extension).getAbsolutePath(),
"-o",
output.getAbsolutePath()
);
exec.setMain("-jar");
exec.setWorkingDir(Constants.CACHE_FILES);
exec.classpath(Constants.getClassPath());
//exec.setStandardOutput(System.out); // TODO: store the logs?
exec.setMaxHeapSize("512M");
return exec;
}
public JavaExecSpec call(Object obj) {
return call();
}
});
int exitValue = result.getExitValue();
if (exitValue != 0) {
this.getLogger().error(":SpecialSource exit value: " + exitValue);
throw new RuntimeException("SpecialSource failed to decompile");
}
}
示例11: getGitTagDescriptions
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
static String getGitTagDescriptions(final Project project) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ExecResult res = project.exec(new Action<ExecSpec>() {
@Override
public void execute(final ExecSpec execSpec) {
execSpec.setWorkingDir(project.getProjectDir());
execSpec.commandLine("git", "describe", "--tags", "--long");
execSpec.setStandardOutput(baos);
}
});
System.out.println(String.format("getGitTagDescriptions:exit '%d'", res.getExitValue()));
if (res.getExitValue() == 0) {
final String str = baos.toString().trim();
if (str == null || str.length() == 0) {
return "1.0.0";
} else {
final String[] arr = str.split("-");
// [0] - fullVersionTag
// [1] - versionBuild
// [2] - gitSHA
System.out.println(String.format("getGitTagDescriptions '%s' {fullVersion=%s}", str, arr[0]));
return arr[0];
}
} else {
return "1.0.0";
}
}
示例12: invokeCompiler
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
@Override
public void invokeCompiler(ProgramArguments arguments) throws Exception {
ExecResult execResult = project.javaexec(executor(arguments));
if (execResult.getExitValue() != 0) {
throw new IllegalStateException("JJTree failed with error code: [" + execResult.getExitValue() + "]");
}
}
示例13: ensureSucceeded
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
static void ensureSucceeded(ExecResult result, String prefix) {
if (result.getExitValue() != 0) {
throw new GradleException("External process failed with exit code " + result.getExitValue() + "\n" +
"Please inspect the command output prefixed with '" + prefix.trim() + "' the build log.");
}
}
示例14: decompile
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
@TaskAction
public void decompile() {
try {
ModGradleExtension extension = this.getProject().getExtensions().getByType(ModGradleExtension.class);
if (!Constants.MINECRAFT_FERN_OUTPUT_JAR.get(extension).exists()) {
this.getLogger().lifecycle(":decompiling Minecraft");
// TODO: Separate task
ExecResult result = getProject().javaexec(new Closure<JavaExecSpec>(this) {
public JavaExecSpec call() {
JavaExecSpec exec = (JavaExecSpec) getDelegate();
Constants.MINECRAFT_FERN_OUTPUT.mkdir();
exec.args(
Constants.FERNFLOWER_JAR.getAbsolutePath(),
"-dgs=1",
"-hdc=0",
"-asc=1",
"-udv=0",
"-din=1",
"-rbr=0",
"-rsy=1",
"-ind= ",
//"-udv=1",
"-log=ERROR",
Constants.MINECRAFT_MERGED.get(extension).getAbsolutePath(),
Constants.MINECRAFT_FERN_OUTPUT.getAbsolutePath()
);
exec.setMain("-jar");
exec.setWorkingDir(Constants.CACHE_FILES);
exec.classpath(Constants.getClassPath());
//exec.setStandardOutput(System.out); // TODO: store the logs?
exec.setMaxHeapSize("512M");
return exec;
}
public JavaExecSpec call(Object obj) {
return call();
}
});
int exitValue = result.getExitValue();
if (exitValue != 0) {
this.getLogger().error(":FernFlower exit value: " + exitValue);
throw new RuntimeException("FernFlower failed to decompile");
}
}
if (Constants.MINECRAFT_SRC_PATCHED.exists()) {
FileUtils.deleteDirectory(Constants.MINECRAFT_SRC_PATCHED);
}
if (Constants.MINECRAFT_SRC_DECOMP.exists()) {
FileUtils.deleteDirectory(Constants.MINECRAFT_SRC_DECOMP);
}
ZipUtil.unpack(Constants.MINECRAFT_FERN_OUTPUT_JAR.get(extension), Constants.MINECRAFT_SRC_DECOMP);
FileUtils.copyDirectory(Constants.MINECRAFT_SRC_DECOMP, Constants.MINECRAFT_SRC_PATCHED);
} catch (IOException e) {
e.printStackTrace();
}
}
示例15: runWsimport
import org.gradle.process.ExecResult; //导入方法依赖的package包/类
/**
* Run wsimport on a WSDL file
*
* @param baseDir Base directory
* @param wsdlFile WSDL file to compile
*/
protected void runWsimport(Path baseDir, Path wsdlFile) {
JavaExecAction action = getActionFactory().newJavaExecAction();
String packageName = Optional.ofNullable(wsdlFile.getParent()).map(p -> PACKAGE_JOINER.join(p)).orElse(null);
Multimap<String, Object> options = Multimaps.newListMultimap(new HashMap<>(), () -> new ArrayList<>());
if (packageName != null) {
options.put("p", packageName);
}
options.put("wsdllocation", wsdlFile.getFileName().toString());
options.put("s", getDestinationDir());
options.put("extension", true);
options.put("Xnocompile", true);
options.put("B-classpath", getProject().getConfigurations().getAt("xjc").getAsPath());
for (String extension : getXjcExtensions()) {
options.put("B-X" + extension, true);
}
if (getProject().getLogger().isDebugEnabled()) {
options.put("Xdebug", true);
}
else {
options.put("quiet", true);
}
for (File bindingFile : Objects.requireNonNull(getBindings()).getFiles()) {
if (bindingFile.isFile()) {
options.put("b", bindingFile);
}
}
List<String> arguments = createArguments(options);
arguments.add(wsdlFile.toString());
getLogger().debug("Running wsimport with arguments {}", Joiner.on(' ').join(arguments));
action.setArgs(arguments);
action.setClasspath(getProject().getConfigurations().getAt("jaxws"));
action.setMain("com.sun.tools.ws.WsImport");
action.setWorkingDir(baseDir.toFile());
ExecResult result = action.execute();
if (result.getExitValue() != 0) {
throw new GradleException("Error running wsimport");
}
}