Search in sources :

Example 26 with DetectableException

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

the class SbtPluginFinder method listPlugins.

private List<String> listPlugins(File directory, ExecutableTarget sbt, @Nullable String sbtCommandAdditionalArguments) throws DetectableException {
    try {
        List<String> args = sbtCommandArgumentGenerator.generateSbtCmdArgs(sbtCommandAdditionalArguments, "plugins");
        ExecutableOutput output = executableRunner.executeSuccessfully(ExecutableUtils.createFromTarget(directory, sbt, args));
        return output.getStandardOutputAsList();
    } catch (ExecutableFailedException e) {
        throw new DetectableException("Unable to list installed sbt plugins, detect requires a suitable sbt plugin is available to find dependency graphs.", e);
    }
}
Also used : ExecutableFailedException(com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 27 with DetectableException

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

the class LocalPipInspectorResolver method resolvePipInspector.

@Override
public File resolvePipInspector() throws DetectableException {
    try {
        if (!hasResolvedInspector) {
            hasResolvedInspector = true;
            resolvedInspector = installInspector();
        }
        return resolvedInspector;
    } catch (Exception e) {
        throw new DetectableException(e);
    }
}
Also used : IOException(java.io.IOException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 28 with DetectableException

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

the class OnlineNugetInspectorResolver method resolveNugetInspector.

@Override
public ExecutableTarget resolveNugetInspector() throws DetectableException {
    if (!hasResolvedInspector) {
        File inspectorFile = null;
        hasResolvedInspector = true;
        File installDirectory = directoryManager.getPermanentDirectory(INSPECTOR_NAME);
        try {
            inspectorFile = installer.install(installDirectory);
        } catch (DetectableException e) {
            logger.debug("Unable to install the detect nuget inspector from Artifactory.", e);
        }
        if (inspectorFile == null) {
            // Remote installation has failed
            logger.debug("Attempting to locate previous install of detect nuget inspector.");
            return installedToolLocator.locateTool(INSPECTOR_NAME).map(ExecutableTarget::forFile).orElseThrow(() -> new DetectableException("Unable to locate previous install of the detect nuget inspector."));
        } else {
            installedToolManager.saveInstalledToolLocation(INSPECTOR_NAME, inspectorFile.getAbsolutePath());
        }
        inspector = ExecutableTarget.forFile(inspectorFile);
    }
    return inspector;
}
Also used : File(java.io.File) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 29 with DetectableException

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

the class OnlineProjectInspectorResolver method resolveProjectInspector.

@Override
public ExecutableTarget resolveProjectInspector() throws DetectableException {
    File inspectorFile = null;
    if (!hasResolvedInspector) {
        hasResolvedInspector = true;
        File installDirectory = directoryManager.getPermanentDirectory(INSTALLED_TOOL_JSON_KEY);
        try {
            inspectorFile = projectInspectorInstaller.install(installDirectory);
        } catch (DetectableException e) {
            logger.debug("Unable to install the project inspector from Artifactory.");
        }
        if (inspectorFile == null) {
            // Remote installation has failed
            logger.debug("Attempting to locate previous install of project inspector.");
            return installedToolLocator.locateTool(INSTALLED_TOOL_JSON_KEY).map(ExecutableTarget::forFile).orElseThrow(() -> new DetectableException("Unable to locate previous install of the project inspector."));
        } else {
            installedToolManager.saveInstalledToolLocation(INSTALLED_TOOL_JSON_KEY, inspectorFile.getAbsolutePath());
        }
    }
    return ExecutableTarget.forFile(inspectorFile);
}
Also used : File(java.io.File) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException)

Example 30 with DetectableException

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

the class ProjectInspectorExecutableLocator method findExecutable.

@Nullable
public File findExecutable(File extractedZip, String executableName) throws DetectableException {
    logger.debug("Looking for '" + executableName + "' in " + extractedZip.toString());
    File bin = new File(extractedZip, "bin");
    File executable = new File(bin, executableName);
    if (executable.exists()) {
        logger.debug("Found it: " + executable);
        if (!executable.canExecute()) {
            if (!executable.setExecutable(true)) {
                throw new DetectableException("Unable to set project inspector to executable: " + executable);
            }
        }
        return executable;
    } else {
        logger.debug("Could not find executable: " + executable);
        return null;
    }
}
Also used : File(java.io.File) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) Nullable(org.jetbrains.annotations.Nullable)

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