Search in sources :

Example 26 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformer method transform.

public DependencyGraph transform(PackageResolved packageResolved) {
    // ProjectDependencyGraph(new ProjectDependency(SWIFT_FORGE, relativePackageResolvedPath))
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    packageResolved.getResolvedObject().getPackages().stream().filter(Objects::nonNull).map(this::convertToDependency).filter(Optional::isPresent).map(Optional::get).forEach(dependencyGraph::addDirectDependency);
    return dependencyGraph;
}
Also used : Optional(java.util.Optional) Objects(java.util.Objects) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 27 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class SbtModuleAggregator method aggregateModules.

public List<SbtDependencyModule> aggregateModules(List<SbtDependencyModule> modules) {
    Set<SbtAggregate> aggregates = uniqueAggregates(modules);
    logger.debug("Found unique aggregates: " + aggregates.size());
    return aggregates.stream().map(aggregate -> {
        SbtDependencyModule aggregated = new SbtDependencyModule();
        aggregated.setName(aggregate.getName());
        aggregated.setVersion(aggregate.getVersion());
        aggregated.setOrg(aggregate.getOrg());
        BasicDependencyGraph graph = new BasicDependencyGraph();
        aggregated.setGraph(graph);
        modules.forEach(module -> {
            if (moduleEqualsAggregate(module, aggregate)) {
                logger.debug("Combining '" + module.getName() + "' with '" + aggregate.getName() + "'");
                graph.copyGraphToRoot((BasicDependencyGraph) module.getGraph());
            }
        });
        return aggregated;
    }).collect(Collectors.toList());
}
Also used : List(java.util.List) Logger(org.slf4j.Logger) SbtAggregate(com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtAggregate) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) SbtDependencyModule(com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtDependencyModule) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) SbtAggregate(com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtAggregate) SbtDependencyModule(com.synopsys.integration.detectable.detectables.sbt.parse.model.SbtDependencyModule) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 28 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class SwiftPackageTransformer method transform.

public CodeLocation transform(SwiftPackage rootSwiftPackage) {
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    for (SwiftPackage swiftPackageDependency : rootSwiftPackage.getDependencies()) {
        Dependency dependency = convertToDependency(dependencyGraph, swiftPackageDependency);
        dependencyGraph.addChildToRoot(dependency);
    }
    return new CodeLocation(dependencyGraph);
}
Also used : SwiftPackage(com.synopsys.integration.detectable.detectables.swift.cli.model.SwiftPackage) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 29 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class NugetInspectorExtractor method extract.

public Extraction extract(List<File> targets, File outputDirectory, ExecutableTarget inspector, NugetInspectorOptions nugetInspectorOptions) {
    try {
        List<NugetTargetResult> results = new ArrayList<>();
        for (int i = 0; i < targets.size(); i++) {
            File targetDirectory = new File(outputDirectory, "inspection-" + i);
            results.add(executeTarget(inspector, targets.get(i), targetDirectory, nugetInspectorOptions));
        }
        List<CodeLocation> codeLocations = results.stream().flatMap(it -> it.codeLocations.stream()).collect(Collectors.toList());
        Map<File, CodeLocation> codeLocationsBySource = new HashMap<>();
        codeLocations.forEach(codeLocation -> {
            File sourcePathFile = codeLocation.getSourcePath().orElse(null);
            if (codeLocationsBySource.containsKey(sourcePathFile)) {
                logger.debug("Combined code location for: " + sourcePathFile);
                CodeLocation destination = codeLocationsBySource.get(sourcePathFile);
                // TODO: I don't like this casting, perhaps this doesn't have to happen here in 8.0.0. JM-04/2022
                destination.getDependencyGraph().copyGraphToRoot((BasicDependencyGraph) codeLocation.getDependencyGraph());
            } else {
                codeLocationsBySource.put(sourcePathFile, codeLocation);
            }
        });
        Optional<NameVersion> nameVersion = results.stream().filter(it -> it.nameVersion != null).map(it -> it.nameVersion).findFirst();
        List<CodeLocation> uniqueCodeLocations = new ArrayList<>(codeLocationsBySource.values());
        return new Extraction.Builder().success(uniqueCodeLocations).nameVersionIfPresent(nameVersion).build();
    } catch (Exception e) {
        return new Extraction.Builder().exception(e).build();
    }
}
Also used : Extraction(com.synopsys.integration.detectable.extraction.Extraction) NugetParseResult(com.synopsys.integration.detectable.detectables.nuget.parse.NugetParseResult) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) ArrayList(java.util.ArrayList) NameVersion(com.synopsys.integration.util.NameVersion) ExecutableTarget(com.synopsys.integration.detectable.ExecutableTarget) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException) Map(java.util.Map) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Logger(org.slf4j.Logger) NugetInspectorParser(com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Executable(com.synopsys.integration.executable.Executable) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) Optional(java.util.Optional) ExecutableUtils(com.synopsys.integration.detectable.ExecutableUtils) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) NameVersion(com.synopsys.integration.util.NameVersion) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException) IOException(java.io.IOException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) Extraction(com.synopsys.integration.detectable.extraction.Extraction) File(java.io.File)

Example 30 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class PearDependencyGraphTransformer method buildDependencyGraph.

public DependencyGraph buildDependencyGraph(Map<String, String> dependencyNameVersionMap, List<PackageDependency> packageDependencies) {
    List<Dependency> dependencies = packageDependencies.stream().filter(this::filterDependencyType).map(PackageDependency::getName).map(dependencyName -> {
        String dependencyVersion = dependencyNameVersionMap.get(dependencyName);
        ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.PEAR, dependencyName, dependencyVersion);
        return new Dependency(dependencyName, dependencyVersion, externalId);
    }).collect(Collectors.toList());
    DependencyGraph mutableDependencyGraph = new BasicDependencyGraph();
    mutableDependencyGraph.addChildrenToRoot(dependencies);
    return mutableDependencyGraph;
}
Also used : PearDependencyType(com.synopsys.integration.detectable.detectables.pear.PearDependencyType) List(java.util.List) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Forge(com.synopsys.integration.bdio.model.Forge) EnumListFilter(com.synopsys.integration.detectable.detectable.util.EnumListFilter) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Map(java.util.Map) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) PackageDependency(com.synopsys.integration.detectable.detectables.pear.model.PackageDependency) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Collectors(java.util.stream.Collectors) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) PackageDependency(com.synopsys.integration.detectable.detectables.pear.model.PackageDependency) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) PackageDependency(com.synopsys.integration.detectable.detectables.pear.model.PackageDependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Aggregations

BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)43 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)38 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)26 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)16 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 List (java.util.List)7 Forge (com.synopsys.integration.bdio.model.Forge)6 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)5 ArrayList (java.util.ArrayList)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 File (java.io.File)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Gson (com.google.gson.Gson)3 NotNull (org.jetbrains.annotations.NotNull)3 GraphEdge (com.paypal.digraph.parser.GraphEdge)2 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)2 DependencyHistory (com.synopsys.integration.detectable.detectable.util.DependencyHistory)2 Extraction (com.synopsys.integration.detectable.extraction.Extraction)2