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


Java InvocationResult.getExecutionException方法代码示例

本文整理汇总了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);
  }

}
 
开发者ID:tsiq,项目名称:magic-beanstalk,代码行数:30,代码来源:AllGoalsMojo.java

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

示例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());
}
 
开发者ID:mytaxi,项目名称:phrase-maven-plugin,代码行数:23,代码来源:IntegrationTest.java

示例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);
		}
	}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:24,代码来源:MavenRuntime.java

示例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);
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:21,代码来源:LicenseMojo.java

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

示例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;
}
 
开发者ID:twosigma,项目名称:beakerx,代码行数:18,代码来源:MavenJarResolver.java

示例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());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:30,代码来源:RepositoryBuilderMojo.java

示例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;
}
 
开发者ID:wso2,项目名称:developer-studio,代码行数:40,代码来源:MavenExecutorImpl.java

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

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


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