本文整理汇总了Java中org.apache.maven.shared.invoker.InvocationRequest.setErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationRequest.setErrorHandler方法的具体用法?Java InvocationRequest.setErrorHandler怎么用?Java InvocationRequest.setErrorHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.invoker.InvocationRequest
的用法示例。
在下文中一共展示了InvocationRequest.setErrorHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeMaven
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
protected static int invokeMaven(String[] args, String outDir, File logFile) {
List<String> goals = Arrays.asList(args);
String commandLine = Strings.join(goals, " ");
InvocationResult result = null;
try {
File dir = new File(outDir);
InvocationRequest request = new DefaultInvocationRequest();
request.setGoals(goals);
InvocationOutputHandler outputHandler = new SystemOutAndFileHandler(logFile);
outputHandler.consumeLine("");
outputHandler.consumeLine("");
outputHandler.consumeLine(dir.getName() + " : starting: mvn " + commandLine);
outputHandler.consumeLine("");
request.setOutputHandler(outputHandler);
request.setErrorHandler(outputHandler);
DefaultInvoker invoker = new DefaultInvoker();
request.setPomFile(new File(dir, "pom.xml"));
result = invoker.execute(request);
CommandLineException executionException = result.getExecutionException();
if (executionException != null) {
LOG.error("Failed to invoke maven with: mvn " + commandLine + ". " + executionException, executionException);
}
} catch (Exception e) {
LOG.error("Failed to invoke maven with: mvn " + commandLine + ". " + e, e);
}
return result == null ? 1 : result.getExitCode();
}