当前位置: 首页>>代码示例>>Java>>正文


Java InvocationRequest.setOutputHandler方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:24,代码来源:MavenDependencyResolver.java

示例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);
}
 
开发者ID:ahn,项目名称:mideaas,代码行数:17,代码来源:MavenUtil.java

示例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 );
}
 
开发者ID:khmarbaise,项目名称:iterator-maven-plugin,代码行数:13,代码来源:InvokerMojo.java

示例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();
}
 
开发者ID:fabric8io,项目名称:ipaas-quickstarts,代码行数:32,代码来源:ArchetypeTest.java


注:本文中的org.apache.maven.shared.invoker.InvocationRequest.setOutputHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。