use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class GoGradleLockParser method parse.
public DependencyGraph parse(File goGradleLockFile) throws IOException, IntegrationException {
DependencyGraph dependencyGraph = new BasicDependencyGraph();
YAMLMapper mapper = new YAMLMapper();
JsonNode rootNode = mapper.readTree(goGradleLockFile);
JsonNode buildNode = rootNode.findPath("build");
if (buildNode == null) {
throw new IntegrationException(String.format("Failed to find build node in %s", GoGradleDetectable.GO_GRADLE_LOCK));
}
for (JsonNode dependencyNode : buildNode) {
Optional<String> name = Optional.ofNullable(dependencyNode.get("name")).map(JsonNode::textValue);
Optional<String> commit = Optional.ofNullable(dependencyNode.get("commit")).map(JsonNode::textValue);
if (name.isPresent() && commit.isPresent()) {
String dependencyName = name.get();
if (dependencyName.startsWith("golang.org/x/")) {
dependencyName = dependencyName.replace("golang.org/x/", "");
}
ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, dependencyName, commit.get());
Dependency dependency = new Dependency(externalId);
dependencyGraph.addChildToRoot(dependency);
}
}
return dependencyGraph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class ClangPackageDetailsTransformer method toCodeLocation.
public CodeLocation toCodeLocation(List<Forge> dependencyForges, Set<PackageDetails> packages) {
List<Dependency> dependencies = packages.parallelStream().flatMap(pkg -> toDependency(dependencyForges, pkg).stream()).collect(Collectors.toList());
logger.trace("Generated : {} dependencies.", dependencies.size());
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(dependencies);
return new CodeLocation(dependencyGraph);
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class FinalStepTransformJsonProtoHaskellCabalLibrariesToHackageTest method testStep.
@Test
public void testStep() throws IntegrationException, IOException {
File jsonProtoFile = new File("src/test/resources/detectables/functional/bazel/jsonProtoForHaskellCabalLibraries.txt");
String jsonProtoHaskellCabalLibrary = FileUtils.readFileToString(jsonProtoFile, StandardCharsets.UTF_8);
FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage step = new FinalStepTransformJsonProtoHaskellCabalLibrariesToHackage(new HaskellCabalLibraryJsonProtoParser(new Gson()), new ExternalIdFactory());
List<String> input = new ArrayList<>(1);
input.add(jsonProtoHaskellCabalLibrary);
List<Dependency> dependencies = step.finish(input);
DependencyGraph dependencyGraph = new BasicDependencyGraph();
for (Dependency dependency : dependencies) {
dependencyGraph.addChildToRoot(dependency);
}
Forge hackageForge = new Forge("/", "hackage");
GraphAssert graphAssert = new GraphAssert(hackageForge, dependencyGraph);
graphAssert.hasRootSize(1);
ExternalId expectedExternalId = new ExternalIdFactory().createNameVersionExternalId(hackageForge, "colour", "2.3.5");
graphAssert.hasRootDependency(expectedExternalId);
}
Aggregations