Search in sources :

Example 96 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class BazelExtractor method extract.

public Extraction extract(ExecutableTarget bazelExe, File workspaceDir, File workspaceFile) throws ExecutableFailedException, DetectableException {
    toolVersionLogger.log(workspaceDir, bazelExe, "version");
    BazelCommandExecutor bazelCommandExecutor = new BazelCommandExecutor(executableRunner, workspaceDir, bazelExe);
    Pipelines pipelines = new Pipelines(bazelCommandExecutor, bazelVariableSubstitutor, externalIdFactory, haskellCabalLibraryJsonProtoParser);
    Set<WorkspaceRule> workspaceRulesFromFile = parseWorkspaceRulesFromFile(workspaceFile);
    Set<WorkspaceRule> workspaceRulesToQuery = workspaceRuleChooser.choose(workspaceRulesFromFile, workspaceRulesFromProperty);
    CodeLocation codeLocation = generateCodelocation(pipelines, workspaceRulesToQuery);
    return buildResults(codeLocation, bazelProjectNameGenerator.generateFromBazelTarget(bazelTarget));
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Pipelines(com.synopsys.integration.detectable.detectables.bazel.pipeline.Pipelines) BazelCommandExecutor(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor)

Example 97 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class ClangPackageDetailsTransformer method toCodeLocation.

public CodeLocation toCodeLocation(List<Forge> dependencyForges, Set<PackageDetails> packages) {
    List<Dependency> dependencies = packages.parallelStream().flatMap(pkg -> toDependency(dependencyForges, pkg).stream()).collect(Collectors.toList());
    logger.trace("Generated : {} dependencies.", dependencies.size());
    DependencyGraph dependencyGraph = new BasicDependencyGraph();
    dependencyGraph.addChildrenToRoot(dependencies);
    return new CodeLocation(dependencyGraph);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Logger(org.slf4j.Logger) Forge(com.synopsys.integration.bdio.model.Forge) LoggerFactory(org.slf4j.LoggerFactory) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Set(java.util.Set) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) PackageDetails(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 98 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class GradleReportParserFunctionalTest method testUnresolvedConfigurations.

@Test
void testUnresolvedConfigurations() {
    Optional<CodeLocation> codeLocation = buildCodeLocation("/gradle/gradle_implementations_dependencyGraph.txt", false);
    Assertions.assertTrue(codeLocation.isPresent());
    DependencyGraph dependencyGraph = codeLocation.get().getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.MAVEN, dependencyGraph);
    graphAssert.hasRootSize(0);
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(codeLocation.get()));
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) MavenGraphAssert(com.synopsys.integration.detectable.util.graph.MavenGraphAssert) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) GsonBuilder(com.google.gson.GsonBuilder) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 99 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class GradleReportParserFunctionalTest method testImplementationsGraph.

@Test
void testImplementationsGraph() {
    Optional<CodeLocation> codeLocation = buildCodeLocation("/gradle/gradle_implementations_dependencyGraph.txt", true);
    Assertions.assertTrue(codeLocation.isPresent());
    DependencyGraph dependencyGraph = codeLocation.get().getDependencyGraph();
    GraphAssert graphAssert = new GraphAssert(Forge.MAVEN, dependencyGraph);
    graphAssert.hasRootSize(7);
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(codeLocation.get()));
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) MavenGraphAssert(com.synopsys.integration.detectable.util.graph.MavenGraphAssert) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) GsonBuilder(com.google.gson.GsonBuilder) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 100 with CodeLocation

use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.

the class LernaExternalDetectableTest method assertExtraction.

@Override
public void assertExtraction(@NotNull Extraction extraction) {
    Assertions.assertEquals(3, extraction.getCodeLocations().size(), "Expected one code location from root, and two from a non-private packages.");
    CodeLocation codeLocationA = extraction.getCodeLocations().get(1);
    Assertions.assertEquals("packageA", codeLocationA.getExternalId().map(ExternalId::getName).orElse(null), "Package A should be the second code location.");
    NameVersionGraphAssert rootGraphAssert = new NameVersionGraphAssert(Forge.NPMJS, codeLocationA.getDependencyGraph());
    rootGraphAssert.hasDependency("packageB", "3.2.1");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)

Aggregations

CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)104 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)60 Extraction (com.synopsys.integration.detectable.extraction.Extraction)41 File (java.io.File)24 ArrayList (java.util.ArrayList)23 Test (org.junit.jupiter.api.Test)22 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)21 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)20 NameVersion (com.synopsys.integration.util.NameVersion)19 IOException (java.io.IOException)19 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)16 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)16 List (java.util.List)14 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)13 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)11 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)10 Optional (java.util.Optional)10 Collectors (java.util.stream.Collectors)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10