use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class BazelExtractor method generateCodelocation.
@NotNull
private CodeLocation generateCodelocation(Pipelines pipelines, Set<WorkspaceRule> workspaceRules) throws DetectableException, ExecutableFailedException {
List<Dependency> aggregatedDependencies = new ArrayList<>();
// Make sure the order of processing deterministic
List<WorkspaceRule> sortedWorkspaceRules = workspaceRules.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
for (WorkspaceRule workspaceRule : sortedWorkspaceRules) {
logger.info("Running processing pipeline for rule {}", workspaceRule);
List<Dependency> ruleDependencies = pipelines.get(workspaceRule).run();
logger.info("Number of dependencies discovered for rule {}: {}}", workspaceRule, ruleDependencies.size());
logger.debug("Dependencies discovered for rule {}: {}}", workspaceRule, ruleDependencies);
aggregatedDependencies.addAll(ruleDependencies);
}
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(aggregatedDependencies);
return new CodeLocation(dependencyGraph);
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class CondaListParser method parse.
public DependencyGraph parse(String listJsonText, String infoJsonText) {
Type listType = new TypeToken<ArrayList<CondaListElement>>() {
}.getType();
List<CondaListElement> condaList = gson.fromJson(listJsonText, listType);
CondaInfo condaInfo = gson.fromJson(infoJsonText, CondaInfo.class);
String platform = condaInfo.platform;
DependencyGraph graph = new BasicDependencyGraph();
condaList.stream().map(condaListElement -> dependencyCreator.createFromCondaListElement(condaListElement, platform)).forEach(graph::addChildToRoot);
return graph;
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class GoModGraphGenerator method generateGraph.
public CodeLocation generateGraph(GoListModule projectModule, GoRelationshipManager goRelationshipManager, GoModDependencyManager goModDependencyManager) {
DependencyGraph graph = new BasicDependencyGraph();
String moduleName = projectModule.getPath();
if (goRelationshipManager.hasRelationshipsFor(moduleName)) {
goRelationshipManager.getRelationshipsFor(moduleName).stream().map(relationship -> relationship.getChild().getName()).forEach(childName -> addModuleToGraph(childName, null, graph, goRelationshipManager, goModDependencyManager));
}
return new CodeLocation(graph, externalIdFactory.createNameVersionExternalId(Forge.GOLANG, projectModule.getPath(), projectModule.getVersion()));
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class IvyParseExtractor method extract.
public Extraction extract(File ivyXmlFile, File buildXmlFile) throws IOException {
try (InputStream ivyXmlInputStream = new FileInputStream(ivyXmlFile)) {
IvyDependenciesHandler ivyDependenciesHandler = new IvyDependenciesHandler(externalIdFactory);
saxParser.parse(ivyXmlInputStream, ivyDependenciesHandler);
List<Dependency> dependencies = ivyDependenciesHandler.getDependencies();
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(dependencies);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
Optional<NameVersion> projectName = projectNameParser.parseProjectName(buildXmlFile);
return new Extraction.Builder().success(codeLocation).nameVersionIfPresent(projectName).build();
} catch (SAXException e) {
return new Extraction.Builder().failure(String.format("There was an error parsing file %s: %s", ivyXmlFile.getAbsolutePath(), e.getMessage())).build();
}
}
use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.
the class MavenCodeLocationPackager method extractCodeLocations.
// mavenOutput should be the full output of mvn dependency:tree (no scope applied); scope filtering is now done by this method
public List<MavenParseResult> extractCodeLocations(String sourcePath, List<String> mavenOutput, List<String> excludedScopes, List<String> includedScopes, List<String> excludedModules, List<String> includedModules) {
ExcludedIncludedWildcardFilter modulesFilter = ExcludedIncludedWildcardFilter.fromCollections(excludedModules, includedModules);
ExcludedIncludedWildcardFilter scopeFilter = ExcludedIncludedWildcardFilter.fromCollections(excludedScopes, includedScopes);
codeLocations = new ArrayList<>();
currentMavenProject = null;
dependencyParentStack = new Stack<>();
parsingProjectSection = false;
currentGraph = new BasicDependencyGraph();
level = 0;
for (String currentLine : mavenOutput) {
String line = currentLine.trim();
if (shouldSkipLine(line)) {
continue;
}
line = trimLogLevel(line);
if (parsingProjectSection && currentMavenProject == null) {
initializeCurrentMavenProject(modulesFilter, sourcePath, line);
continue;
}
boolean finished = line.contains("--------") || endOfTreePattern.matcher(line).matches();
if (finished) {
currentMavenProject = null;
dependencyParentStack.clear();
parsingProjectSection = false;
level = 0;
continue;
}
int previousLevel = level;
String cleanedLine = calculateCurrentLevelAndCleanLine(line);
ScopedDependency dependency = textToDependency(cleanedLine);
if (null == dependency) {
continue;
}
if (currentMavenProject != null) {
populateGraphDependencies(scopeFilter, dependency, previousLevel);
}
}
addOrphansToGraph(currentGraph, orphans);
return codeLocations;
}
Aggregations