Search in sources :

Example 1 with GradleGav

use of com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav in project synopsys-detect by blackducksoftware.

the class GradleReportTransformer method addConfigurationToGraph.

private void addConfigurationToGraph(MutableDependencyGraph graph, GradleConfiguration configuration) {
    DependencyHistory history = new DependencyHistory();
    TreeNodeSkipper treeNodeSkipper = new TreeNodeSkipper();
    for (GradleTreeNode currentNode : configuration.getChildren()) {
        if (treeNodeSkipper.shouldSkip(currentNode)) {
            continue;
        }
        if (currentNode.getNodeType() == GradleTreeNode.NodeType.GAV) {
            history.clearDependenciesDeeperThan(currentNode.getLevel());
            Optional<GradleGav> currentNodeGav = currentNode.getGav();
            if (currentNodeGav.isPresent()) {
                addGavToGraph(currentNodeGav.get(), history, graph);
            } else {
                // We know this is a GradleTreeNode.NodeType.GAV
                // So if its missing data, something is probably wrong.
                logger.debug("Missing expected GAV from known NodeType. {}", currentNode);
            }
        } else {
            treeNodeSkipper.skipUntilLineLevel(currentNode.getLevel());
        }
    }
}
Also used : GradleTreeNode(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleTreeNode) GradleGav(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav) DependencyHistory(com.synopsys.integration.detectable.detectable.util.DependencyHistory)

Example 2 with GradleGav

use of com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav in project synopsys-detect by blackducksoftware.

the class GradleReportTransformer method addConfigurationToGraph.

private void addConfigurationToGraph(DependencyGraph graph, GradleConfiguration configuration) {
    DependencyHistory history = new DependencyHistory();
    TreeNodeSkipper treeNodeSkipper = new TreeNodeSkipper();
    for (GradleTreeNode currentNode : configuration.getChildren()) {
        if (treeNodeSkipper.shouldSkip(currentNode)) {
            continue;
        }
        if (currentNode.getNodeType() == GradleTreeNode.NodeType.GAV) {
            history.clearDependenciesDeeperThan(currentNode.getLevel());
            Optional<GradleGav> currentNodeGav = currentNode.getGav();
            if (currentNodeGav.isPresent()) {
                addGavToGraph(currentNodeGav.get(), history, graph);
            } else {
                // We know this is a GradleTreeNode.NodeType.GAV
                // So if its missing data, something is probably wrong.
                logger.debug("Missing expected GAV from known NodeType. {}", currentNode);
            }
        } else {
            treeNodeSkipper.skipUntilLineLevel(currentNode.getLevel());
        }
    }
}
Also used : GradleTreeNode(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleTreeNode) GradleGav(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav) DependencyHistory(com.synopsys.integration.detectable.detectable.util.DependencyHistory)

Example 3 with GradleGav

use of com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav in project synopsys-detect by blackducksoftware.

the class GradleReportLineTest method assertDependency.

private void assertDependency(String line, String[] expectedResults) {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    GradleReportLineParser gradleReportLineParser = new GradleReportLineParser();
    GradleTreeNode gradleTreeNode = gradleReportLineParser.parseLine(line);
    GradleGav gav = gradleTreeNode.getGav().get();
    ExternalId externalId = externalIdFactory.createMavenExternalId(gav.getGroup(), gav.getName(), gav.getVersion());
    Dependency dependency = new Dependency(gav.getName(), gav.getVersion(), externalId);
    Assertions.assertEquals(expectedResults[0], dependency.getExternalId().getGroup());
    Assertions.assertEquals(expectedResults[1], dependency.getName());
    Assertions.assertEquals(expectedResults[2], dependency.getVersion());
    Assertions.assertEquals(expectedResults[3], dependency.getExternalId().createExternalId());
}
Also used : GradleTreeNode(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleTreeNode) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) GradleReportLineParser(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportLineParser) GradleGav(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 4 with GradleGav

use of com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav in project synopsys-detect by blackducksoftware.

the class GradleReportParserTest method assertParsedGavDoesNotContain.

private void assertParsedGavDoesNotContain(String line, String contains) {
    GradleReportLineParser gradleReportLineParser = new GradleReportLineParser();
    GradleTreeNode node = gradleReportLineParser.parseLine(line);
    assertTrue(node.getGav().isPresent());
    GradleGav gav = node.getGav().get();
    assertFalse(gav.getVersion().contains(contains));
}
Also used : GradleTreeNode(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleTreeNode) GradleReportLineParser(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportLineParser) GradleGav(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav)

Aggregations

GradleGav (com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleGav)4 GradleTreeNode (com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleTreeNode)4 DependencyHistory (com.synopsys.integration.detectable.detectable.util.DependencyHistory)2 GradleReportLineParser (com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportLineParser)2 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1