use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PackageResolvedTransformer method transform.
public DependencyGraph transform(PackageResolved packageResolved) {
// ProjectDependencyGraph(new ProjectDependency(SWIFT_FORGE, relativePackageResolvedPath))
DependencyGraph dependencyGraph = new BasicDependencyGraph();
packageResolved.getResolvedObject().getPackages().stream().filter(Objects::nonNull).map(this::convertToDependency).filter(Optional::isPresent).map(Optional::get).forEach(dependencyGraph::addDirectDependency);
return dependencyGraph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class SbtModuleAggregator method aggregateModules.
public List<SbtDependencyModule> aggregateModules(List<SbtDependencyModule> modules) {
Set<SbtAggregate> aggregates = uniqueAggregates(modules);
logger.debug("Found unique aggregates: " + aggregates.size());
return aggregates.stream().map(aggregate -> {
SbtDependencyModule aggregated = new SbtDependencyModule();
aggregated.setName(aggregate.getName());
aggregated.setVersion(aggregate.getVersion());
aggregated.setOrg(aggregate.getOrg());
BasicDependencyGraph graph = new BasicDependencyGraph();
aggregated.setGraph(graph);
modules.forEach(module -> {
if (moduleEqualsAggregate(module, aggregate)) {
logger.debug("Combining '" + module.getName() + "' with '" + aggregate.getName() + "'");
graph.copyGraphToRoot((BasicDependencyGraph) module.getGraph());
}
});
return aggregated;
}).collect(Collectors.toList());
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class SwiftPackageTransformer method transform.
public CodeLocation transform(SwiftPackage rootSwiftPackage) {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
for (SwiftPackage swiftPackageDependency : rootSwiftPackage.getDependencies()) {
Dependency dependency = convertToDependency(dependencyGraph, swiftPackageDependency);
dependencyGraph.addChildToRoot(dependency);
}
return new CodeLocation(dependencyGraph);
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class NugetInspectorExtractor method extract.
public Extraction extract(List<File> targets, File outputDirectory, ExecutableTarget inspector, NugetInspectorOptions nugetInspectorOptions) {
try {
List<NugetTargetResult> results = new ArrayList<>();
for (int i = 0; i < targets.size(); i++) {
File targetDirectory = new File(outputDirectory, "inspection-" + i);
results.add(executeTarget(inspector, targets.get(i), targetDirectory, nugetInspectorOptions));
}
List<CodeLocation> codeLocations = results.stream().flatMap(it -> it.codeLocations.stream()).collect(Collectors.toList());
Map<File, CodeLocation> codeLocationsBySource = new HashMap<>();
codeLocations.forEach(codeLocation -> {
File sourcePathFile = codeLocation.getSourcePath().orElse(null);
if (codeLocationsBySource.containsKey(sourcePathFile)) {
logger.debug("Combined code location for: " + sourcePathFile);
CodeLocation destination = codeLocationsBySource.get(sourcePathFile);
// TODO: I don't like this casting, perhaps this doesn't have to happen here in 8.0.0. JM-04/2022
destination.getDependencyGraph().copyGraphToRoot((BasicDependencyGraph) codeLocation.getDependencyGraph());
} else {
codeLocationsBySource.put(sourcePathFile, codeLocation);
}
});
Optional<NameVersion> nameVersion = results.stream().filter(it -> it.nameVersion != null).map(it -> it.nameVersion).findFirst();
List<CodeLocation> uniqueCodeLocations = new ArrayList<>(codeLocationsBySource.values());
return new Extraction.Builder().success(uniqueCodeLocations).nameVersionIfPresent(nameVersion).build();
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class PearDependencyGraphTransformer method buildDependencyGraph.
public DependencyGraph buildDependencyGraph(Map<String, String> dependencyNameVersionMap, List<PackageDependency> packageDependencies) {
List<Dependency> dependencies = packageDependencies.stream().filter(this::filterDependencyType).map(PackageDependency::getName).map(dependencyName -> {
String dependencyVersion = dependencyNameVersionMap.get(dependencyName);
ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.PEAR, dependencyName, dependencyVersion);
return new Dependency(dependencyName, dependencyVersion, externalId);
}).collect(Collectors.toList());
DependencyGraph mutableDependencyGraph = new BasicDependencyGraph();
mutableDependencyGraph.addChildrenToRoot(dependencies);
return mutableDependencyGraph;
}
Aggregations