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


Java Dependency类代码示例

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


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

示例1: getArtifactsWithDep

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
/**
 *
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE );
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:27,代码来源:DependencyResolver.java

示例2: getArtifactsWithDep

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
  Collection<String> excludes) throws RepositoryException {
  Artifact artifact = new DefaultArtifact(dependency);
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
          new PatternExclusionsDependencyFilter(excludes);

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
          DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  try {
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
  } catch (NullPointerException | DependencyResolutionException ex) {
    throw new RepositoryException(
            String.format("Cannot fetch dependencies for %s", dependency), ex);
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:32,代码来源:DependencyResolver.java

示例3: getArtifactsWithDep

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
/**
 * @param dependency
 * @param excludes list of pattern can either be of the form groupId:artifactId
 * @return
 * @throws Exception
 */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency,
    Collection<String> excludes) throws Exception {
  Artifact artifact = new DefaultArtifact(inferScalaVersion(dependency));
  DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
  PatternExclusionsDependencyFilter exclusionFilter =
      new PatternExclusionsDependencyFilter(inferScalaVersion(excludes));

  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));

  synchronized (repos) {
    for (RemoteRepository repo : repos) {
      collectRequest.addRepository(repo);
    }
  }
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
      DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
  return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:SparkDependencyResolver.java

示例4: parseDependencyGroupId

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private String parseDependencyGroupId(Dependency dependency, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
                                      RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
    String parsedGroupId;
    String groupId = dependency.getArtifact().getGroupId();

    Set<String> properties = getPropertiesFromString(groupId);

    for (String propertyName : properties) {
        String parsedProperty = getPropertyFromPom(parsePropertyName(propertyName), mvnRepository, system,
                remoteRepository, pomInformation);

        if (parsedProperty == null) {
            throw new MotechException(String.format("The property: %s used for groupId in dependency: %s cannot be found in pom and its parents.",
                    propertyName, dependency.getArtifact().getArtifactId()));
        }

        groupId = StringUtils.replace(groupId, propertyName, parsedProperty);
    }

    parsedGroupId = groupId;

    return parsedGroupId;
}
 
开发者ID:motech,项目名称:motech,代码行数:24,代码来源:ModuleAdminServiceImpl.java

示例5: testCollectDependencies

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
public void testCollectDependencies()
    throws Exception
{
    Artifact artifact = new DefaultArtifact( "ut.simple:artifact:extension:classifier:1.0" );
    // notice: extension and classifier not really used in this test...

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot( new Dependency( artifact, null ) );
    collectRequest.addRepository( newTestRepository() );

    CollectResult collectResult = system.collectDependencies( session, collectRequest );

    List<DependencyNode> nodes = collectResult.getRoot().getChildren();
    assertEquals( 2, nodes.size() );
    checkUtSimpleArtifactDependencies( nodes.get( 0 ).getDependency(), nodes.get( 1 ).getDependency() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:RepositorySystemTest.java

示例6: areAllDependenciesInReactor

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private boolean areAllDependenciesInReactor( Collection<MavenProject> projects, Collection<Dependency> dependencies )
{
    Set<String> projectKeys = getReactorProjectKeys( projects );

    for ( Dependency dependency : dependencies )
    {
        org.sonatype.aether.artifact.Artifact a = dependency.getArtifact();
        String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() );
        if ( !projectKeys.contains( key ) )
        {
            return false;
        }
    }

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

示例7: toDependency

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
public static Dependency toDependency( org.apache.maven.artifact.Artifact artifact,
                                       Collection<org.apache.maven.model.Exclusion> exclusions )
{
    if ( artifact == null )
    {
        return null;
    }

    Artifact result = toArtifact( artifact );

    List<Exclusion> excl = null;
    if ( exclusions != null )
    {
        excl = new ArrayList<Exclusion>( exclusions.size() );
        for ( org.apache.maven.model.Exclusion exclusion : exclusions )
        {
            excl.add( toExclusion( exclusion ) );
        }
    }

    return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:23,代码来源:RepositoryUtils.java

示例8: getDependencyTree

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
    try {
        CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepositories);
        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
        session.setDependencySelector(new AndDependencySelector(new OptionalDependencySelector(),
                new ScopeDependencySelector1(),
                new ExclusionDependencySelector()));
        DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(),
                new JavaEffectiveScopeCalculator(),
                new JavaDependencyContextRefiner());
        session.setDependencyGraphTransformer(transformer);
        CollectResult result = repositorySystem.collectDependencies(session, collectRequest);
        return result.getRoot();
    } catch (DependencyCollectionException e) {
        throw new MojoExecutionException("Cannot build project dependency tree", e);
    }
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:18,代码来源:Dependency30Helper.java

示例9: resolve

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
/**
 * List of transitive dependencies of the artifact.
 * @param root The artifact to work with
 * @param scope The scope to work with ("runtime", "test", etc.)
 * @param filter The dependency filter to work with
 * @return The list of dependencies
 * @throws DependencyResolutionException If can't fetch it
 */
public List<Artifact> resolve(final Artifact root,
    final String scope, final DependencyFilter filter)
    throws DependencyResolutionException {
    final List<Artifact> deps = new LinkedList<Artifact>();
    final RepositorySystem system = new RepositorySystemBuilder().build();
    deps.addAll(
        this.fetch(
            system,
            this.session(system),
            new DependencyRequest(
                this.request(new Dependency(root, scope)),
                filter
            )
        )
    );
    return deps;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:26,代码来源:Aether.java

示例10: resolve

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private void resolve( ResolveRequest resolveRequest )
{

    RepositorySystem system = newRepositorySystem();

    RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );

    org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
        resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );

    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot( new Dependency( artifact, "" ) );

    // add remote repositories
    for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
    {
        collectRequest.addRepository(
            new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
                                                                 remoteRepository.getUrl() ) );
    }
    collectRequest.setRequestContext( "project" );

    //collectRequest.addRepository( repo );

    try
    {
        CollectResult collectResult = system.collectDependencies( session, collectRequest );
        collectResult.getRoot().accept( resolveRequest.dependencyVisitor );
        log.debug( "test" );
    }
    catch ( DependencyCollectionException e )
    {
        log.error( e.getMessage(), e );
    }


}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:38,代码来源:Maven3DependencyTreeBuilder.java

