@Override public ArtifactSpec resolve(final ArtifactSpec spec) { if (spec.file != null) { return spec; } final Iterator<ResolvedDependency> iterator = doResolve(new HashSet<>(Collections.singletonList(spec))).iterator(); if (iterator.hasNext()) { spec.file = iterator.next() .getModuleArtifacts() .iterator().next() .getFile(); return spec; } return null; }
private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) { final Configuration config = this.project.getConfigurations().detachedConfiguration(); final DependencySet dependencySet = config.getDependencies(); deps.forEach(spec -> { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); d.getExcludeRules().add(new DefaultExcludeRule()); dependencySet.add(d); }); return config.getResolvedConfiguration().getFirstLevelModuleDependencies(); }
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) { Set<ResolvedDependency> matches = new LinkedHashSet<ResolvedDependency>(); for (DependencyGraphNodeResult node : getFirstLevelNodes(dependencySpec)) { matches.add(node.getPublicView()); } return matches; }
public Set<ResolvedDependency> getAllModuleDependencies() { Set<ResolvedDependency> resolvedElements = new LinkedHashSet<ResolvedDependency>(); Deque<ResolvedDependency> workQueue = new LinkedList<ResolvedDependency>(); workQueue.addAll(loadTransientGraphResults(selectedArtifacts).getRootNode().getPublicView().getChildren()); while (!workQueue.isEmpty()) { ResolvedDependency item = workQueue.removeFirst(); if (resolvedElements.add(item)) { final Set<ResolvedDependency> children = item.getChildren(); if (children != null) { workQueue.addAll(children); } } } return resolvedElements; }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies() { try { return lenientConfiguration.getFirstLevelModuleDependencies(); } catch (Throwable e) { throw wrapException(e, resolveContext); } }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) { try { return lenientConfiguration.getFirstLevelModuleDependencies(dependencySpec); } catch (Throwable e) { throw wrapException(e, resolveContext); } }
@Override public Set<ResolvedDependency> getAllModuleDependencies() { try { return lenientConfiguration.getAllModuleDependencies(); } catch (Throwable e) { throw wrapException(e, resolveContext); } }
public Set<ResolvedDependency> getFirstLevelModuleDependencies() throws ResolveException { try { return resolvedConfiguration.getFirstLevelModuleDependencies(); } catch (Throwable e) { throw wrapException(e, configuration); } }
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) throws ResolveException { try { return resolvedConfiguration.getFirstLevelModuleDependencies(dependencySpec); } catch (Throwable e) { throw wrapException(e, configuration); } }
public Set<ResolvedArtifact> getAllModuleArtifacts() { if (allModuleArtifactsCache == null) { Set<ResolvedArtifact> allArtifacts = new LinkedHashSet<ResolvedArtifact>(); allArtifacts.addAll(getModuleArtifacts()); for (ResolvedDependency childResolvedDependency : getChildren()) { allArtifacts.addAll(childResolvedDependency.getAllModuleArtifacts()); } allModuleArtifactsCache = allArtifacts; } return allModuleArtifactsCache; }
@Override public ResolvedArtifactSet getArtifactsForIncomingEdge(DependencyGraphNodeResult parent) { if (!parents.contains(parent)) { throw new InvalidUserDataException("Provided dependency (" + parent + ") must be a parent of: " + this); } return CompositeArtifactSet.of(parentArtifacts.get((ResolvedDependency) parent)); }
public Set<ResolvedArtifact> getAllArtifacts(ResolvedDependency parent) { if (allArtifactsCache.get(parent) == null) { Set<ResolvedArtifact> allArtifacts = new LinkedHashSet<ResolvedArtifact>(); allArtifacts.addAll(getArtifacts(parent)); for (ResolvedDependency childResolvedDependency : getChildren()) { for (ResolvedDependency childParent : childResolvedDependency.getParents()) { allArtifacts.addAll(childResolvedDependency.getAllArtifacts(childParent)); } } allArtifactsCache.put(parent, allArtifacts); } return allArtifactsCache.get(parent); }
public GradleArtifact(GradleArtifact parent, ResolvedDependency gradleArtifact) { this.parent = parent; children = new HashSet<>(); name = gradleArtifact.getModule().getId().getName(); group = gradleArtifact.getModule().getId().getGroup(); version = gradleArtifact.getModule().getId().getVersion(); addChildren(gradleArtifact); }
private void addChildren(ResolvedDependency gradleArtifact) { gradleArtifact.getChildren().forEach(c -> { GradleArtifact child = new GradleArtifact(this, c); children.add(child); } ); }
public Set<ResolvedArtifact> getParentArtifacts(ResolvedDependency parent) { if (!parents.contains(parent)) { throw new InvalidUserDataException("Provided dependency (" + parent + ") must be a parent of: " + this); } Set<ResolvedArtifact> artifacts = parentArtifacts.get(parent); return artifacts == null ? Collections.<ResolvedArtifact>emptySet() : artifacts; }
public void addParentSpecificArtifacts(ResolvedDependency parent, Set<ResolvedArtifact> artifacts) { Set<ResolvedArtifact> parentArtifacts = this.parentArtifacts.get(parent); if (parentArtifacts == null) { parentArtifacts = new TreeSet<ResolvedArtifact>(new ResolvedArtifactComparator()); this.parentArtifacts.put(parent, parentArtifacts); } parentArtifacts.addAll(artifacts); moduleArtifacts.addAll(artifacts); }
public DefaultResolvedArtifact(ResolvedModuleVersion owner, Factory<ResolvedDependency> ownerSource, IvyArtifactName artifact, Factory<File> artifactSource, long id) { this.ownerSource = ownerSource; this.owner = owner; this.artifact = artifact; this.id = id; this.artifactSource = artifactSource; }
public ResolvedDependency getResolvedDependency() { DeprecationLogger.nagUserOfDeprecated( "ResolvedArtifact.getResolvedDependency()", "For version info use ResolvedArtifact.getModuleVersion(), to access the dependency graph use ResolvedConfiguration.getFirstLevelModuleDependencies()" ); //resolvedDependency is expensive so lazily create it return ownerSource.create(); }
private void walk(final boolean top, ResolvedDependency dep) { Set<ResolvedArtifact> artifacts = dep.getModuleArtifacts(); for (ResolvedArtifact each : artifacts) { String[] parts = dep.getName().split(":"); String groupId = parts[0]; String artifactId = parts[1]; String version = parts[2]; this.tool.dependency("compile", groupId, artifactId, version, each.getExtension(), each.getClassifier(), each.getFile(), top); } dep.getChildren().forEach(d -> walk(false, d)); }
protected static Set<String> getNonCheckstyleDeps(final Configuration pConfiguration) { Set<String> result = new HashSet<>(); for (ResolvedDependency dep : pConfiguration.getResolvedConfiguration().getFirstLevelModuleDependencies()) { if (!CreateJarEclipseTask.isCheckstyle(dep)) { result.add(dep.getName()); for (final ResolvedDependency rd : dep.getChildren()) { result.add(rd.getName()); } } } return result; }
/** * Scan the dependencies of the specified configurations and return a list of File objects for each dependency. * Resolves the configurations if they are still unresolved. * * @param pTask the calling task * @param pDepConfig the current dependency configuration * @return list of files */ public static Set<File> getPublishedDependencyLibs(@Nonnull final Task pTask, @Nonnull final DependencyConfig pDepConfig) { Set<File> result = new HashSet<>(); Configuration cfg = new ClasspathBuilder(pTask.getProject()).buildMainRuntimeConfiguration(pDepConfig); for (ResolvedDependency dep : cfg.getResolvedConfiguration().getFirstLevelModuleDependencies()) { if (!isCheckstyle(dep)) { for (ResolvedArtifact artifact : dep.getAllModuleArtifacts()) { result.add(artifact.getFile()); } } } return result; }
private List<JApiCmpWorkerAction.Archive> inferArchives(FileCollection fc) { if (fc instanceof Configuration) { final List<JApiCmpWorkerAction.Archive> archives = new ArrayList<>(); Set<ResolvedDependency> firstLevelModuleDependencies = ((Configuration) fc).getResolvedConfiguration().getFirstLevelModuleDependencies(); for (ResolvedDependency moduleDependency : firstLevelModuleDependencies) { collectArchives(archives, moduleDependency); } return archives; } return toArchives(fc); }
private void collectArchives(final List<JApiCmpWorkerAction.Archive> archives, ResolvedDependency resolvedDependency) { String version = resolvedDependency.getModule().getId().getVersion(); archives.add(new JApiCmpWorkerAction.Archive(resolvedDependency.getAllModuleArtifacts().iterator().next().getFile(), version)); for (ResolvedDependency dependency : resolvedDependency.getChildren()) { collectArchives(archives, dependency); } }
public Set<ResolvedDependency> getFirstLevelModuleDependencies() { return loadTransientGraphResults(selectedArtifacts).getRootNode().getPublicView().getChildren(); }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies() { return Collections.emptySet(); }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) throws ResolveException { return Collections.emptySet(); }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies() throws ResolveException { throw wrapException(e, configuration); }
@Override public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) throws ResolveException { throw wrapException(e, configuration); }
public Set<ResolvedDependency> getFirstLevelModuleDependencies() throws ResolveException { rethrowFailure(); return configuration.getFirstLevelModuleDependencies(); }
public Set<ResolvedDependency> getFirstLevelModuleDependencies(Spec<? super Dependency> dependencySpec) throws ResolveException { rethrowFailure(); return configuration.getFirstLevelModuleDependencies(dependencySpec); }
@Override public ResolvedDependency getPublicView() { return this; }
public Set<ResolvedDependency> getChildren() { return ImmutableSet.<ResolvedDependency>copyOf(children); }
public Set<ResolvedArtifact> getParentArtifacts(ResolvedDependency parent) { return sort(getArtifactsForIncomingEdge((DependencyGraphNodeResult) parent)); }
public Set<ResolvedArtifact> getArtifacts(ResolvedDependency parent) { return getParentArtifacts(parent); }