private void collectDependens(Set<ResolvedDependencyResult> compileOnlyDependencySet) { for (ResolvedDependencyResult resolvedDependencyResult : compileOnlyDependencySet) { compileDependencies.add(resolvedDependencyResult.getSelected() .getModuleVersion() .getGroup() + "-" + resolvedDependencyResult.getSelected() .getModuleVersion() .getName()); Set<ResolvedDependencyResult> resolvedDependencyResults = new HashSet<ResolvedDependencyResult>(); if (null != resolvedDependencyResult.getSelected().getDependencies()) { for (DependencyResult sub : resolvedDependencyResult.getSelected() .getDependencies()) { if (sub instanceof ResolvedDependencyResult) { resolvedDependencyResults.add((ResolvedDependencyResult) sub); } } } collectDependens(resolvedDependencyResults); } }
public void visitOutgoingEdges(Long fromComponent, Collection<? extends DependencyResult> dependencies) { for (DependencyResult d : dependencies) { DefaultResolvedComponentResult from = modules.get(fromComponent); org.gradle.api.artifacts.result.DependencyResult dependency; if (d.getFailure() != null) { dependency = dependencyResultFactory.createUnresolvedDependency(d.getRequested(), from, d.getReason(), d.getFailure()); } else { DefaultResolvedComponentResult selected = modules.get(d.getSelected()); dependency = dependencyResultFactory.createResolvedDependency(d.getRequested(), from, selected); selected.addDependent((ResolvedDependencyResult) dependency); } from.addDependency(dependency); } }
public ResolvedDependencyResult createResolvedDependency(ComponentSelector requested, ResolvedComponentResult from, DefaultResolvedComponentResult selected) { List<Object> key = asList(requested, from, selected); if (!resolvedDependencies.containsKey(key)) { resolvedDependencies.put(key, new DefaultResolvedDependencyResult(requested, selected, from)); } return resolvedDependencies.get(key); }
private void eachElement(ResolvedComponentResult node, Action<? super ResolvedComponentResult> moduleAction, Action<? super DependencyResult> dependencyAction, Set<ResolvedComponentResult> visited) { if (!visited.add(node)) { return; } moduleAction.execute(node); for (DependencyResult d : node.getDependencies()) { dependencyAction.execute(d); if (d instanceof ResolvedDependencyResult) { eachElement(((ResolvedDependencyResult) d).getSelected(), moduleAction, dependencyAction, visited); } } }
@Override public boolean isSatisfiedBy(DependencyResult candidate) { if (candidate instanceof ResolvedDependencyResult) { return matchesRequested(candidate) || matchesSelected((ResolvedDependencyResult) candidate); } else { return matchesRequested(candidate); } }
private boolean matchesSelected(ResolvedDependencyResult candidate) { ComponentIdentifier selected = candidate.getSelected().getId(); if (moduleIdentifier != null && selected instanceof ModuleComponentIdentifier) { ModuleComponentIdentifier selectedModule = (ModuleComponentIdentifier) selected; return selectedModule.getGroup().equals(moduleIdentifier.getGroup()) && selectedModule.getModule().equals(moduleIdentifier.getName()); } return false; }
@Override public boolean isSatisfiedBy(DependencyResult candidate) { //The matching is very simple at the moment but it should solve majority of cases. //It operates using String#contains and it tests either requested or selected module. if (candidate instanceof ResolvedDependencyResult) { return matchesRequested(candidate) || matchesSelected((ResolvedDependencyResult) candidate); } else { return matchesRequested(candidate); } }
public Collection<RenderableDependency> prepare(Collection<DependencyResult> input, VersionSelectorScheme versionSelectorScheme, VersionComparator versionComparator) { LinkedList<RenderableDependency> out = new LinkedList<RenderableDependency>(); List<DependencyEdge> dependencies = CollectionUtils.collect(input, new Transformer<DependencyEdge, DependencyResult>() { @Override public DependencyEdge transform(DependencyResult result) { if (result instanceof UnresolvedDependencyResult) { return new UnresolvedDependencyEdge((UnresolvedDependencyResult) result); } else { return new ResolvedDependencyEdge((ResolvedDependencyResult) result); } } }); Collection<DependencyEdge> sorted = DependencyResultSorter.sort(dependencies, versionSelectorScheme, versionComparator); //remember if module id was annotated HashSet<ComponentIdentifier> annotated = new HashSet<ComponentIdentifier>(); RequestedVersion current = null; for (DependencyEdge dependency : sorted) { //add description only to the first module if (annotated.add(dependency.getActual())) { //add a heading dependency with the annotation if the dependency does not exist in the graph if (!dependency.getRequested().matchesStrictly(dependency.getActual())) { out.add(new DependencyReportHeader(dependency)); current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null); out.add(current); } else { current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), getReasonDescription(dependency.getReason())); out.add(current); } } else if (!current.getRequested().equals(dependency.getRequested())) { current = new RequestedVersion(dependency.getRequested(), dependency.getActual(), dependency.isResolvable(), null); out.add(current); } current.addChild(dependency); } return out; }
@Override public Set<RenderableDependency> getChildren() { Set<RenderableDependency> out = new LinkedHashSet<RenderableDependency>(); for (DependencyResult d : dependency.getSelected().getDependencies()) { if (d instanceof UnresolvedDependencyResult) { out.add(new RenderableUnresolvedDependencyResult((UnresolvedDependencyResult) d)); } else { out.add(new RenderableDependencyResult((ResolvedDependencyResult) d)); } } return out; }
@Override public Set<RenderableDependency> getChildren() { Set<RenderableDependency> out = new LinkedHashSet<RenderableDependency>(); for (DependencyResult d : module.getDependencies()) { if (d instanceof UnresolvedDependencyResult) { out.add(new RenderableUnresolvedDependencyResult((UnresolvedDependencyResult) d)); } else { out.add(new RenderableDependencyResult((ResolvedDependencyResult) d)); } } return out; }
@Override public Set<RenderableDependency> getChildren() { Map<ComponentIdentifier, RenderableDependency> children = new LinkedHashMap<ComponentIdentifier, RenderableDependency>(); for (ResolvedDependencyResult dependent : module.getDependents()) { InvertedRenderableModuleResult child = new InvertedRenderableModuleResult(dependent.getFrom()); if (!children.containsKey(child.getId())) { children.put(child.getId(), child); } } return new LinkedHashSet<RenderableDependency>(children.values()); }
public List<ResolvedDependencyInfo> resolve(List<DependencyResult> dependencyResults, boolean mainBundle) { Multimap<String, ResolvedDependencyInfo> dependenciesMap = LinkedHashMultimap.create(); // Instead of using the official flat dependency treatment, you can use your own tree dependence; For application dependencies, we only take compile dependencies Set<ModuleVersionIdentifier> directDependencies = new HashSet<ModuleVersionIdentifier>(); Set<String> resolveSets = new HashSet<>(); for (DependencyResult dependencyResult : dependencyResults) { if (dependencyResult instanceof ResolvedDependencyResult) { ModuleVersionIdentifier moduleVersion = ((ResolvedDependencyResult)dependencyResult).getSelected() .getModuleVersion(); CircleDependencyCheck circleDependencyCheck = new CircleDependencyCheck(moduleVersion); if (!directDependencies.contains(moduleVersion)) { directDependencies.add(moduleVersion); resolveDependency(null, ((ResolvedDependencyResult)dependencyResult).getSelected(), artifacts, variantDeps, 0, circleDependencyCheck, circleDependencyCheck.getRootDependencyNode(), dependenciesMap, resolveSets); } } } List<ResolvedDependencyInfo> mainResolvdInfo = resolveAllDependencies(dependenciesMap); if (mainBundle) { for (ResolvedDependencyInfo resolvedDependencyInfo : mainResolvdInfo) { addMainDependencyInfo(resolvedDependencyInfo); } } return mainResolvdInfo; }
public static boolean isAwbDependency(DependencyResult dependencyResult, Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) { if (dependencyResult instanceof ResolvedDependencyResult) { ResolvedDependencyResult resolvedDependencyResult = (ResolvedDependencyResult)dependencyResult; ModuleVersionIdentifier moduleVersionIdentifier = resolvedDependencyResult.getSelected().getModuleVersion(); List<ResolvedArtifact> resolvedArtifacts = artifacts.get(moduleVersionIdentifier); if (resolvedArtifacts.size() > 0) { ResolvedArtifact resolvedArtifact = resolvedArtifacts.get(0); return ("awb".equals(resolvedArtifact.getType())); } } return false; }
public boolean isSatisfiedBy(DependencyResult candidate) { if (candidate instanceof ResolvedDependencyResult) { return matchesRequested(candidate) || matchesSelected((ResolvedDependencyResult) candidate); } else { return matchesRequested(candidate); } }
public boolean isSatisfiedBy(DependencyResult candidate) { //The matching is very simple at the moment but it should solve majority of cases. //It operates using String#contains and it tests either requested or selected module. if (candidate instanceof ResolvedDependencyResult) { return matchesRequested(candidate) || matchesSelected((ResolvedDependencyResult) candidate); } else { return matchesRequested(candidate); } }
public Set<RenderableDependency> getChildren() { Set<RenderableDependency> out = new LinkedHashSet<RenderableDependency>(); for (DependencyResult d : dependency.getSelected().getDependencies()) { if (d instanceof UnresolvedDependencyResult) { out.add(new RenderableUnresolvedDependencyResult((UnresolvedDependencyResult) d)); } else { out.add(new RenderableDependencyResult((ResolvedDependencyResult) d)); } } return out; }
public Set<RenderableDependency> getChildren() { Set<RenderableDependency> out = new LinkedHashSet<RenderableDependency>(); for (DependencyResult d : module.getDependencies()) { if (d instanceof UnresolvedDependencyResult) { out.add(new RenderableUnresolvedDependencyResult((UnresolvedDependencyResult) d)); } else { out.add(new RenderableDependencyResult((ResolvedDependencyResult) d)); } } return out; }
public Set<RenderableDependency> getChildren() { Map<ComponentIdentifier, RenderableDependency> children = new LinkedHashMap<ComponentIdentifier, RenderableDependency>(); for (ResolvedDependencyResult dependent : module.getDependents()) { InvertedRenderableModuleResult child = new InvertedRenderableModuleResult(dependent.getFrom()); if (!children.containsKey(child.getId())) { children.put(child.getId(), child); } } return new LinkedHashSet<RenderableDependency>(children.values()); }
public Set<ResolvedDependencyResult> getDependents() { return Collections.unmodifiableSet(dependents); }
public DefaultResolvedComponentResult addDependent(ResolvedDependencyResult dependent) { this.dependents.add(dependent); return this; }
private boolean matchesSelected(ResolvedDependencyResult candidate) { ModuleVersionIdentifier selected = candidate.getSelected().getModuleVersion(); String selectedCandidate = selected.getGroup() + ":" + selected.getModule() + ":" + selected.getVersion(); return selectedCandidate.contains(stringNotation); }
public RenderableDependencyResult(ResolvedDependencyResult dependency) { this.dependency = dependency; }
public ResolvedDependencyEdge(ResolvedDependencyResult dependency) { this.dependency = dependency; }
private void collectLibraryJars(LibVariantContext libVariantContext) { //TODO NPE protect Set<DependencyResult> providedDependencySet = getDependencyResults(libVariantContext, "providedCompile"); Set<DependencyResult> compileDependencySet = getDependencyResults(libVariantContext, "compile"); Set<DependencyResult> debugCompileDependencySet = getDependencyResults(libVariantContext, "debugCompile"); if (null == providedDependencySet) { providedDependencySet = new HashSet<DependencyResult>(); } if (null == compileDependencySet) { compileDependencySet = new HashSet<DependencyResult>(); } else { compileDependencySet = new HashSet<DependencyResult>(compileDependencySet); } if (null != debugCompileDependencySet && !debugCompileDependencySet.isEmpty()) { try { ((HashSet<DependencyResult>) compileDependencySet).addAll(debugCompileDependencySet); } catch (Throwable e) { e.printStackTrace(); } } Set<ResolvedDependencyResult> compileOnlyDependencySet = new HashSet<ResolvedDependencyResult>(); for (DependencyResult resolvedDependencyResult : compileDependencySet) { if (resolvedDependencyResult instanceof ResolvedDependencyResult) { ModuleVersionIdentifier moduleVersion = ((ResolvedDependencyResult) resolvedDependencyResult) .getSelected() .getModuleVersion(); String key = moduleVersion.getGroup() + "-" + moduleVersion.getName(); boolean exclude = false; for (DependencyResult resolvedDependencyResult2 : providedDependencySet) { if (resolvedDependencyResult2 instanceof ResolvedDependencyResult) { ModuleVersionIdentifier moduleVersion2 = ((ResolvedDependencyResult) resolvedDependencyResult2) .getSelected() .getModuleVersion(); String key2 = moduleVersion2.getGroup() + "-" + moduleVersion2.getName(); if (key.equals(key2)) { exclude = true; break; } } } if (!exclude) { compileOnlyDependencySet.add((ResolvedDependencyResult) resolvedDependencyResult); } } } collectDependens(compileOnlyDependencySet); }