当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryUtils类代码示例

本文整理汇总了Java中org.apache.maven.RepositoryUtils的典型用法代码示例。如果您正苦于以下问题:Java RepositoryUtils类的具体用法?Java RepositoryUtils怎么用?Java RepositoryUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RepositoryUtils类属于org.apache.maven包,在下文中一共展示了RepositoryUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMirror

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private Mirror getMirror( RepositorySystemSession session, ArtifactRepository repository )
{
    if ( session != null )
    {
        org.sonatype.aether.repository.MirrorSelector selector = session.getMirrorSelector();
        if ( selector != null )
        {
            RemoteRepository repo = selector.getMirror( RepositoryUtils.toRepo( repository ) );
            if ( repo != null )
            {
                Mirror mirror = new Mirror();
                mirror.setId( repo.getId() );
                mirror.setUrl( repo.getUrl() );
                mirror.setLayout( repo.getContentType() );
                return mirror;
            }
        }
    }
    return null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:LegacyRepositorySystem.java

示例2: getAuthentication

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository )
{
    if ( session != null )
    {
        AuthenticationSelector selector = session.getAuthenticationSelector();
        if ( selector != null )
        {
            org.sonatype.aether.repository.Authentication auth =
                selector.getAuthentication( RepositoryUtils.toRepo( repository ) );
            if ( auth != null )
            {
                Authentication result = new Authentication( auth.getUsername(), auth.getPassword() );
                result.setPrivateKey( auth.getPrivateKeyFile() );
                result.setPassphrase( auth.getPassphrase() );
                return result;
            }
        }
    }
    return null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:LegacyRepositorySystem.java

示例3: getProxy

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private Proxy getProxy( RepositorySystemSession session, ArtifactRepository repository )
{
    if ( session != null )
    {
        ProxySelector selector = session.getProxySelector();
        if ( selector != null )
        {
            org.sonatype.aether.repository.Proxy proxy = selector.getProxy( RepositoryUtils.toRepo( repository ) );
            if ( proxy != null )
            {
                Proxy p = new Proxy();
                p.setHost( proxy.getHost() );
                p.setProtocol( proxy.getType() );
                p.setPort( proxy.getPort() );
                if ( proxy.getAuthentication() != null )
                {
                    p.setUserName( proxy.getAuthentication().getUsername() );
                    p.setPassword( proxy.getAuthentication().getPassword() );
                }
                return p;
            }
        }
    }
    return null;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:26,代码来源:LegacyRepositorySystem.java

示例4: retrieveArtifact

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
/**
 * Uses Aether to retrieve an artifact from the repository.
 *
 * @param coordinates as in groupId:artifactId:version
 * @return the located artifact
 */
Artifact retrieveArtifact(final String coordinates)
{

  final ArtifactRequest request = new ArtifactRequest();
  request.setArtifact(new DefaultArtifact(coordinates));
  request.setRepositories(remoteRepos);

  ArtifactResult result = null;
  try {
    result = repoSystem.resolveArtifact(repoSession, request);
  } catch (final ArtifactResolutionException e) {
    getLog().error("Could not resolve parent artifact (" + coordinates + "): " + e.getMessage());
  }

  if (result != null) {
    return RepositoryUtils.toArtifact(result.getArtifact());
  }
  return null;
}
 
开发者ID:mrice,项目名称:license-check,代码行数:26,代码来源:OpenSourceLicenseCheckMojo.java

示例5: init

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
@PostConstruct
public void init() {
  // setting the artifact version to a release version temporarily since the dist repository checks for a snapshot
  // version of the artifact. Maybe this can be implemented in a different manner but then we would have to setup the
  // repository manually
  org.apache.maven.artifact.Artifact projectArtifact = this.project.getArtifact();
  String oldVersion = projectArtifact.getVersion();
  projectArtifact.setVersion("1");

  // getting the remote repo
  this.deploymentRepository = RepositoryUtils.toRepo(this.project.getDistributionManagementArtifactRepository());

  // resetting the artifact version
  projectArtifact.setVersion(oldVersion);

  for (MavenProject p : this.reactorProjects) {
    // puts the initial module artifact coordinates into the cache
    addArtifactCoordinates(ProjectToCoordinates.POM.apply(p), ReleasePhase.PRE_RELEASE);

    // caching of SCM settings of every POM in order to go back to it before setting next dev version
    this.cachedScmSettings.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), p.getModel().getScm());

    Optional<Document> parsedPOM = PomUtil.parsePOM(p);
    if (parsedPOM.isPresent()) {
      this.originalPOMs.put(ProjectToCoordinates.EMPTY_VERSION.apply(p), parsedPOM.get());
    }
  }
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:29,代码来源:ReleaseMetadata.java

示例6: ScmRepositoryIndex

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private ScmRepositoryIndex(MavenSession session, RepositorySystemSession repoSession,
        ArtifactFactory repositorySystem, ProjectBuilder projectBuilder, Set<org.srcdeps.core.Scm> scms) {
    super();
    this.session = session;
    this.repoSession = repoSession;
    this.repositorySystem = repositorySystem;
    this.projectBuilder = projectBuilder;
    this.remoteRepos = RepositoryUtils.toRepos(session.getProjectBuildingRequest().getRemoteRepositories());
    this.scms = scms;
}
 
开发者ID:srcdeps,项目名称:srcdeps-maven,代码行数:11,代码来源:SrcdepsInitMojo.java

示例7: convertAetherDependencyNodes

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public static List<MavenArtifactNode> convertAetherDependencyNodes(MavenArtifactNode parent,
                                                                   Collection<DependencyNode> nodes,
                                                                   Map<Artifact, MavenArtifact> nativeToConvertedMap,
                                                                   File localRepository) {
  List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
  for (DependencyNode each : nodes) {
    Artifact a = RepositoryUtils.toArtifact(each.getDependency().getArtifact());
    MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);

    Map<?, ?> data = each.getData();
    //String premanagedVersion = DependencyManagerUtils.getPremanagedVersion(each);
    //String premanagedScope = DependencyManagerUtils.getPremanagedScope(each);

    //Object winner = data.get(ConflictResolver.NODE_DATA_WINNER);
    //if(winner instanceof DependencyNode) {
    //  DependencyNode winnerNode = (DependencyNode)winner;
    //  if(!StringUtil.equals(each.getVersion().toString(), winnerNode.getVersion().toString())) {
    //    state = MavenArtifactState.CONFLICT;
    //    Artifact winnerArtifact = RepositoryUtils.toArtifact(winnerNode.getDependency().getArtifact());
    //    relatedArtifact = convertArtifact(winnerArtifact, nativeToConvertedMap, localRepository);
    //  }
    //}
    //

    MavenArtifactNode newNode = new MavenArtifactNode(
      parent, ma, MavenArtifactState.ADDED, null, each.getDependency().getScope(),
      each.getPremanagedVersion(), each.getPremanagedScope());
    newNode.setDependencies(convertAetherDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
    result.add(newNode);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:Maven30AetherModelConverter.java

示例8: convertAetherDependencyNodes

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public static List<MavenArtifactNode> convertAetherDependencyNodes(MavenArtifactNode parent,
                                                                   Collection<DependencyNode> nodes,
                                                                   Map<Artifact, MavenArtifact> nativeToConvertedMap,
                                                                   File localRepository) {
  List<MavenArtifactNode> result = new ArrayList<MavenArtifactNode>(nodes.size());
  for (DependencyNode each : nodes) {
    Artifact a = RepositoryUtils.toArtifact(each.getDependency().getArtifact());
    MavenArtifact ma = convertArtifact(a, nativeToConvertedMap, localRepository);

    Map<?, ?> data = each.getData();
    String premanagedVersion = DependencyManagerUtils.getPremanagedVersion(each);
    String premanagedScope = DependencyManagerUtils.getPremanagedScope(each);


    MavenArtifactState state = MavenArtifactState.ADDED;
    MavenArtifact relatedArtifact = null;

    Object winner = data.get(ConflictResolver.NODE_DATA_WINNER);
    if(winner instanceof DependencyNode) {
      DependencyNode winnerNode = (DependencyNode)winner;
      if(!StringUtil.equals(each.getVersion().toString(), winnerNode.getVersion().toString())) {
        state = MavenArtifactState.CONFLICT;
        Artifact winnerArtifact = RepositoryUtils.toArtifact(winnerNode.getDependency().getArtifact());
        relatedArtifact = convertArtifact(winnerArtifact, nativeToConvertedMap, localRepository);
      }
    }

    MavenArtifactNode newNode = new MavenArtifactNode(
      parent, ma, state, relatedArtifact, each.getDependency().getScope(),
      premanagedVersion, premanagedScope);
    newNode.setDependencies(convertAetherDependencyNodes(newNode, each.getChildren(), nativeToConvertedMap, localRepository));
    result.add(newNode);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:Maven32AetherModelConverter.java

示例9: getBundleArtifacts

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public Set<BundleArtifact> getBundleArtifacts(List<DependencyNode> nodes) {
	Set<BundleArtifact> bundleArtifacts = new HashSet<BundleArtifact>();
	for (DependencyNode node : nodes) {
		Artifact artifact = RepositoryUtils.toArtifact(node.getDependency().getArtifact());
		String symbolicName = getManifestAttribute(artifact, Constants.BUNDLE_SYMBOLICNAME);
		if (symbolicName != null) {
			String version = getManifestAttribute(artifact, Constants.BUNDLE_VERSION);
			bundleArtifacts.add(new BundleArtifact(artifact, symbolicName, version));
			bundleArtifacts.addAll(getBundleArtifacts(node.getChildren()));
		} else {
			log.warn("Not an OSGi bundle : " + artifact.getId());
		}
	}
	return bundleArtifacts;
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:16,代码来源:MavenOsgiUtils.java

示例10: getAllArtifacts

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public Set<Artifact> getAllArtifacts(List<DependencyNode> nodes) {
	Set<Artifact> artifacts = new HashSet<Artifact>();
	for (DependencyNode node : nodes) {
		Artifact artifact = RepositoryUtils.toArtifact(node.getDependency().getArtifact());
		if (isBundle(artifact)) {
			artifacts.add(artifact);
			artifacts.addAll(getAllArtifacts(node.getChildren()));
		}
	}
	return artifacts;
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:12,代码来源:MavenOsgiUtils.java

示例11: getArtifacts

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public Set<Artifact> getArtifacts(List<DependencyNode> nodes) {
	Set<Artifact> artifacts = new HashSet<Artifact>();
	for (DependencyNode node : nodes) {
		Artifact artifact = RepositoryUtils.toArtifact(node.getDependency().getArtifact());
		if (isBundle(artifact)) {
			artifacts.add(artifact);
		}
	}
	return artifacts;
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:11,代码来源:MavenOsgiUtils.java

示例12: testSensibleSession

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
public void testSensibleSession(MavenSession s) throws Exception {
    MavenSession ms = newMavenSession();  //((LicenseAuditMojo)mojo).mavenSession;
    assertNotNull( ms );
    assertNotNull( ms.getLocalRepository().getBasedir() );
    System.out.println("Basedir: "+ms.getLocalRepository().getBasedir());
    // The following artifacts could not be resolved: org.apache.maven:maven-core:jar:2.0.7

    RepositorySystem rs = lookup(RepositorySystem.class);
    assertNotNull( rs );

    // check we can access stuff in remote repos
    // (fails if we don't have proper aether connectors + transforms,
    // or if we've not "populated" with default remote repos)
    ArtifactResult art;
    art = resolveArtifact(rs, ms, "org.apache.maven:maven-core:jar:2.0.7");
    System.out.println(art);
    assertNotNull(art.getArtifact());

    // check we avoid this:
    // [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:22, /Users/alex/.m2/repository/org/apache/commons/commons-parent/22/commons-parent-22.pom, line 909, column 14
    art = resolveArtifact(rs, ms, "org.apache.commons:commons-lang3:3.1");
    System.out.println(art);
    assertNotNull(art.getArtifact());
    
    ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
    ProjectBuildingResult res = projectBuilder.build(RepositoryUtils.toArtifact(art.getArtifact()), true, ms.getProjectBuildingRequest());
    System.out.println(res);
    if (!res.getProblems().isEmpty()) fail("Problems: "+res.getProblems());
}
 
开发者ID:ahgittin,项目名称:license-audit-maven-plugin,代码行数:30,代码来源:BetterAbstractMojoTestCaseTest.java

示例13: resolveArtifact

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
static ArtifactResult resolveArtifact(RepositorySystem rs, MavenSession ms, String coords) throws ArtifactResolutionException {
    return rs.resolveArtifact(
        ms.getRepositorySession(),
        new ArtifactRequest(new DefaultArtifact(coords), 
            RepositoryUtils.toRepos(ms.getRequest().getRemoteRepositories()), 
            null));
}
 
开发者ID:ahgittin,项目名称:license-audit-maven-plugin,代码行数:8,代码来源:BetterAbstractMojoTestCaseTest.java

示例14: findProjectArtifact

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private static Artifact findProjectArtifact(MavenProject project) {
    String extension = project.getArtifact().getArtifactHandler().getExtension();

    String fileName = project.getModel().getBuild().getFinalName() + "." + extension;
    File f = new File(new File(project.getBasedir(), "target"), fileName);
    if (f.exists()) {
        Artifact ret = RepositoryUtils.toArtifact(project.getArtifact());
        return ret.setFile(f);
    } else {
        return null;
    }
}
 
开发者ID:revapi,项目名称:revapi,代码行数:13,代码来源:Analyzer.java

示例15: resolveDependencies

import org.apache.maven.RepositoryUtils; //导入依赖的package包/类
private DependencyResolutionResult resolveDependencies( MavenProject project, RepositorySystemSession session )
{
    DependencyResolutionResult resolutionResult = null;

    try
    {
        DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest( project, session );
        resolutionResult = dependencyResolver.resolve( resolution );
    }
    catch ( DependencyResolutionException e )
    {
        resolutionResult = e.getResult();
    }

    Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
    if ( resolutionResult.getDependencyGraph() != null )
    {
        RepositoryUtils.toArtifacts( artifacts, resolutionResult.getDependencyGraph().getChildren(),
                                     Collections.singletonList( project.getArtifact().getId() ), null );

        // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
        LocalRepositoryManager lrm = session.getLocalRepositoryManager();
        for ( Artifact artifact : artifacts )
        {
            if ( !artifact.isResolved() )
            {
                String path = lrm.getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) );
                artifact.setFile( new File( lrm.getRepository().getBasedir(), path ) );
            }
        }
    }
    project.setResolvedArtifacts( artifacts );
    project.setArtifacts( artifacts );

    return resolutionResult;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:37,代码来源:DefaultProjectBuilder.java


注:本文中的org.apache.maven.RepositoryUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。