Search in sources :

Example 36 with DetectableException

use of com.synopsys.integration.detectable.detectable.exception.DetectableException 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)

Example 37 with DetectableException

use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.

the class LocatorNugetInspectorResolver method resolveNugetInspector.

@Override
public NugetInspector resolveNugetInspector() throws DetectableException {
    try {
        if (!hasResolvedInspector) {
            hasResolvedInspector = true;
            resolvedNugetInspector = install();
        }
        return resolvedNugetInspector;
    } catch (Exception e) {
        throw new DetectableException(e);
    }
}
Also used : IntegrationException(com.synopsys.integration.exception.IntegrationException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 38 with DetectableException

use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.

the class LocatorNugetInspectorResolver method findInspector.

private NugetInspector findInspector(File nupkgFolder, String inspectorName, Function<String, NugetInspector> inspectorInitializer) throws DetectableException {
    logger.debug("Searching for: " + inspectorName);
    File toolsFolder = new File(nupkgFolder, "tools");
    logger.debug("Searching in: " + toolsFolder.getAbsolutePath());
    File foundExecutable = fileFinder.findFiles(toolsFolder, inspectorName, false, 3).stream().findFirst().filter(File::exists).orElseThrow(() -> new DetectableException(String.format("Unable to find nuget inspector, looking for %s in %s", inspectorName, toolsFolder)));
    String inspectorExecutable = foundExecutable.getAbsolutePath();
    logger.debug("Found nuget inspector: {}", inspectorExecutable);
    return inspectorInitializer.apply(inspectorExecutable);
}
Also used : File(java.io.File) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 39 with DetectableException

use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.

the class DotNetRuntimeFinder method listAvailableRuntimes.

public List<String> listAvailableRuntimes() throws DetectableException {
    try {
        ExecutableOutput runtimesOutput = dotnetListRuntimes();
        List<String> foundRuntimes = runtimesOutput.getStandardOutputAsList().stream().map(StringUtils::trimToEmpty).filter(StringUtils::isNotBlank).collect(Collectors.toList());
        logger.info("Found {} available dotnet runtimes", foundRuntimes.size());
        if (foundRuntimes.isEmpty()) {
            throw new DetectableException("No available dotnet runtimes");
        }
        return foundRuntimes;
    } catch (ExecutableRunnerException e) {
        throw new DetectableException("Could not determine available dotnet runtimes", e);
    }
}
Also used : ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) StringUtils(org.apache.commons.lang3.StringUtils) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException)

Aggregations

DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)39 File (java.io.File)22 IOException (java.io.IOException)13 Extraction (com.synopsys.integration.detectable.extraction.Extraction)8 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)8 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)8 List (java.util.List)8 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)6 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)6 DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)6 PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)6 ExtractionEnvironment (com.synopsys.integration.detectable.extraction.ExtractionEnvironment)6 Collections (java.util.Collections)6 HashMap (java.util.HashMap)6 Test (org.junit.jupiter.api.Test)6 ExecutableTarget (com.synopsys.integration.detectable.ExecutableTarget)5 ExecutableFailedException (com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException)5 NameVersion (com.synopsys.integration.util.NameVersion)5 ArrayList (java.util.ArrayList)5 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)4