org.apache.maven.plugin.LegacySupport类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(121)

本文整理了Java中org.apache.maven.plugin.LegacySupport类的一些代码示例,展示了LegacySupport类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LegacySupport类的具体详情如下:
包路径:org.apache.maven.plugin.LegacySupport
类名称:LegacySupport

LegacySupport介绍

[英]Helps to provide backward-compatibility with plugins that use legacy components. Warning: This is an internal utility interface that is only public for technical reasons, it is not part of the public API. In particular, this interface can be changed or deleted without prior notice.
[中]有助于提供与使用旧组件的插件的向后兼容性。警告:这是一个内部实用程序接口,仅出于技术原因是公共的,它不是公共API的一部分。特别是,此接口可以在不事先通知的情况下更改或删除。

代码示例

代码示例来源:origin: apache/maven

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;
}

代码示例来源:origin: apache/maven

MavenSession session = new MavenSession( container, repoSession, request, result );
legacySupport.setSession( session );

代码示例来源:origin: apache/maven

LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem );
request.setTrace( RequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );

代码示例来源:origin: apache/maven

public void executeMojo( MavenSession session, MojoExecution mojoExecution )
  throws MojoFailureException, MojoExecutionException, PluginConfigurationException, PluginManagerException
  MavenProject project = session.getCurrentProject();
  Thread.currentThread().setContextClassLoader( pluginRealm );
  MavenSession oldSession = legacySupport.getSession();
    legacySupport.setSession( session );
    legacySupport.setSession( oldSession );

代码示例来源:origin: apache/maven

public AuthenticationInfo getAuthenticationInfo( String id )
  MavenSession session = legacySupport.getSession();
    MavenExecutionRequest request = session.getRequest();

代码示例来源:origin: takari/polyglot-maven

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 );
  }
}

代码示例来源:origin: apache/maven

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 );
  }
}

代码示例来源:origin: ImmobilienScout24/deadcode4j

Logger logger = LoggerFactory.getLogger(getClass());
try {
  if (legacySupport.getSession().isOffline()) {
    logger.info("Running in offline mode; skipping update check.");
    return absent();
  ArtifactVersion versionInUse = artifact.getVersionRange().getRecommendedVersion();
  ArtifactRepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata(artifact);
  repositoryMetadataManager.resolve(repositoryMetadata, legacySupport.getSession().getCurrentProject().getPluginArtifactRepositories(), legacySupport.getSession().getLocalRepository());
  ArtifactVersion newestVersion = versionInUse;
  for (String version : repositoryMetadata.getMetadata().getVersioning().getVersions()) {

代码示例来源:origin: apache/maven

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() );
  }
}

代码示例来源:origin: apache/maven

@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;
}

代码示例来源:origin: apache/maven

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;
  }
}

代码示例来源:origin: org.eclipse.tycho/tycho-core

@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);
}

代码示例来源:origin: apache/maven

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 );
  }
}

代码示例来源:origin: apache/maven

@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 );
}

代码示例来源:origin: apache/maven

legacySupport.setSession( null );

代码示例来源:origin: apache/maven

private static RepositorySystemSession rss( PlexusContainer c )
{
  try
  {
    LegacySupport legacySupport = c.lookup( LegacySupport.class );
    return legacySupport.getRepositorySession();
  }
  catch ( ComponentLookupException e )
  {
    throw new IllegalStateException( e );
  }
}

代码示例来源:origin: apache/maven

public ProxyInfo getProxy( String protocol )
  MavenSession session = legacySupport.getSession();
    MavenExecutionRequest request = session.getRequest();

代码示例来源:origin: io.takari.polyglot/polyglot-ruby

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 );
  }
}

代码示例来源:origin: apache/maven

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 );
  }
}

代码示例来源:origin: ImmobilienScout24/deadcode4j

public void sendUsageStatistics(DeadCodeStatistics deadCodeStatistics) {
  final Logger logger = getLogger();
  if (Boolean.TRUE.equals(deadCodeStatistics.getSkipSendingUsageStatistics())) {
    logger.debug("Configuration wants to me to skip sending usage statistics.");
    return;
  }
  if (legacySupport.getSession().isOffline()) {
    logger.info("Running in offline mode; skipping sending of usage statistics.");
    return;
  }
  SystemProperties systemProperties = SystemProperties.from(legacySupport, mavenRuntime);
  if (Boolean.FALSE.equals(deadCodeStatistics.getSkipSendingUsageStatistics())) {
    logger.debug("Configured to send usage statistics.");
  } else {
    if (!legacySupport.getSession().getRequest().isInteractiveMode()) {
      logger.info("Running in non-interactive mode; skipping sending of usage statistics.");
      return;
    }
    if (!askForPermissionAndComment(deadCodeStatistics, systemProperties)) {
      return;
    }
  }
  Map<String, String> parameters = getParameters(deadCodeStatistics, systemProperties);
  sendUsageStatistics(parameters);
}

相关文章

微信公众号

最新文章

更多