public Object getPluginComponent( Plugin plugin, String role, String roleHint ) throws PluginManagerException, ComponentLookupException { MavenSession session = legacySupport.getSession(); PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.getPluginDescriptor( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( Exception e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() ); return container.lookup( role, roleHint ); } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); } }
public Map<String, Object> getPluginComponents( Plugin plugin, String role ) throws ComponentLookupException, PluginManagerException { MavenSession session = legacySupport.getSession(); PluginDescriptor pluginDescriptor; try { pluginDescriptor = pluginManager.getPluginDescriptor( plugin, session.getCurrentProject().getRemotePluginRepositories(), session.getRepositorySession() ); pluginManager.setupPluginRealm( pluginDescriptor, session, null, null, null ); } catch ( Exception e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader( pluginDescriptor.getClassRealm() ); return container.lookupMap( role ); } finally { Thread.currentThread().setContextClassLoader( oldClassLoader ); } }
private ProjectBuildingRequest injectSession( ProjectBuildingRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setRepositorySession( session.getRepositorySession() ); request.setSystemProperties( session.getSystemProperties() ); if ( request.getUserProperties().isEmpty() ) { request.setUserProperties( session.getUserProperties() ); } MavenExecutionRequest req = session.getRequest(); if ( req != null ) { request.setRemoteRepositories( req.getRemoteRepositories() ); } } else { Properties props = new Properties(); EnvironmentUtils.addEnvVars( props ); props.putAll( System.getProperties() ); request.setSystemProperties( props ); } return request; }
Thread.currentThread().setContextClassLoader( pluginRealm ); MavenSession oldSession = legacySupport.getSession();
public PluginDescriptor getPluginDescriptorForPrefix( String prefix ) { MavenSession session = legacySupport.getSession(); PluginPrefixRequest request = new DefaultPluginPrefixRequest( prefix, session ); try { PluginPrefixResult result = pluginPrefixResolver.resolve( request ); Plugin plugin = new Plugin(); plugin.setGroupId( result.getGroupId() ); plugin.setArtifactId( result.getArtifactId() ); return loadPluginDescriptor( plugin, session.getCurrentProject(), session ); } catch ( Exception e ) { return null; } }
@Deprecated public ArtifactRepository getMirrorRepository( ArtifactRepository repository ) { Mirror mirror = mirrorSelector.getMirror( repository, legacySupport.getSession().getSettings().getMirrors() ); if ( mirror != null ) { String id = mirror.getId(); if ( id == null ) { // TODO this should be illegal in settings.xml id = repository.getId(); } log.debug( "Using mirror: " + mirror.getUrl() + " (id: " + id + ")" ); repository = artifactRepositoryFactory.createArtifactRepository( id, mirror.getUrl(), repository.getLayout(), repository.getSnapshots(), repository.getReleases() ); } return repository; }
request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings, ArtifactRepository localRepository ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { MavenSession session = legacySupport.getSession(); if ( plugin.getVersion() == null ) { PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, session.getRepositorySession(), project.getRemotePluginRepositories() ); plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() ); } try { return pluginManager.getPluginDescriptor( plugin, project.getRemotePluginRepositories(), session.getRepositorySession() ); } catch ( PluginResolutionException e ) { throw new PluginNotFoundException( plugin, project.getPluginArtifactRepositories() ); } catch ( PluginDescriptorParsingException | InvalidPluginDescriptorException e ) { throw new PluginManagerException( plugin, e.getMessage(), e ); } }
private void injectSession( ArtifactResolutionRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); } }
@SuppressWarnings( "checkstyle:parameternumber" ) public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map<String, Artifact> managedVersions, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners, List<ConflictResolver> conflictResolvers ) throws ArtifactResolutionException, ArtifactNotFoundException { ArtifactResolutionRequest request = new ArtifactResolutionRequest(). setArtifact( originatingArtifact ). setResolveRoot( false ). // This is required by the surefire plugin setArtifactDependencies( artifacts ). setManagedVersionMap( managedVersions ). setLocalRepository( localRepository ). setRemoteRepositories( remoteRepositories ). setCollectionFilter( filter ). setListeners( listeners ); injectSession2( request, legacySupport.getSession() ); return resolveWithExceptions( request ); }
public AuthenticationInfo getAuthenticationInfo( String id ) MavenSession session = legacySupport.getSession();
public ProxyInfo getProxy( String protocol ) MavenSession session = legacySupport.getSession();
MavenSession session = legacySupport.getSession(); if ( session != null )
private void setup( String gav, ClassRealm realm ) throws MalformedURLException { // looking into another JRUBY_HOME is for jruby itself only to allow // jruby build to use itself for bootstraping // see if we have shall use jruby from somewhere else String jrubyHome = System.getenv( "POLYGLOT_JRUBY_HOME" ); if ( jrubyHome == null ){ jrubyHome = System.getProperty( JRUBY_HOME ); } if ( jrubyHome == null ){ jrubyHome = legacySupport.getSession().getRequest().getUserProperties().getProperty( JRUBY_HOME ); } if ( jrubyHome == null ){ jrubyHome = legacySupport.getSession().getRequest().getSystemProperties().getProperty( JRUBY_HOME ); } if ( jrubyHome == null && legacySupport.getSession().getCurrentProject() != null ){ jrubyHome = legacySupport.getSession().getCurrentProject().getProperties().getProperty( JRUBY_HOME ); } if (jrubyHome != null ){ setupFromJrubyHome( jrubyHome, realm ); } else { // use jruby from an artifact doSetupArtifact( gav, realm ); } }
request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );
.setResolveRoot( true ) .setForceUpdate( true ) .setOffline( legacySupport.getSession().getRequest().isOffline() ) .setMirrors( legacySupport.getSession().getRequest().getMirrors() ) .setProxies( legacySupport.getSession().getRequest().getProxies() ) .setServers( legacySupport.getSession().getRequest().getServers()) .setLocalRepository( legacySupport.getSession().getRequest().getLocalRepository() ) .setRemoteRepositories( legacySupport.getSession().getRequest().getRemoteRepositories() ) .setResolveTransitively( true ) );
private Mirror getMirror( String repoId ) { MavenSession session = legacySupport.getSession(); MavenExecutionRequest request = session.getRequest(); if ( request != null ) { return getMirror( repoId, request.getMirrors() ); } return null; }
@Override public void locateRuntime(EquinoxRuntimeDescription description) throws MavenExecutionException { WorkspaceTychoOsgiRuntimeLocator workspaceLocator = WorkspaceTychoOsgiRuntimeLocator .getResolver(this.workspaceState); MavenSession session = buildContext.getSession(); addRuntimeArtifacts(workspaceLocator, session, description); for (String systemPackage : SYSTEM_PACKAGES_EXTRA) { description.addExtraSystemPackage(systemPackage); } if (workspaceLocator != null) { workspaceLocator.addPlatformProperties(description); } }
@Override public void afterFrameworkStarted(EmbeddedEquinox framework) { MavenSession session = context.getSession(); File localRepoRoot = new File(session.getLocalRepository().getBasedir()); MavenLoggerAdapter mavenLogger = new MavenLoggerAdapter(logger, false); Properties globalProps = getGlobalProperties(session); MavenContext mavenContext = new MavenContextImpl(localRepoRoot, session.isOffline(), mavenLogger, globalProps); framework.registerService(MavenContext.class, mavenContext); }
@Override public void afterFrameworkStarted(EmbeddedEquinox framework) { MavenSession session = context.getSession(); ProxyServiceFacade proxyService = framework.getServiceFactory().getService(ProxyServiceFacade.class); // make sure there is no old state from previous aborted builds clearProxyConfiguration(proxyService); for (Proxy proxy : session.getSettings().getProxies()) { if (proxy.isActive()) { setProxy(proxyService, proxy); } } }