Search in sources :

Example 1 with Target

use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.Target in project synopsys-detect by blackducksoftware.

the class HaskellCabalLibraryJsonProtoParser method extractAddDependencies.

private void extractAddDependencies(String jsonProtoString, List<NameVersion> dependencies, ResultItem result) throws DetectableException {
    if (result == null || result.getTarget() == null) {
        throw new DetectableException(String.format("Unable to parse target from result inJSON proto string: %s", jsonProtoString));
    }
    Target target = result.getTarget();
    if ("RULE".equals(target.getType())) {
        if (target.getRule() == null || target.getRule().getAttribute() == null) {
            throw new DetectableException(String.format("Unable to parse attributes from rule inJSON proto string: %s", jsonProtoString));
        }
        List<AttributeItem> attributes = target.getRule().getAttribute();
        NameVersion dependency = extractDependency(attributes);
        logger.debug("Adding dependency {}/{}}", dependency.getName(), dependency.getVersion());
        dependencies.add(dependency);
    }
}
Also used : Target(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.Target) AttributeItem(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.AttributeItem) NameVersion(com.synopsys.integration.util.NameVersion) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Aggregations

DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)1 AttributeItem (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.AttributeItem)1 Target (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.model.Target)1 NameVersion (com.synopsys.integration.util.NameVersion)1