本文整理汇总了Java中org.apache.maven.shared.invoker.InvocationResult.getExecutionException方法的典型用法代码示例。如果您正苦于以下问题:Java InvocationResult.getExecutionException方法的具体用法?Java InvocationResult.getExecutionException怎么用?Java InvocationResult.getExecutionException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.shared.invoker.InvocationResult
的用法示例。
在下文中一共展示了InvocationResult.getExecutionException方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
/**
* Run the build, push, and generate dockerrun.aws.json file goals sequentially.
* @throws MojoExecutionException if execution fails.
*/
public void execute() throws MojoExecutionException {
final Properties properties = initializePropertiesForGoals();
final List<String> goals = Arrays.asList(
"magic-beanstalk:build",
"magic-beanstalk:push",
"magic-beanstalk:genCustomDockerrun",
"magic-beanstalk:zip");
final InvocationRequest invocationRequest = createInvocationRequestWithGoals(goals, properties);
final Invoker invoker = new DefaultInvoker();
setupInvokerLogger(invoker);
try {
final InvocationResult invocationResult = invoker.execute(invocationRequest);
if (invocationResult.getExitCode() != 0) {
String msg = "Invocation Exception";
if (invocationResult.getExecutionException() != null) {
msg = invocationResult.getExecutionException().getMessage();
}
throw new CommandLineException(msg);
}
} catch (MavenInvocationException | CommandLineException e) {
throw new MojoExecutionException("Failed to execute goals", e);
}
}
示例2: execute
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Starting release build.");
try {
InvocationRequest request = setupInvocationRequest();
Invoker invoker = setupInvoker();
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
CommandLineException executionException = result.getExecutionException();
if (executionException != null) {
throw new MojoFailureException("Error during project build: " + executionException.getMessage(),
executionException);
} else {
throw new MojoFailureException("Error during project build: " + result.getExitCode());
}
}
} catch (MavenInvocationException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
示例3: invokeMaven
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
private void invokeMaven(File pomFile, String goal) throws CommandLineException, MavenInvocationException
{
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile(pomFile);
request.setGoals(Collections.singletonList(goal));
request.setJavaHome(javaHome);
request.setShowErrors(true);
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(mavenHome);
InvocationResult result = invoker.execute(request);
// check status
CommandLineException executionException = result.getExecutionException();
if (executionException != null)
{
throw executionException;
}
assertEquals(0, result.getExitCode());
}
示例4: execute
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
public void execute(Project project, CommandLine arguments) {
DefaultInvocationRequest request = new DefaultInvocationRequest();
request.setJavaHome(os.getJavaHome());
request.setShellEnvironmentInherited(true);
request.setBaseDirectory(workspace.getProjectDirectory(project));
logger.log(project, "Executing mvn %s", arguments.toString());
request.setGoals(arguments.toCommandLine(it -> properties.getFullyQualifiedPlugin(it.getGoal())));
try {
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
throw new RuntimeException(result.getExecutionException());
}
} catch (MavenInvocationException o_O) {
throw new RuntimeException(o_O);
}
}
示例5: executeLicenseProject
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
private void executeLicenseProject(File pomFile, File repoDir) throws Exception {
InvocationRequest mavenRequest = new DefaultInvocationRequest();
mavenRequest.setPomFile(pomFile);
mavenRequest.setBaseDirectory(pomFile.getParentFile());
mavenRequest.setUserSettingsFile(userSettings);
mavenRequest.setLocalRepositoryDirectory(repoDir);
mavenRequest.setGoals(Arrays.asList("clean", "package"));
Invoker invoker = new DefaultInvoker();
try {
InvocationResult result = invoker.execute(mavenRequest);
if (result.getExitCode() != 0) {
throw result.getExecutionException() != null ? result.getExecutionException()
: new IllegalStateException("Build failure: " + result.getExitCode());
}
getLog().info("Licenses POM executed: " + pomFile.getAbsolutePath());
} catch (Exception e) {
getLog().error("Error when executing " + pomFile.getAbsolutePath(), e);
}
}
示例6: backGroundBuild
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
void backGroundBuild(MavenProject project) throws MojoExecutionException {
MavenExecutionRequest executionRequest = session.getRequest();
InvocationRequest request = new DefaultInvocationRequest();
request.setBaseDirectory(project.getBasedir());
request.setPomFile(project.getFile());
request.setGoals(executionRequest.getGoals());
request.setRecursive(false);
request.setInteractive(false);
request.setProfiles(executionRequest.getActiveProfiles());
request.setProperties(executionRequest.getUserProperties());
Invoker invoker = new DefaultInvoker();
try {
InvocationResult result = invoker.execute(request);
if (result.getExitCode() != 0) {
throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", result.getExecutionException());
}
} catch (MavenInvocationException e) {
throw new IllegalStateException("Error invoking Maven goals:[" + StringUtils.join(executionRequest.getGoals(), ", ") + "]", e);
}
}
示例7: getResult
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
private AddMvnCommandResult getResult(InvocationResult invocationResult, List<Dependency> dependencies) {
if (invocationResult.getExitCode() != 0) {
if (invocationResult.getExecutionException() != null) {
return AddMvnCommandResult.error(invocationResult.getExecutionException().getMessage());
}
StringBuilder errorMsgBuilder = new StringBuilder("Could not resolve dependencies for:");
for (Dependency dependency : dependencies) {
errorMsgBuilder
.append("\n").append(dependency.groupId).append(" : ")
.append(dependency.artifactId).append(" : ")
.append(dependency.version);
}
return AddMvnCommandResult.error(errorMsgBuilder.toString());
}
return AddMvnCommandResult.SUCCESS;
}
示例8: executeGeneratedProjectBuild
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
private void executeGeneratedProjectBuild(File pomFile, File projectDir, File repoDir) throws Exception {
InvocationRequest mavenRequest = new DefaultInvocationRequest();
mavenRequest.setPomFile(pomFile);
mavenRequest.setBaseDirectory(projectDir);
mavenRequest.setUserSettingsFile(userSettings);
mavenRequest.setLocalRepositoryDirectory(repoDir);
mavenRequest.setGoals(Collections.singletonList("install"));
Properties props = System.getProperties();
if (Boolean.parseBoolean(downloadSources)) {
props.setProperty("swarm.download.sources", "");
}
if (Boolean.parseBoolean(downloadPoms)) {
props.setProperty("swarm.download.poms", "");
}
mavenRequest.setProperties(props);
Invoker invoker = new DefaultInvoker();
InvocationResult result = invoker.execute(mavenRequest);
if (result.getExitCode() != 0) {
throw result.getExecutionException();
}
getLog().info("Built project from BOM: " + projectDir.getAbsolutePath());
}
示例9: executeMavenGoal
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
public boolean executeMavenGoal(File projectPath, List<String> goals,
boolean isOffline) {
InvocationRequest request = new DefaultInvocationRequest();
if (!projectPath.exists()) {
projectPath.mkdirs();
}
request.setPomFile(new File(projectPath, POM_XML));
if (goals == null) {
goals = getDefaultMavenGoals();
}
request.setGoals(goals);
Invoker invoker = new DefaultInvoker();
request.setOffline(isOffline);
try {
InvocationResult result = invoker.execute(request);
if (result.getExecutionException() == null) {
if (result.getExitCode() != 0) {
request.setOffline(!isOffline);
result = invoker.execute(request);
if (result.getExitCode() == 0) {
return true;
} else {
final String errorMessage = "No maven Project found at "
+ projectPath;
log.error(errorMessage);
throw new MavenInvocationException(errorMessage);
}
}
return true;
}
} catch (MavenInvocationException e) {
log.error("Maven invocation failed", e);
}
return false;
}
示例10: newRunnable
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的package包/类
protected final Runnable newRunnable( Holder<Exception> errorHolder, String... goals )
{
return () ->
{
try
{
DefaultInvoker invoker = new DefaultInvoker();
invoker.setLocalRepositoryDirectory( new File( BASEDIR, "target/it-local-repository" ) );
invoker.setWorkingDirectory( tmp.getRoot() );
invoker.setLogger( new PrintStreamLogger( System.err, InvokerLogger.INFO ) );
InvocationRequest request = new DefaultInvocationRequest();
request.setOffline( true );
request.setPomFile( new File( tmp.getRoot(), "pom.xml" ) );
request.setGoals( Arrays.asList( goals ) );
InvocationResult result = invoker.execute( request );
if( result.getExecutionException() != null )
{
errorHolder.set( result.getExecutionException() );
}
else if( result.getExitCode() != 0 )
{
errorHolder.set(
new RuntimeException( "Maven invocation failure, exit code was: " + result.getExitCode() )
);
}
}
catch( Exception ex )
{
errorHolder.set( ex );
}
};
}
示例11: invokeMaven
import org.apache.maven.shared.invoker.InvocationResult; //导入方法依赖的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();
}