Search in sources :

Example 1 with NameVersionDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId 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();
}
Also used : NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) DependencyId(com.synopsys.integration.bdio.model.dependencyid.DependencyId) NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) LazyExternalIdDependencyGraphBuilder(com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId)

Example 2 with NameVersionDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId in project hub-detect by blackducksoftware.

the class GemlockParser method parseSpecPackageLine.

private void parseSpecPackageLine(final String trimmedLine) {
    final NameVersion parentNameVersion = parseNameVersion(trimmedLine);
    if (StringUtils.isNotBlank(parentNameVersion.getVersion())) {
        currentParent = new NameDependencyId(parentNameVersion.getName());
        discoveredDependencyInfo(new NameVersionDependencyId(parentNameVersion.getName(), parentNameVersion.getVersion()));
    } else {
        logger.error(String.format("An installed spec did not have a non-fuzzy version: %s", trimmedLine));
    }
}
Also used : NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) NameVersion(com.synopsys.integration.util.NameVersion) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)

Example 3 with NameVersionDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId in project hub-detect by blackducksoftware.

the class GemlockParser method addBundlerDependency.

private void addBundlerDependency(final String trimmedLine) {
    final NameVersionDependencyId bundlerId = new NameVersionDependencyId("bundler", trimmedLine);
    discoveredDependencyInfo(bundlerId);
}
Also used : NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId)

Example 4 with NameVersionDependencyId

use of com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId in project hub-detect by blackducksoftware.

the class GemlockParser method processNameVersion.

// If you have Version, you know everything. Otherwise, you need to find this version later.
// Generally each parse/process call should either call this or add to encountered.
private DependencyId processNameVersion(NameVersion nameVersion) {
    NameDependencyId nameDependencyId = new NameDependencyId(nameVersion.getName());
    if (StringUtils.isNotBlank(nameVersion.getVersion())) {
        NameVersionDependencyId nameVersionDependencyId = new NameVersionDependencyId(nameVersion.getName(), nameVersion.getVersion());
        discoveredDependencyInfo(nameVersionDependencyId);
    } else {
        encounteredDependencies.add(nameVersion.getName());
    }
    return nameDependencyId;
}
Also used : NameVersionDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)

Aggregations

NameVersionDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameVersionDependencyId)4 NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)3 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)1 DependencyId (com.synopsys.integration.bdio.model.dependencyid.DependencyId)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 NameVersion (com.synopsys.integration.util.NameVersion)1