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


Java Dependency類代碼示例

本文整理匯總了Java中org.eclipse.aether.graph.Dependency的典型用法代碼示例。如果您正苦於以下問題:Java Dependency類的具體用法?Java Dependency怎麽用?Java Dependency使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: resolveArtifacts

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
/**
 * Given a set of coordinates, resolves the transitive dependencies, and then returns the root
 * node to the resolved dependency graph. The root node is a sentinel node with direct edges
 * on the artifacts users declared explicit on.
 */
public DependencyNode resolveArtifacts(List<String> artifactCoords) {
  List<Dependency> directDependencies = createDirectDependencyList(artifactCoords);
  CollectRequest collectRequest =
      aether.createCollectRequest(directDependencies, managedDependencies);

  DependencyRequest dependencyRequest = aether.createDependencyRequest(collectRequest);
  DependencyResult dependencyResult;
  try {
    dependencyResult = aether.requestDependencyResolution(dependencyRequest);
  } catch (DependencyResolutionException e) {
    //FIXME(petros): This is very fragile. If one artifact doesn't resolve, no artifacts resolve.
    logger.warning("Unable to resolve transitive dependencies: " + e.getMessage());
    return null;
  }
  // root is a sentinel node whose direct children are the requested artifacts.
  return dependencyResult.getRoot();
}
 
開發者ID:bazelbuild,項目名稱:migration-tooling,代碼行數:23,代碼來源:ArtifactResolver.java

示例2: resolveArtifacts

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private Stream<? extends Artifact> resolveArtifacts(String coordinator) {
    log.debug("resolving {}", coordinator);
    try {
        // build resolve filters
        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot(new Dependency(new DefaultArtifact(coordinator), JavaScopes.COMPILE));
        DependencyRequest dependencyRequest = new DependencyRequest(
                collectRequest,
                DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.RUNTIME)
        );
        // resolve
        final List<Artifact> artifacts = teslaAether.resolveArtifacts(dependencyRequest);
        if (CollectionUtils.isEmpty(artifacts)) {
            throw new DependencyResolveException(String.format("cannot resolve %s", coordinator));
        }
        return artifacts.stream();
    } catch (DependencyResolutionException e) {
        final String message = String.format("cannot resolve %s : %s", coordinator, e.getLocalizedMessage());
        throw new DependencyResolveException(message, e);
    }
}
 
開發者ID:dshell-io,項目名稱:dshell,代碼行數:22,代碼來源:DefaultDependencyResolver.java

示例3: collectDependencyArtifacts

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private List<Artifact> collectDependencyArtifacts(List<Dependency> dependencies)
        throws RepositoryException {
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setDependencies(dependencies);
    DependencyNode node = repositorySystem
        .collectDependencies(repositorySystemSession, collectRequest)
        .getRoot();

    DependencyRequest dependencyRequest = new DependencyRequest();
    dependencyRequest.setRoot(node);
    // setFilter() allows null arguments.
    dependencyRequest.setFilter(
        AndDependencyFilter.newInstance(
            new ScopeDependencyFilter(Arrays.asList(JavaScopes.COMPILE, JavaScopes.RUNTIME), null),
            CloudKeeperBundleFilter.INSTANCE
        )
    );
    repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);

    PreorderNodeListGenerator nodeListGenerator = new PreorderNodeListGenerator();
    node.accept(nodeListGenerator);
    return nodeListGenerator.getArtifacts(false);
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:24,代碼來源:DummyAetherRepository.java

示例4: loadDependencyDeclarations

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private List<MutableBundle> loadDependencyDeclarations(List<String> dependencies)
        throws JAXBException, RepositoryException, XMLStreamException {
    List<Dependency> aetherGraphDependencies = new ArrayList<>(dependencies.size());
    for (String dependency: dependencies) {
        aetherGraphDependencies.add(
            new Dependency(new DefaultArtifact(GROUP_ID, dependency, "ckbundle", VERSION.toString()), "compile")
        );
    }
    List<Artifact> bundleArtifacts = collectDependencyArtifacts(aetherGraphDependencies);

    XMLInputFactory xmlInputFactory = XMLInputFactory.newFactory();
    List<MutableBundle> bundles = new ArrayList<>(bundleArtifacts.size());
    for (Artifact bundleArtifact: bundleArtifacts) {
        MutableBundle bundle = Bundles.loadBundle(jaxbContext, xmlInputFactory, bundleArtifact);
        bundles.add(bundle);
    }
    return bundles;
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:19,代碼來源:DummyAetherRepository.java

示例5: addDependencyManagement

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
public void addDependencyManagement(DependencyManagement dependencyManagement) {
	for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement
			.getDependencies()) {
		List<Exclusion> aetherExclusions = new ArrayList<Exclusion>();
		for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
				.getExclusions()) {
			aetherExclusions.add(new Exclusion(exclusion.getGroupId(),
					exclusion.getArtifactId(), "*", "*"));
		}
		Dependency aetherDependency = new Dependency(
				new DefaultArtifact(dependency.getGroupId(),
						dependency.getArtifactId(), "jar", dependency.getVersion()),
				JavaScopes.COMPILE, false, aetherExclusions);
		this.managedDependencies.add(0, aetherDependency);
		this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
				aetherDependency);
	}
	this.dependencyManagement = this.dependencyManagement == null
			? dependencyManagement
			: new CompositeDependencyManagement(dependencyManagement,
					this.dependencyManagement);
	this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
			this.dependencyManagement);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:25,代碼來源:DependencyResolutionContext.java

