use of com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class CpanPackager method makeDependencyGraph.
public DependencyGraph makeDependencyGraph(List<String> cpanListText, List<String> directDependenciesText) {
Map<String, NameVersionNode> allModules = cpanListParser.parse(cpanListText);
List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
MutableDependencyGraph graph = new MutableMapDependencyGraph();
for (String moduleName : directModuleNames) {
NameVersionNode nameVersionNode = allModules.get(moduleName);
if (null != nameVersionNode) {
nameVersionNode.setName(nameVersionNode.getName().replace("::", "-"));
Dependency module = nameVersionNodeTransformer.addNameVersionNodeToDependencyGraph(graph, Forge.CPAN, nameVersionNode);
graph.addChildToRoot(module);
} else {
logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
}
}
return graph;
}
use of com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class NameVersionNodeTransformer method createDependencyGraph.
public DependencyGraph createDependencyGraph(final Forge defaultForge, final NameVersionNode nameVersionNode, final Boolean rootIsRealRoot) {
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
final Dependency root = addNameVersionNodeToDependencyGraph(graph, defaultForge, nameVersionNode);
if (rootIsRealRoot) {
graph.addChildToRoot(root);
} else {
graph.addChildrenToRoot(graph.getChildrenForParent(root));
}
return graph;
}
use of com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class GradleReportParser method parseDependencies.
public DetectCodeLocation parseDependencies(final DetectProject detectProject, final InputStream dependenciesInputStream) {
clearState();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(dependenciesInputStream, StandardCharsets.UTF_8))) {
while (reader.ready()) {
final String line = reader.readLine();
/**
* The meta data section will be at the end of the file after all of the "gradle dependencies" output
*/
if (line.startsWith("DETECT META DATA START")) {
processingMetaData = true;
continue;
}
if (line.startsWith("DETECT META DATA END")) {
processingMetaData = false;
continue;
}
if (processingMetaData) {
processMetaDataLine(line);
continue;
}
if (StringUtils.isBlank(line)) {
clearConfigurationState();
continue;
}
final Dependency nextDependency = gradleReportConfigurationParser.parseDependency(externalIdFactory, line);
if (nextDependency == null) {
continue;
}
final int lineTreeLevel = gradleReportConfigurationParser.getTreeLevel();
if (lineTreeLevel == previousTreeLevel + 1) {
nodeStack.push(previousNode);
} else if (lineTreeLevel < previousTreeLevel) {
for (int times = 0; times < (previousTreeLevel - lineTreeLevel); times++) {
nodeStack.pop();
}
} else if (lineTreeLevel != previousTreeLevel) {
logger.error(String.format("The tree level (%s) and this line (%s) with count %s can't be reconciled.", previousTreeLevel, line, lineTreeLevel));
}
if (nodeStack.size() == 0) {
graph.addChildToRoot(nextDependency);
} else {
graph.addChildWithParents(nextDependency, nodeStack.peek());
}
previousNode = nextDependency;
previousTreeLevel = lineTreeLevel;
}
} catch (final Exception e) {
logger.error("Exception parsing gradle output: " + e.getMessage());
}
detectProject.setProjectNameIfNotSet(rootProjectName);
detectProject.setProjectVersionNameIfNotSet(rootProjectVersionName);
final ExternalId id = externalIdFactory.createMavenExternalId(projectGroup, projectName, projectVersionName);
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(BomToolType.GRADLE, projectSourcePath, id, graph).bomToolProjectName(projectName).bomToolProjectVersionName(projectVersionName).build();
return detectCodeLocation;
}
use of com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class DependencyGraphAssertions method assertParentHasChildMavenGav.
public static void assertParentHasChildMavenGav(final String parentGav, final DependencyGraph dependencyGraph, final String targetGavChild) {
final ExternalId parentId = mavenGavToExternalId(parentGav);
final ExternalId childId = mavenGavToExternalId(targetGavChild);
final Dependency dep = dependencyGraph.getDependency(parentId);
assertNotNull("Graph does not have gav '" + parentGav + "'", dep);
final Set<ExternalId> children = dependencyGraph.getChildrenExternalIdsForParent(dep);
assertTrue("Parent gav '" + parentGav + "' does not have child gav '" + targetGavChild + "'", children.contains(childId));
}
use of com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.
the class DependencyGraphAssertions method assertHasRootMavenGav.
public static void assertHasRootMavenGav(final DependencyGraph dependencyGraph, final String targetGav) {
final ExternalId targetId = mavenGavToExternalId(targetGav);
final Dependency dep = dependencyGraph.getDependency(targetId);
assertNotNull(dep);
}
Aggregations