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


Java MavenExecutionResult.hasExceptions方法代码示例

本文整理汇总了Java中org.apache.maven.execution.MavenExecutionResult.hasExceptions方法的典型用法代码示例。如果您正苦于以下问题:Java MavenExecutionResult.hasExceptions方法的具体用法?Java MavenExecutionResult.hasExceptions怎么用?Java MavenExecutionResult.hasExceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.execution.MavenExecutionResult的用法示例。


在下文中一共展示了MavenExecutionResult.hasExceptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProjectClassPaths

import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
public static List<String> getProjectClassPaths(String localPathRevision) throws Exception {
        MavenExecutionResult result = getResult(localPathRevision, Arrays.asList("dependency:resolve"), null);

//        List<Throwable> exceptions = result.getExceptions();
//        for (Throwable throwable : exceptions) {
//            throwable.printStackTrace();
//        }
        if (result.hasExceptions()) {
            throw new MavenException(result.getExceptions().toString());
        }

        Map<String, Artifact> artifactMap = result.getProject().getArtifactMap();
        List<String> classpath = new ArrayList<String>(artifactMap.size());
        for (String artifact : artifactMap.keySet()) {
            String path = artifactMap.get(artifact).getFile().getAbsolutePath();
//            System.out.println("artifact = " + path);
            classpath.add(path);
//            for (String string : artifact.getDependencyTrail()) {
//                System.out.println("                 " + string);
//            }
        }
        Collections.sort(classpath);
        return classpath;
    }
 
开发者ID:gems-uff,项目名称:oceano,代码行数:25,代码来源:MavenUtil.java

示例2: translatePom

import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
private void translatePom(IFile input, IProgressMonitor monitor) throws CoreException {
  markerManager.deleteMarkers(input, TRANSLATION_PROBLEM_TYPE);

  IProject project = input.getProject();
  IFile pomXml = project.getFile(IMavenConstants.POM_FILE_NAME);
  IPath buildFolder;
  if (pomXml.exists()) {
   	IMavenProjectFacade facade = projectManager.create(pomXml, true, monitor);
   	MavenProject mavenProject = facade.getMavenProject(monitor);
   	buildFolder = facade.getProjectRelativePath(mavenProject.getBuild().getDirectory());
  } else {
  		//In case where pom.xml doesn't exist, fall back to default target folder
  		buildFolder = project.getFolder("target").getProjectRelativePath();
  }

  IPath polyglotFolder = buildFolder.append("polyglot");
  IFile output = project.getFolder(polyglotFolder).getFile(IMavenConstants.POM_FILE_NAME);
  MavenExecutionResult result = translate(pomXml, input, output, monitor);
  if (result.hasExceptions()) {
    addErrorMarkers(input, result.getExceptions());
    return;
  } 
  
  if (output.exists()) {
  	  try (InputStream content = output.getContents()) {
  		  if (pomXml.exists()) {
  			  pomXml.setContents(content, true, true, monitor);
  		  } else {
  			  pomXml.create(content, true, monitor);
  		  }
  		  if (!pomXml.isDerived()) {
  			  pomXml.setDerived(true, monitor);
  		  }
  	  } catch (IOException e) {
  		  throw new CoreException(new Status(IStatus.ERROR, PolyglotSupportActivator.PLUGIN_ID, "Unable to write to pom.xml", e));
 }
  }
}
 
开发者ID:jbosstools,项目名称:m2e-polyglot-poc,代码行数:39,代码来源:PomTranslatorJob.java

示例3: execute

