if ( result.hasExceptions() ) for ( Throwable exception : result.getExceptions() ) if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) ) + getResumeFrom( result.getTopologicallySortedProjects(), project ) ).toString() );
BuildSummary buildSummary = result.getBuildSummary( project );
private MavenExecutionResult addExceptionToResult( MavenExecutionResult result, Throwable e ) { if ( !result.getExceptions().contains( e ) ) { result.addException( e ); } return result; }
buildContext.getResult().addException( t ); buildContext.getResult().addBuildSummary( new BuildFailure( mavenProject, buildEndTime - buildStartTime, t ) );
public void handle( final MavenExecutionResult event ) throws Exception { log.debug( "Execution result: {}", event ); if ( event.hasExceptions() ) { log.info( "Build failed with exception(s)" ); int i = 0; for ( Throwable cause : event.getExceptions() ) { log.info( "[{}] {}", ++i, cause ); } } log.debug( "Recording MavenProjects" ); getBuildRecorder().recordSessionFinished( MavenProjectConverter.extractFrom( event ) ); } }
public HudsonMavenExecutionResult(MavenExecutionResult mavenExecutionResult) { if (mavenExecutionResult == null) { return; } throwables = mavenExecutionResult.getExceptions(); List<MavenProject> mavenProjects = mavenExecutionResult.getTopologicallySortedProjects(); if (mavenProjects != null) { for (MavenProject mavenProject : mavenProjects) { MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); mavenProjectInfos.add( mavenProjectInfo ); BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); // NPE free : looks to have null here when the projects is not finished ie tests failures if ( buildSummary != null ) { mavenProjectInfo.setBuildTime( buildSummary.getTime() ); } } } }
private void logResult( MavenSession session ) { infoLine( '-' ); MessageBuilder buffer = buffer(); if ( session.getResult().hasExceptions() ) { buffer.failure( "BUILD FAILURE" ); } else { buffer.success( "BUILD SUCCESS" ); } logger.info( buffer.toString() ); }
MavenProject project = result.getProject(); if(project != null) { return project; if(result.hasExceptions()) { List<IStatus> statuses = new ArrayList<IStatus>(); List<Throwable> exceptions = result.getExceptions(); for(Throwable e : exceptions) { statuses.add(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1, e.getMessage(), e));
public static ArrayList<MavenProjectDTO> extractFrom( final MavenExecutionResult event ) { ArrayList<MavenProjectDTO> participatingProjects = new ArrayList<MavenProjectDTO>(); List<MavenProject> projects = event.getTopologicallySortedProjects(); for ( MavenProject mavenProject : projects ) { MavenProjectDTO projectDTO = convertMavenProject( mavenProject ); updateWithBuildSummary( projectDTO, event.getBuildSummary( mavenProject ) ); participatingProjects.add( projectDTO ); } return participatingProjects; }
if ( result.hasExceptions() ) result.setTopologicallySortedProjects( session.getProjects() ); result.setProject( session.getTopLevelProject() ); if ( session.getResult().hasExceptions() ) return addExceptionToResult( result, session.getResult().getExceptions().get( 0 ) );
@Override public void afterSessionEnd(MavenSession session) throws MavenExecutionException { boolean errors = !session.getResult().getExceptions().isEmpty(); if (!deployAtEndRequests.isEmpty()) { log.info(""); log.info("------------------------------------------------------------------------"); if (errors) { log.info("-- Not performing deploy at end due to errors --"); } else { log.info("-- Performing deploy at end --"); log.info("------------------------------------------------------------------------"); synchronized (deployAtEndRequests) { for (DeployRequest deployRequest : deployAtEndRequests) { try { deploy(session.getRepositorySession(), deployRequest); } catch (DeploymentException e) { log.error(e.getMessage(), e); throw new MavenExecutionException(e.getMessage(), e); } } deployAtEndRequests.clear(); } } log.info("------------------------------------------------------------------------"); } }
private boolean hasFailedWithoutProject(MavenExecutionResult event) { return event.getProject() == null && event.hasExceptions(); }
public MavenExecutionResult readProjectWithDependencies(MavenExecutionRequest req, boolean useWorkspaceResolution) { if (useWorkspaceResolution) { req.setWorkspaceReader(new NbWorkspaceReader()); } File pomFile = req.getPom(); MavenExecutionResult result = new DefaultMavenExecutionResult(); try { ProjectBuildingRequest configuration = req.getProjectBuildingRequest(); configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); configuration.setResolveDependencies(true); configuration.setRepositorySession(maven.newRepositorySession(req)); ProjectBuildingResult projectBuildingResult = projectBuilder.build(pomFile, configuration); result.setProject(projectBuildingResult.getProject()); result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult()); } catch (ProjectBuildingException ex) { //don't add the exception here. this should come out as a build marker, not fill //the error logs with msgs return result.addException(ex); } normalizePaths(result.getProject()); return result; }
private boolean hasOnlyOneModule(MavenExecutionResult result) { return result.getTopologicallySortedProjects().size() == 1; }
public MavenExecutionResult readMavenProject(File pomFile, ProjectBuildingRequest configuration) throws MavenException { long start = System.currentTimeMillis(); log.debug("Reading Maven project: {}", pomFile.getAbsoluteFile()); //$NON-NLS-1$ MavenExecutionResult result = new DefaultMavenExecutionResult(); try { configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL); ProjectBuildingResult projectBuildingResult = lookup(ProjectBuilder.class).build(pomFile, configuration); result.setProject(projectBuildingResult.getProject()); result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult()); } catch (ProjectBuildingException ex) { if (ex.getResults() != null && ex.getResults().size() == 1) { ProjectBuildingResult projectBuildingResult = ex.getResults().get(0); result.setProject(projectBuildingResult.getProject()); result.setDependencyResolutionResult(projectBuildingResult.getDependencyResolutionResult()); } result.addException(ex); } catch (RuntimeException e) { result.addException(e); } finally { log.debug("Read Maven project: {} in {} ms", pomFile.getAbsoluteFile(), System.currentTimeMillis() - start); //$NON-NLS-1$ } return result; }
rootSession.getResult().addException( e ); break; rootSession.getResult().addException( e ); break;
private String buildShortTitle(MavenExecutionResult result) { return result.getProject().getName(); }
public void handle( final MavenExecutionResult event ) throws Exception { log.debug( "Execution result: {}", event ); if ( event.hasExceptions() ) { log.info( "Build failed with exception(s)" ); int i = 0; for ( Throwable cause : event.getExceptions() ) { log.info( "[{}] {}", ++i, cause ); } } log.debug( "Recording MavenProjects" ); getBuildRecorder().recordSessionFinished( MavenProjectConverter.extractFrom( event ) ); } }
public HudsonMavenExecutionResult(MavenExecutionResult mavenExecutionResult) { if (mavenExecutionResult == null) { return; } throwables = mavenExecutionResult.getExceptions(); List<MavenProject> mavenProjects = mavenExecutionResult.getTopologicallySortedProjects(); if (mavenProjects != null) { for (MavenProject mavenProject : mavenProjects) { MavenProjectInfo mavenProjectInfo = new MavenProjectInfo( mavenProject ); mavenProjectInfos.add( mavenProjectInfo ); BuildSummary buildSummary = mavenExecutionResult.getBuildSummary( mavenProject ); // NPE free : looks to have null here when the projects is not finished ie tests failures if ( buildSummary != null ) { mavenProjectInfo.setBuildTime( buildSummary.getTime() ); } } } }
protected Status getBuildStatus(MavenExecutionResult result) { return result.hasExceptions() ? Status.FAILURE : Status.SUCCESS; }