示例6: resolve

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
@Override
public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) {
	List<Exclusion> exclusions = createExclusions(args);
	List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
	try {
		List<File> files = resolve(dependencies);
		List<URI> uris = new ArrayList<URI>(files.size());
		for (File file : files) {
			uris.add(file.toURI());
		}
		return uris.toArray(new URI[uris.size()]);
	}
	catch (Exception ex) {
		throw new DependencyResolutionFailedException(ex);
	}
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:AetherGrapeEngine.java

示例7: resolve

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
/**
 * Builds the DependencyRequest, calls RepositorySystem.resolveDependencies and checks for any error.
 * 
 * @return DependencyResult the returned result from resolveDependencies
 * */
public DependencyResult resolve() throws Exception{
	Dependency dependency=settings.getDependency().createDependency();
	
	CollectRequest collectRequest = new CollectRequest();
	collectRequest.setRoot(dependency);
	collectRequest.setRepositories(settings.createRepositories());

	DependencyRequest dependencyRequest=new DependencyRequest();
	dependencyRequest.setCollectRequest(collectRequest);
   
	DependencyResult result=repositorySystem.resolveDependencies(session, dependencyRequest);
	
	if (result.getCollectExceptions()!=null && result.getCollectExceptions().size()>0){
		throw result.getCollectExceptions().get(0);//return the first one. TODO: should return an exception wrapping them all
	}
	
	return result;
}
 
開發者ID:microsofia,項目名稱:microsofia-boot,代碼行數:24,代碼來源:DependencyResolver.java

示例8: addDependencies

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private void addDependencies(Function<Artifact, Boolean> duplicateFilter, Optional<String> extension, Optional<String> classifier) {
    List<Dependency> dependencies = input.stream()
            .map(DependencyNode::getDependency)
            .collect(Collectors.toList());

    Set<String> existingGavs = dependencies.stream()
            .map(Dependency::getArtifact)
            .filter(duplicateFilter::apply)
            .map(this::toGav)
            .collect(Collectors.toSet());

    List<DependencyNode> newNodes = input.stream()
            .filter(n -> !existingGavs.contains(toGav(n.getDependency().getArtifact())))
            .map(n -> createNode(n, extension, classifier))
            .collect(Collectors.toList());
    output.addAll(newNodes);
}
 
開發者ID:wildfly-swarm,項目名稱:wildfly-swarm,代碼行數:18,代碼來源:ExtraArtifactsHandler.java

示例9: assertDependencyUpdated

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private void assertDependencyUpdated(final Artifact artifact, final String targetProject,
		final String expectedVersion, final String expectedBuildNumber) throws Exception {
	final RepositorySystemSession session = newRepositorySystemSession();
	final ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
	descriptorRequest.setArtifact(artifact);

	final ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor(session, descriptorRequest);

	Dependency targetDependency = null;
	for (final Dependency dep : descriptorResult.getDependencies()) {
		if (targetProject.equals(dep.getArtifact().getArtifactId())) {
			targetDependency = dep;
			break;
		}
	}

	assertNotNull(format("No dependency found with artifact-id %s", targetProject), targetDependency);
	assertEquals(format("%s%s", expectedVersion, expectedBuildNumber), targetDependency.getArtifact().getVersion());
}
 
開發者ID:SourcePond,項目名稱:release-maven-plugin-parent,代碼行數:20,代碼來源:NestedModulesBaseTest.java

示例10: getAllDependencies

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private ImmutableSet<ArtifactCoordinates> getAllDependencies(Artifact artifact, String scope)
		throws DependencyCollectionException, DependencyResolutionException {
	Dependency artifactAsDependency = new Dependency(artifact, scope);
	CollectRequest collectRequest = new CollectRequest(artifactAsDependency, singletonList(mavenCentral));
	DependencyNode dependencyRoot =
			repositorySystem.collectDependencies(repositorySystemSession, collectRequest).getRoot();

	DependencyRequest dependencyRequest = new DependencyRequest(dependencyRoot, null);
	repositorySystem.resolveDependencies(repositorySystemSession, dependencyRequest);

	PreorderNodeListGenerator dependencies = new PreorderNodeListGenerator();
	dependencyRoot.getChildren().forEach(node -> node.accept(dependencies));

	ImmutableSet.Builder<ArtifactCoordinates> dependencyCoordinates = ImmutableSet.builder();
	dependencies.getArtifacts(true).stream().map(ArtifactCoordinates::from).forEach(dependencyCoordinates::add);
	return dependencyCoordinates.build();
}
 
開發者ID:CodeFX-org,項目名稱:jdeps-wall-of-shame,代碼行數:18,代碼來源:MavenCentral.java

示例11: getRejectedDependencies

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
public Set<Artifact> getRejectedDependencies(Artifact artifact) throws ArtifactDescriptorException {
    Set<Dependency> allDependencies = getAllDependencies(artifact);

    Set<Artifact> rejected = new HashSet<>();
    for (Dependency dependency : allDependencies) {
        Scope scope = Scope.compile;
        try {
            scope = Scope.valueOf(dependency.getScope().toLowerCase());
        } catch (Throwable ignored) { }

        if (ignoredScopes.contains(scope)) {
            continue;
        }

        if ((dependency.getArtifact().isSnapshot() && rejectSnapshots) || notAllowed(allowedArtifacts, dependency)) {
            rejected.add(dependency.getArtifact());
        }
    }

    return rejected;
}
 
開發者ID:flipkart-incubator,項目名稱:Poseidon,代碼行數:22,代碼來源:Cadfael.java

示例12: mavenDependencyToDependency

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
private Dependency mavenDependencyToDependency(
		org.apache.maven.model.Dependency dep) {
	Artifact art = new DefaultArtifact(dep.getGroupId(),
		dep.getArtifactId(),
		dep.getClassifier(),
		dep.getType(),
		dep.getVersion());
	Collection<Exclusion> excls = new HashSet<Exclusion>();
	for (org.apache.maven.model.Exclusion excl :
		dep.getExclusions()) {
		excls.add(mavenExclusionToExclusion(excl));
	}
	return new Dependency(art,
		dep.getScope(),
		new Boolean(dep.isOptional()),
		excls);
}
 
開發者ID:NixOS,項目名稱:mvn2nix-maven-plugin,代碼行數:18,代碼來源:Mvn2NixMojo.java

示例13: populateResult

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
@Override
public void populateResult(RepositorySystemSession session,
	ArtifactDescriptorResult result,
	Model model) {
	super.populateResult(session, result, model);
	Parent parent = model.getParent();
	if (parent != null) {
		DefaultArtifact art =
			new DefaultArtifact(parent.getGroupId(),
				parent.getArtifactId(),
				"pom",
				parent.getVersion());
		Dependency dep = new Dependency(art, "compile");
		result.addDependency(dep);
	}
}
 
開發者ID:NixOS,項目名稱:mvn2nix-maven-plugin,代碼行數:17,代碼來源:ParentPOMPropagatingArtifactDescriptorReaderDelegate.java

示例14: transitiveDependencies

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
public static Set<Artifact> transitiveDependencies(Artifact artifact) {

    RepositorySystem system = newRepositorySystem();

    RepositorySystemSession session = newRepositorySystemSession(system);

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

    CollectResult collectResult = null;
    try {
      collectResult = system.collectDependencies(session, collectRequest);
    } catch (DependencyCollectionException e) {
      throw new RuntimeException(e);
    }

    PreorderNodeListGenerator visitor = new PreorderNodeListGenerator();
    collectResult.getRoot().accept(visitor);

    return ImmutableSet.copyOf(
      visitor.getNodes().stream()
        .filter(d -> !d.getDependency().isOptional())
        .map(DependencyNode::getArtifact)
        .collect(Collectors.toList()));
  }
 
開發者ID:pgr0ss,項目名稱:bazel-deps,代碼行數:27,代碼來源:Maven.java

示例15: getDependencies

import org.eclipse.aether.graph.Dependency; //導入依賴的package包/類
public List<Artifact> getDependencies(String groupId, String artifactId, String extension, String version) throws Exception {
  Artifact artifact = new DefaultArtifact(groupId, artifactId, extension, version);
  CollectRequest collectRequest = new CollectRequest();
  collectRequest.setRoot(new Dependency( artifact, ""));
  collectRequest.setRepositories(Collections.emptyList());
  DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE));
  DependencyResult dependencyResult = system.resolveDependencies(session, dependencyRequest);
  List<Artifact> dependencies = new ArrayList<>();
  for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
    if (!artifactResult.isResolved()) {
      throw new Exception("Could not resolve artifact " + artifactResult.getRequest().getArtifact());
    }
    dependencies.add(artifactResult.getArtifact());
  }
  return dependencies;
}
 
開發者ID:vert-x3,項目名稱:vertx-maven-service-factory,代碼行數:17,代碼來源:AetherHelper.java


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