Search in sources :

Example 36 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class NpmDependencyConverter method createNpmDependency.

private NpmDependency createNpmDependency(String name, String version, Boolean isDev) {
    ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.NPM, name, version);
    Dependency graphDependency = new Dependency(name, version, externalId);
    boolean dev = false;
    if (isDev != null && isDev == true) {
        dev = true;
    }
    return new NpmDependency(name, version, dev, graphDependency);
}
Also used : NpmDependency(com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmDependency) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NpmDependency(com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmDependency) PackageLockDependency(com.blackducksoftware.integration.hub.detect.detector.npm.model.PackageLockDependency) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 37 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class MavenCodeLocationPackager method addOrphansToGraph.

private void addOrphansToGraph(final MutableDependencyGraph graph, final List<Dependency> orphans) {
    logger.trace(String.format("# orphans: %d", orphans.size()));
    if (orphans.size() > 0) {
        final Dependency orphanListParent = createOrphanListParentDependency();
        logger.trace(String.format("adding orphan list parent dependency: %s", orphanListParent.externalId.toString()));
        graph.addChildToRoot(orphanListParent);
        for (Dependency dependency : orphans) {
            logger.trace(String.format("adding orphan: %s", dependency.externalId.toString()));
            graph.addParentWithChild(orphanListParent, dependency);
        }
    }
}
Also used : Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 38 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class MavenCodeLocationPackager method textToProject.

Dependency textToProject(final String componentText) {
    if (!isGav(componentText)) {
        return null;
    }
    final String[] gavParts = componentText.split(":");
    final String group = gavParts[0];
    final String artifact = gavParts[1];
    String version;
    if (gavParts.length == 4) {
        // Dependency does not include the classifier
        version = gavParts[gavParts.length - 1];
    } else if (gavParts.length == 5) {
        // Dependency does include the classifier
        version = gavParts[gavParts.length - 1];
    } else {
        logger.debug(String.format("%s does not look like a dependency we can parse", componentText));
        return null;
    }
    final ExternalId externalId = externalIdFactory.createMavenExternalId(group, artifact, version);
    return new Dependency(artifact, version, externalId);
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 39 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class VndrParser method parseVendorConf.

public DependencyGraph parseVendorConf(final List<String> vendorConfContents) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    // TODO test against moby
    vendorConfContents.forEach(line -> {
        if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
            final String[] parts = line.split(" ");
            final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]);
            final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId);
            graph.addChildToRoot(dependency);
        }
    });
    return graph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 40 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class CpanListParser method parse.

public DependencyGraph parse(final List<String> cpanListText, final List<String> directDependenciesText) {
    final Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
    final List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (final String moduleName : directModuleNames) {
        final String version = nameVersionMap.get(moduleName);
        if (null != version) {
            final String name = moduleName.replace("::", "-");
            final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
            final Dependency dependency = new Dependency(name, version, externalId);
            graph.addChildToRoot(dependency);
        } else {
            logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
        }
    }
    return graph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)46 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)23 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)12 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)11 Test (org.junit.Test)11 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)10 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)9 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 File (java.io.File)5 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 ArrayList (java.util.ArrayList)3 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)2 Gson (com.google.gson.Gson)2 Forge (com.synopsys.integration.bdio.model.Forge)2 NpmDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmDependency)1 PackageLockDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.PackageLockDependency)1 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 DetectCodeLocationType (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocationType)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1