use of org.gradle.api.internal.artifacts.result.DefaultResolvedDependencyResult in project atlas by alibaba.
the class DependencyGroup method getProjectBundleCompile.
private Map<String, Set<DependencyResult>> getProjectBundleCompile(Configuration configuration, Set<String> bundleAddedSets) {
Map<String, Set<DependencyResult>> bundleMap = new HashMap<>();
configuration.getAllDependencies().forEach(new Consumer<Dependency>() {
@Override
public void accept(Dependency dependency) {
if (dependency instanceof DefaultProjectDependency) {
DefaultProjectDependency projectDependency = (DefaultProjectDependency) dependency;
String key = "project " + ":" + projectDependency.getName();
if (!bundleAddedSets.contains(key)) {
return;
}
Set<DependencyResult> compileSets = new HashSet<>();
try {
Set<ResolvedArtifact> resolvedArtifacts = projectDependency.getDependencyProject().getConfigurations().getByName("compile").getResolvedConfiguration().getResolvedArtifacts();
projectDependency.getDependencyProject().getConfigurations().getByName("compile").getIncoming().getResolutionResult().getRoot().getDependencies().forEach(new Consumer<DependencyResult>() {
@Override
public void accept(DependencyResult dependencyResult) {
if (!mainDexs.contains(dependencyResult.toString())) {
compileSets.add(dependencyResult);
if (dependencyResult instanceof DefaultResolvedDependencyResult) {
ModuleVersionIdentifier moduleVersionIdentifier = ((DefaultResolvedDependencyResult) dependencyResult).getSelected().getModuleVersion();
for (ResolvedArtifact resolvedArtifact : resolvedArtifacts) {
if (resolvedArtifact.getModuleVersion().getId().equals(moduleVersionIdentifier)) {
bundleCompileId.put(moduleVersionIdentifier, resolvedArtifact);
}
}
}
}
}
});
} catch (UnknownConfigurationException e) {
}
bundleMap.put(projectDependency.getGroup() + ":" + projectDependency.getName(), compileSets);
}
}
});
return bundleMap;
}
use of org.gradle.api.internal.artifacts.result.DefaultResolvedDependencyResult in project gradle by gradle.
the class ResolvedComponentResultSerializer method writeComponent.
private void writeComponent(Encoder encoder, ResolvedComponentResult component, Map<ResolvedComponentResult, Integer> components) throws Exception {
Integer id = components.get(component);
if (id != null) {
// Already seen
encoder.writeSmallInt(id);
return;
}
id = components.size();
components.put(component, id);
encoder.writeSmallInt(id);
moduleVersionIdSerializer.write(encoder, component.getModuleVersion());
componentIdSerializer.write(encoder, component.getId());
componentSelectionReasonSerializer.write(encoder, component.getSelectionReason());
List<ResolvedVariantResult> variants = component.getVariants();
encoder.writeSmallInt(variants.size());
for (ResolvedVariantResult variant : variants) {
resolvedVariantResultSerializer.write(encoder, variant);
}
Set<? extends DependencyResult> dependencies = component.getDependencies();
encoder.writeSmallInt(dependencies.size());
for (DependencyResult dependency : dependencies) {
boolean successful = dependency instanceof ResolvedDependencyResult;
encoder.writeBoolean(successful);
if (successful) {
DefaultResolvedDependencyResult dependencyResult = (DefaultResolvedDependencyResult) dependency;
componentSelectorSerializer.write(encoder, dependencyResult.getRequested());
writeComponent(encoder, dependencyResult.getSelected(), components);
} else {
DefaultUnresolvedDependencyResult dependencyResult = (DefaultUnresolvedDependencyResult) dependency;
componentSelectorSerializer.write(encoder, dependencyResult.getRequested());
}
}
}
Aggregations