示例11: parsePom

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
public void parsePom(InputStream inputStream) {
    try {
        MavenXpp3Reader reader = new MavenXpp3Reader();

        Model model = reader.read(inputStream);

        if (dependencies == null) {
            dependencies = new LinkedList<>();
        }
        if (repositories == null) {
            repositories = new LinkedList<>();
        }

        parent = model.getParent();
        setPropertiesFromModel(this, model);

        for (org.apache.maven.model.Dependency dependency : model.getDependencies()) {
            if (!"test".equalsIgnoreCase(dependency.getScope())) {
                dependencies.add(new Dependency(new DefaultArtifact(
                        dependency.getGroupId(),
                        dependency.getArtifactId(),
                        dependency.getClassifier(),
                        "jar",
                        dependency.getVersion()
                ), JavaScopes.RUNTIME));
            }
        }

        for (Repository remoteRepository : model.getRepositories()) {
            repositories.add(new RemoteRepository(remoteRepository.getId(), "default", remoteRepository.getUrl()));
        }
    } catch (Exception ex) {
        LOGGER.error("Error while reading POM file", ex);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:36,代码来源:PomInformation.java

示例12: installBundleFromRepository

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
@Override
public BundleInformation installBundleFromRepository(String moduleId, boolean startBundle) {
    try {
        return installFromRepository(new Dependency(new DefaultArtifact(moduleId), JavaScopes.RUNTIME), startBundle);
    } catch (RepositoryException | IOException | BundleException e) {
        throw new MotechException("Unable to install module from repository " + moduleId, e);
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:9,代码来源:ModuleAdminServiceImpl.java

示例13: parseDependencyVersion

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private String parseDependencyVersion(Dependency dependency, MavenRepositorySystemSession mvnRepository, RepositorySystem system,
                                      RemoteRepository remoteRepository, PomInformation pomInformation) throws ArtifactResolutionException {
    String parsedVersion;
    String version = dependency.getArtifact().getVersion();

    if (StringUtils.isEmpty(version)) {
        parsedVersion = "[0,)";
    } else {
        Set<String> properties = getPropertiesFromString(version);

        for (String propertyName : properties) {
            String parsedProperty = getPropertyFromPom(parsePropertyName(propertyName), mvnRepository, system,
                    remoteRepository, pomInformation);

            if (parsedProperty == null) {
                LOGGER.error("The property: {} used in dependency: {} cannot be found in pom " +
                                "and its parents. For this dependency the latest version will be used",
                        propertyName, dependency.getArtifact().getArtifactId());
                version = "[0,)";
                break;
            }

            version = StringUtils.replace(version, propertyName, parsedProperty);
        }

        parsedVersion = version;
    }

    return parsedVersion;
}
 
开发者ID:motech,项目名称:motech,代码行数:31,代码来源:ModuleAdminServiceImpl.java

示例14: buildFeatureStrNoVersion

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
private String buildFeatureStrNoVersion(Dependency dependency) {
    StringBuilder featureId = new StringBuilder(dependency.getArtifact().getGroupId());
    featureId = featureId.append(":").append(dependency.getArtifact().getArtifactId());
    featureId = featureId.append(":").append(dependency.getArtifact().getVersion());
    final int lastColonIndex = featureId.lastIndexOf(":");

    return featureId.substring(0, lastColonIndex);
}
 
开发者ID:motech,项目名称:motech,代码行数:9,代码来源:ModuleAdminServiceImpl.java

示例15: shouldParsePomFile

import org.sonatype.aether.graph.Dependency; //导入依赖的package包/类
@Test
public void shouldParsePomFile() throws IOException {
    Properties properties = new Properties();
    properties.put("test.properties", "test");
    properties.put("modules.root.dir", "${basedir}/../..");
    // Because we use <version> and <groupId> tags in our tested pom, the parsing method should add this as properties
    properties.put("project.version", "0-27-SNAPSHOT");
    properties.put("project.groupId", "testGroupId");

    Dependency dependency = new Dependency(new DefaultArtifact(
            "${project.groupId}",
            "motech-osgi-platform",
            "",
            "jar",
            "${project.version}"
    ), JavaScopes.RUNTIME);

    try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("pom/pom.xml")) {
        pomInformation = new PomInformation();
        pomInformation.parsePom(inputStream);
    }

    assertEquals(properties, pomInformation.getProperties());

    Parent parentFromParsing = pomInformation.getParent();
    assertEquals("0.27-SNAPSHOT", parentFromParsing.getVersion());
    assertEquals("motech", parentFromParsing.getArtifactId());
    assertEquals("org.motechproject", parentFromParsing.getGroupId());

    assertTrue(pomInformation.getDependencies().contains(dependency));
}
 
开发者ID:motech,项目名称:motech,代码行数:32,代码来源:PomInformationTest.java


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