當前位置: 首頁>>代碼示例>>Java>>正文


Java MavenSession.getRepositorySession方法代碼示例

本文整理匯總了Java中org.apache.maven.execution.MavenSession.getRepositorySession方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenSession.getRepositorySession方法的具體用法?Java MavenSession.getRepositorySession怎麽用?Java MavenSession.getRepositorySession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.execution.MavenSession的用法示例。


在下文中一共展示了MavenSession.getRepositorySession方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testVersionlessDependency

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@Test
public void testVersionlessDependency() throws Exception {
  File basedir = resources.getBasedir();
  MavenProject project = maven.readMavenProject(basedir);
  maven.newDependency(temp.newFile()).setGroupId("g").setArtifactId("a").setVersion("1").addTo(project);

  MavenSession mavenSession = maven.newMavenSession(project);
  RepositorySystemSession repoSession = mavenSession.getRepositorySession();
  SimpleReactorReader.builder() //
      .addArtifact("g:a:1", temp.newFile()) //
      .addArtifact("g:a:pom:1", temp.newFile()) //
      .toSession(repoSession);

  ProcessorpathResolver resolver = maven.lookup(ProcessorpathResolver.class);
  List<File> processorpath = resolver.resolve(repoSession, project, dependencies("g:a"));

  assertEquals(1, processorpath.size());
  assertTrue(processorpath.get(0).isFile());
}
 
開發者ID:takari,項目名稱:takari-lifecycle,代碼行數:20,代碼來源:ProcessorpathResolverTest.java

示例2: injectRepositorySession

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
static void injectRepositorySession(
        Logger logger, MavenSession session, Map<String, String> dict) {
    // Inject repository session properties.
    try {
        Map<String, String> repoSessionProps;
        // Due to repackaging of Aether in Maven 3.1, session.getRepositorySession()
        // will return either org.eclipse.aether.RepositorySystemSession (Maven 3.1+)
        // or org.sonatype.aether.RepositorySystemSession (Maven 3.0.x)
        // depending on the version of Maven that executes the project.
        // Both interfaces have getSystemProperties() accessor method that returns Map<String, String>.
        Object repoSession = session.getRepositorySession();
        Class<?> cls = repoSession.getClass();
        final Method getSystemPropertiesMethod = cls.getDeclaredMethod("getSystemProperties");
        repoSessionProps = (Map<String, String>) getSystemPropertiesMethod.invoke(repoSession);
        try {
            repoSessionProps.putAll(dict);
        } catch (Exception e) {
            // Time to hack: RepositorySystemSession.getSystemProperties() returned an immutable map.
            Field f = cls.getDeclaredField("systemProperties");
            f.setAccessible(true);
            repoSessionProps = (Map<String, String>) f.get(repoSession);
            repoSessionProps.putAll(dict);
        }
    } catch (Throwable t) {
        logger.warn("Failed to inject repository session properties.", t);
    }
}
 
開發者ID:trustin,項目名稱:os-maven-plugin,代碼行數:29,代碼來源:RepositorySessionInjector.java

示例3: resolvePluginVersion

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private void resolvePluginVersion( Plugin plugin, MavenSession session, MavenProject project )
    throws PluginVersionResolutionException
{
    PluginVersionRequest versionRequest =
        new DefaultPluginVersionRequest( plugin, session.getRepositorySession(),
                                         project.getRemotePluginRepositories() );
    plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:9,代碼來源:MojoDescriptorCreator.java

示例4: getDependencies

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
private Set<Artifact> getDependencies( MavenProject project, Collection<String> scopesToCollect,
                                       Collection<String> scopesToResolve, MavenSession session,
                                       boolean aggregating, Set<Artifact> projectArtifacts )
    throws LifecycleExecutionException
{
    if ( scopesToCollect == null )
    {
        scopesToCollect = Collections.emptySet();
    }
    if ( scopesToResolve == null )
    {
        scopesToResolve = Collections.emptySet();
    }

    if ( scopesToCollect.isEmpty() && scopesToResolve.isEmpty() )
    {
        return new LinkedHashSet<Artifact>();
    }

    scopesToCollect = new HashSet<String>( scopesToCollect );
    scopesToCollect.addAll( scopesToResolve );

    DependencyFilter collectionFilter = new ScopeDependencyFilter( null, negate( scopesToCollect ) );
    DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) );
    resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter );
    resolutionFilter =
        AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) );

    DependencyResolutionResult result;
    try
    {
        DefaultDependencyResolutionRequest request =
            new DefaultDependencyResolutionRequest( project, session.getRepositorySession() );
        request.setResolutionFilter( resolutionFilter );

        eventSpyDispatcher.onEvent( request );

        result = dependenciesResolver.resolve( request );
    }
    catch ( DependencyResolutionException e )
    {
        result = e.getResult();

        /*
         * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
         * plugins that require dependency resolution although they usually run in phases of the build where project
         * artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
         */
        if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) )
        {
            logger.warn( "The following dependencies could not be resolved at this point of the build"
                + " but seem to be part of the reactor:" );

            for ( Dependency dependency : result.getUnresolvedDependencies() )
            {
                logger.warn( "o " + dependency );
            }

            logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
        }
        else
        {
            throw new LifecycleExecutionException( null, project, e );
        }
    }

    eventSpyDispatcher.onEvent( result );

    Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
    if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() )
    {
        RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(),
                                     Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
    }
    return artifacts;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:77,代碼來源:LifecycleDependencyResolver.java

示例5: getRepositorySession

import org.apache.maven.execution.MavenSession; //導入方法依賴的package包/類
public RepositorySystemSession getRepositorySession()
{
    MavenSession session = getSession();
    return ( session != null ) ? session.getRepositorySession() : null;
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:6,代碼來源:DefaultLegacySupport.java


注:本文中的org.apache.maven.execution.MavenSession.getRepositorySession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。