import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
private int execute( CliRequest cliRequest )
{
    eventSpyDispatcher.onEvent( cliRequest.request );

    MavenExecutionResult result = maven.execute( cliRequest.request );

    eventSpyDispatcher.onEvent( result );

    eventSpyDispatcher.close();

    if ( result.hasExceptions() )
    {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;

        for ( Throwable exception : result.getExceptions() )
        {
            ExceptionSummary summary = handler.handleException( exception );

            logSummary( summary, references, "", cliRequest.showErrors );

            if ( project == null && exception instanceof LifecycleExecutionException )
            {
                project = ( (LifecycleExecutionException) exception ).getProject();
            }
        }

        slf4jLogger.error( "" );

        if ( !cliRequest.showErrors )
        {
            slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the -e switch." );
        }
        if ( !slf4jLogger.isDebugEnabled() )
        {
            slf4jLogger.error( "Re-run Maven using the -X switch to enable full debug logging." );
        }

        if ( !references.isEmpty() )
        {
            slf4jLogger.error( "" );
            slf4jLogger.error( "For more information about the errors and possible solutions"
                          + ", please read the following articles:" );

            for ( Map.Entry<String, String> entry : references.entrySet() )
            {
                slf4jLogger.error( entry.getValue() + " " + entry.getKey() );
            }
        }

        if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) )
        {
            slf4jLogger.error( "" );
            slf4jLogger.error( "After correcting the problems, you can resume the build with the command" );
            slf4jLogger.error( "  mvn <goals> -rf :" + project.getArtifactId() );
        }

        if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) )
        {
            slf4jLogger.info( "Build failures were ignored." );

            return 0;
        }
        else
        {
            return 1;
        }
    }
    else
    {
        return 0;
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:77,代码来源:MavenCli.java

示例4: execute

import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
protected int execute(AFCliRequest cliRequest) throws MavenExecutionRequestPopulationException {
    MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.getRequest());

    eventSpyDispatcher.onEvent(request);

    MavenExecutionResult result = maven.execute(request);

    eventSpyDispatcher.onEvent(result);

    eventSpyDispatcher.close();

    if (result.hasExceptions()) {
        ExceptionHandler handler = new DefaultExceptionHandler();

        Map<String, String> references = new LinkedHashMap<String, String>();

        MavenProject project = null;

        for (Throwable exception : result.getExceptions()) {
            ExceptionSummary summary = handler.handleException(exception);

            logSummary(summary,
                       references,
                       "",
                       cliRequest.isShowErrors());

            if (project == null && exception instanceof LifecycleExecutionException) {
                project = ((LifecycleExecutionException) exception).getProject();
            }
        }

        slf4jLogger.error("");

        if (!cliRequest.isShowErrors()) {
            slf4jLogger.error("To see the full stack trace of the errors, re-run Maven with the -e switch.");
        }
        if (!slf4jLogger.isDebugEnabled()) {
            slf4jLogger.error("Re-run Maven using the -X switch to enable full debug logging.");
        }

        if (!references.isEmpty()) {
            slf4jLogger.error("");
            slf4jLogger.error("For more information about the errors and possible solutions"
                                      + ", please read the following articles:");

            for (Entry<String, String> entry : references.entrySet()) {
                slf4jLogger.error(entry.getValue() + " " + entry.getKey());
            }
        }

        if (project != null && !project.equals(result.getTopologicallySortedProjects().get(0))) {
            slf4jLogger.error("");
            slf4jLogger.error("After correcting the problems, you can resume the build with the command");
            slf4jLogger.error("  mvn <goals> -rf :" + project.getArtifactId());
        }

        if (MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(cliRequest.getRequest().getReactorFailureBehavior())) {
            slf4jLogger.info("Build failures were ignored.");
            return 0;
        } else {
            return 1;
        }
    } else {
        return 0;
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:67,代码来源:AFMavenCli.java

示例5: executeMaven

import org.apache.maven.execution.MavenExecutionResult; //导入方法依赖的package包/类
public static void executeMaven(final File pom,
                                final PrintStream stdout,
                                final PrintStream stderr,
                                final Properties properties,
                                final String... goals) {

    final PrintStream oldout = System.out;
    final PrintStream olderr = System.err;
    final Properties oldProperties = System.getProperties();
    if (properties != null) {
        properties.keySet().forEach((o) -> {
            if (properties.getProperty((String) o) != null) {
                System.setProperty((String) o,
                                   properties.getProperty((String) o));
            }
        });
    }

    final MavenEmbedder mavenEmbedder = newMavenEmbedder();
    try {
        if (stdout != null) {
            System.setOut(stdout);
        }
        if (stderr != null) {
            System.setErr(stderr);
        }

        final MavenRequest mavenRequest = MavenProjectLoader.createMavenRequest(false);
        mavenRequest.setGoals(Arrays.asList(goals));
        mavenRequest.setPom(pom.getAbsolutePath());

        final MavenExecutionResult result = mavenEmbedder.execute(mavenRequest);

        if (result.hasExceptions()) {
            for (Throwable t : result.getExceptions()) {
                LOG.error("Error Running Maven",
                          t);
            }
            throw new BuildException("Maven found issues trying to build the pom file: "
                                             + pom.getAbsolutePath() + ". Look at the Error Logs for more information");
        }
    } catch (final MavenEmbedderException ex) {
        throw new BuildException("Maven coudn't build the project for pom file: " + pom.getAbsolutePath(),
                                 ex);
    } finally {
        System.setProperties(oldProperties);
        mavenEmbedder.dispose();
        System.setOut(oldout);
        System.setErr(olderr);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:52,代码来源:MavenBuildExecutor.java


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