use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class CondaListParser method condaListElementToDependency.
public Dependency condaListElementToDependency(String platform, CondaListElement element) {
String name = element.getName();
String version = String.format("%s-%s-%s", element.getVersion(), element.getBuildString(), platform);
ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.ANACONDA, name, version);
return new Dependency(name, version, externalId);
}
use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class PackRatNodeParser method parseProjectDependencies.
DependencyGraph parseProjectDependencies(final List<String> packratLockContents) {
final LazyExternalIdDependencyGraphBuilder graphBuilder = new LazyExternalIdDependencyGraphBuilder();
DependencyId currentParent = null;
String name = null;
String version = null;
for (final String line : packratLockContents) {
if (line.startsWith("PackratFormat:") || line.startsWith("PackratVersion:") || line.startsWith("RVersion:")) {
continue;
}
if (line.contains("Package: ")) {
name = line.replace("Package: ", "").trim();
currentParent = new NameDependencyId(name);
graphBuilder.setDependencyName(currentParent, name);
graphBuilder.addChildToRoot(currentParent);
version = null;
continue;
}
if (line.contains("Version: ")) {
version = line.replace("Version: ", "").trim();
graphBuilder.setDependencyVersion(currentParent, version);
final DependencyId realId = new NameVersionDependencyId(name, version);
final ExternalId externalId = this.externalIdFactory.createNameVersionExternalId(Forge.CRAN, name, version);
graphBuilder.setDependencyAsAlias(realId, currentParent);
graphBuilder.setDependencyInfo(realId, name, version, externalId);
currentParent = realId;
}
if (line.contains("Requires: ")) {
final String[] parts = line.replace("Requires: ", "").split(",");
for (int i = 0; i < parts.length; i++) {
final String childName = parts[i].trim();
graphBuilder.addParentWithChild(currentParent, new NameDependencyId(childName));
}
}
}
return graphBuilder.build();
}
use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class NameVersionNodeTransformer method addNameVersionNodeToDependencyGraph.
public Dependency addNameVersionNodeToDependencyGraph(final MutableDependencyGraph graph, final Forge defaultForge, final NameVersionNode nameVersionNode) {
Forge forge = defaultForge;
if (nameVersionNode.getMetadata() != null && nameVersionNode.getMetadata().getForge() != null) {
forge = nameVersionNode.getMetadata().getForge();
}
final ExternalId externalId = externalIdFactory.createNameVersionExternalId(forge, nameVersionNode.getName(), nameVersionNode.getVersion());
final Dependency parentDependency = new Dependency(nameVersionNode.getName(), nameVersionNode.getVersion(), externalId);
for (final NameVersionNode child : nameVersionNode.getChildren()) {
final Dependency childDependency = addNameVersionNodeToDependencyGraph(graph, defaultForge, child);
graph.addParentWithChild(parentDependency, childDependency);
}
return parentDependency;
}
use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class DependencyGraphAssertions method assertHasMavenGav.
public static void assertHasMavenGav(final DependencyGraph dependencyGraph, final String org, final String name, final String version) {
final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
final ExternalId id = externalIdFactory.createMavenExternalId(org, name, version);
final Dependency dep = dependencyGraph.getDependency(id);
assertNotNull("Expected dependency '" + org + ":" + name + ":" + version + "' to exist in graph but it was null.", dep);
}
Aggregations