result = addExceptionToResult( new DefaultMavenExecutionResult(), e ); result = addExceptionToResult( new DefaultMavenExecutionResult(), e.getCause() ); result = addExceptionToResult( new DefaultMavenExecutionResult(), new InternalErrorException( "Internal error: " + e, e ) );
public boolean hasExceptions() { return !getExceptions().isEmpty(); }
MavenExecutionResult result = new DefaultMavenExecutionResult();
/** * * @param project * @return * @since 2.0 */ protected MavenSession newMavenSession( MavenProject project ) { MavenExecutionRequest request = new DefaultMavenExecutionRequest(); MavenExecutionResult result = new DefaultMavenExecutionResult(); MavenSession session = new MavenSession( container, MavenRepositorySystemUtils.newSession(), request, result ); session.setCurrentProject( project ); session.setProjects( Arrays.asList( project ) ); return session; }
@Override public synchronized MavenExecutionResult getExecutionResult() { if ( executionResult == null ) { this.executionResult = new DefaultMavenExecutionResult(); } return executionResult; }
@Override public MavenSession newMavenSession(File basedir) throws Exception { MavenExecutionRequest request = newExecutionRequest(); MavenExecutionResult result = new DefaultMavenExecutionResult(); DefaultMaven maven = (DefaultMaven) container.lookup(Maven.class); try { Object repositorySession = maven.getClass().getMethod("newRepositorySession", MavenExecutionRequest.class).invoke(maven, request); Class<?> repositorySessionClass = repositorySession.getClass().getClassLoader().loadClass("org.sonatype.aether.RepositorySystemSession"); Constructor<MavenSession> constructor = MavenSession.class.getConstructor(PlexusContainer.class, repositorySessionClass, MavenExecutionRequest.class, MavenExecutionResult.class); return constructor.newInstance(container, repositorySession, request, result); } catch (ReflectiveOperationException | SecurityException e) { throw new RuntimeException(e); } }
@SuppressWarnings("deprecation") public MavenSession createSession(MavenExecutionRequest request, MavenProject project) throws MavenException { RepositorySystemSession repoSession = createRepositorySession(request); MavenExecutionResult result = new DefaultMavenExecutionResult(); MavenSession mavenSession = new MavenSession(plexus, repoSession, request, result); if (project != null) { mavenSession.setProjects(Collections.singletonList(project)); } return mavenSession; }
@SuppressWarnings("deprecation") @Override public MavenSession newMavenSession(File basedir) throws Exception { MavenExecutionRequest request = newExecutionRequest(); RepositorySystemSession repositorySession = newRepositorySession(request); MavenExecutionResult result = new DefaultMavenExecutionResult(); return new MavenSession(container, repositorySession, request, result); }
protected MavenSession newMavenSession( MavenProject project, List<MavenProject> projects ) throws Exception { MavenExecutionRequest request = newMavenExecutionRequest( new File( project.getBasedir(), "pom.xml" ) ); MavenExecutionResult result = new DefaultMavenExecutionResult(); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); MavenSession session = new MavenSession(getContainer(), repositorySession, request, result); session.setCurrentProject( project ); session.setProjects( projects ); return session; }
protected MavenSession newMavenSession(MavenProject project, List<MavenProject> projects) throws Exception { MavenExecutionRequest request = newMavenExecutionRequest(new File(project.getBasedir(), "pom.xml")); MavenExecutionResult result = new DefaultMavenExecutionResult(); DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); MavenSession session = new MavenSession(getContainer(), repositorySession, request, result); session.setProjects(projects); session.setCurrentProject(project); return session; }
@SuppressWarnings("deprecation") @Override public MavenSession newMavenSession(File basedir) throws Exception { MavenExecutionRequest request = newExecutionRequest(); request.setMultiModuleProjectDirectory(basedir); RepositorySystemSession repositorySession = newRepositorySession(request); MavenExecutionResult result = new DefaultMavenExecutionResult(); return new MavenSession(container, repositorySession, request, result); } }
void init() throws MavenEmbedderException { try { this.mavenExecutionRequest = this.buildMavenExecutionRequest( mavenRequest ); RepositorySystemSession rss = ( (DefaultMaven) componentProvider.lookup( Maven.class ) ).newRepositorySession( mavenExecutionRequest ); mavenSession = new MavenSession( componentProvider.getPlexusContainer(), rss, mavenExecutionRequest, new DefaultMavenExecutionResult() ); componentProvider.lookup( LegacySupport.class ).setSession( mavenSession ); } catch ( MavenEmbedderException e ) { log.error( "Unable to build MavenEmbedder", e ); throw e; } catch ( ComponentLookupException e ) { log.error( "Unable to build MavenEmbedder", e ); throw new MavenEmbedderException( e.getMessage(), e ); } }
private MavenEmbedder( MavenRequest mavenRequest, ComponentProvider componentProvider ) throws MavenEmbedderException { this.mavenRequest = mavenRequest; this.componentProvider = componentProvider; try { this.mavenExecutionRequest = this.buildMavenExecutionRequest( mavenRequest ); RepositorySystemSession rss = ( (DefaultMaven) componentProvider.lookup( Maven.class ) ).newRepositorySession( mavenExecutionRequest ); mavenSession = new MavenSession( componentProvider.getPlexusContainer(), rss, mavenExecutionRequest, new DefaultMavenExecutionResult() ); componentProvider.lookup( LegacySupport.class ).setSession( mavenSession ); } catch ( MavenEmbedderException e ) { log.error( "Unable to build MavenEmbedder", e ); throw e; } catch ( ComponentLookupException e ) { log.error( "Unable to build MavenEmbedder", e ); throw new MavenEmbedderException( e.getMessage(), e ); } }
/** * * @param project * @return * @since 2.0 */ protected MavenSession newMavenSession( MavenProject project ) { MavenExecutionRequest request = new DefaultMavenExecutionRequest(); MavenExecutionResult result = new DefaultMavenExecutionResult(); MavenSession session = new MavenSession( container, MavenRepositorySystemUtils.newSession(), request, result ); session.setCurrentProject( project ); session.setProjects( Arrays.asList( project ) ); return session; }
new DefaultMavenExecutionResult() ) ); try
private DependencyResolvingMavenEmbedder(File mavenHome, MavenRequest mavenRequest, PlexusContainer plexusContainer) throws MavenEmbedderException { this.mavenHome = mavenHome; this.mavenRequest = mavenRequest; this.plexusContainer = plexusContainer; try { this.buildMavenExecutionRequest(); RepositorySystemSession rss = ((DefaultMaven) lookup(Maven.class)).newRepositorySession(mavenExecutionRequest); mavenSession = new MavenSession(plexusContainer, rss, mavenExecutionRequest, new DefaultMavenExecutionResult()); lookup(LegacySupport.class).setSession(mavenSession); } catch (MavenEmbedderException e) { throw new MavenEmbedderException(e.getMessage(), e); } catch (ComponentLookupException e) { throw new MavenEmbedderException(e.getMessage(), e); } }
private MavenEmbedder( File mavenHome, MavenRequest mavenRequest, PlexusContainer plexusContainer ) throws MavenEmbedderException { this.mavenHome = mavenHome; this.mavenRequest = mavenRequest; this.plexusContainer = plexusContainer; try { this.buildMavenExecutionRequest(); RepositorySystemSession rss = ((DefaultMaven) lookup(Maven.class)).newRepositorySession(mavenExecutionRequest); mavenSession = new MavenSession( plexusContainer, rss, mavenExecutionRequest, new DefaultMavenExecutionResult() ); lookup(LegacySupport.class).setSession(mavenSession); } catch (MavenEmbedderException e) { throw new MavenEmbedderException(e.getMessage(), e); } catch (ComponentLookupException e) { throw new MavenEmbedderException(e.getMessage(), e); } }
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; }
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; }
mavenExecutionRequest.setTransferListener(ProgressTransferListener.activeListener()); session.setTransferListener(ProgressTransferListener.activeListener()); lookupComponent(LegacySupport.class).setSession(new MavenSession(getPlexus(), session, mavenExecutionRequest, new DefaultMavenExecutionResult()));