use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class DetectProjectManager method createAggregateSimpleBdioDocument.
private SimpleBdioDocument createAggregateSimpleBdioDocument(final String projectName, final String projectVersionName, final DependencyGraph dependencyGraph) {
final String codeLocationName = "";
final ExternalId projectExternalId = simpleBdioFactory.createNameVersionExternalId(new Forge("/", "/", ""), projectName, projectVersionName);
return createSimpleBdioDocument(codeLocationName, projectName, projectVersionName, projectExternalId, dependencyGraph);
}
use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId 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.externalid.ExternalId 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.externalid.ExternalId 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);
}
use of com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalId in project hub-detect by blackducksoftware.
the class DetectProjectManager method createSimpleBdioDocument.
private SimpleBdioDocument createSimpleBdioDocument(final String codeLocationName, final String projectName, final String projectVersionName, final DetectCodeLocation detectCodeLocation) {
final ExternalId projectExternalId = detectCodeLocation.getBomToolProjectExternalId();
final DependencyGraph dependencyGraph = detectCodeLocation.getDependencyGraph();
return createSimpleBdioDocument(codeLocationName, projectName, projectVersionName, projectExternalId, dependencyGraph);
}
Aggregations