本文整理汇总了Java中org.apache.maven.shared.invoker.InvocationRequest.setOutputHandler方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationRequest.setOutputHandler方法的具体用法?Java InvocationRequest.setOutputHandler怎么用?Java InvocationRequest.setOutputHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.invoker.InvocationRequest
的用法示例。
在下文中一共展示了InvocationRequest.setOutputHandler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeMavenBuild
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private void executeMavenBuild(List<String> goals, InvocationOutputHandler outputHandler) {
log.debug("Invoking maven with goals {}", goals);
InvocationRequest request = new DefaultInvocationRequest();
request.setBatchMode(true);
request.setGoals(goals);
// reset MAVEN_DEBUG_OPTS to allow debugging without blocking the invoker calls
request.addShellEnvironment("MAVEN_DEBUG_OPTS", "");
InvocationOutputHandler outHandler = outputHandler;
if (outHandler == null) {
outHandler = log::debug;
}
request.setOutputHandler(outHandler);
try {
InvocationResult result = maven.execute(request);
if (result.getExitCode() != 0) {
throw new MavenInvocationException("Maven process exited with non-zero code [" + result.getExitCode() + "]. "
+ "Retry with debug log level enabled to see the maven invocation logs");
}
}
catch (MavenInvocationException e) {
throw new CarnotzetDefinitionException("Error invoking mvn " + goals, e);
}
}
示例2: execute
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
public static void execute(File dir, List<String> commands, Properties props, boolean logToStdOut) throws MavenInvocationException {
InvocationRequest request = new DefaultInvocationRequest();
request.setBaseDirectory(dir);
request.setGoals(commands);
if (props!=null) {
request.setProperties(props);
}
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(mavenHome);
if (!logToStdOut) {
request.setOutputHandler(emptyHandler);
}
invoker.execute(request);
}
示例3: mavenCall
import org.apache.maven.shared.invoker.InvocationRequest; //导入方法依赖的package包/类
private InvocationResult mavenCall( ItemWithProperties item )
throws MavenInvocationException
{
InvocationRequest request = createAndConfigureAnInvocationRequest( item );
OutputConsumer output = new OutputConsumer( getLog() );
request.setOutputHandler( output );
invoker.setWorkingDirectory( getWorkingDirectoryAfterPlaceHolderIsReplaced( item ) );
return invoker.execute( request );
}
示例4: 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();
}