use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.
the class DockerDetectable method extractable.
@Override
public DetectableResult extractable() throws DetectableException {
// TODO: Can this be improved with a Requirements object? - jp
PassedResultBuilder passedResultBuilder = new PassedResultBuilder();
javaExe = javaResolver.resolveJava();
if (javaExe == null) {
return new ExecutableNotFoundDetectableResult("java");
} else {
passedResultBuilder.foundExecutable(javaExe);
}
try {
dockerExe = dockerResolver.resolveDocker();
} catch (Exception e) {
dockerExe = null;
}
if (dockerExe == null) {
if (dockerDetectableOptions.isDockerPathRequired()) {
return new ExecutableNotFoundDetectableResult("docker");
} else {
logger.debug("Docker executable not found, but it has been configured as not-required; proceeding with execution of Docker tool. Running in air-gap mode will not work without a Docker executable.");
}
} else {
passedResultBuilder.foundExecutable(dockerExe);
}
dockerInspectorInfo = dockerInspectorResolver.resolveDockerInspector();
if (dockerInspectorInfo == null) {
return new InspectorNotFoundDetectableResult("docker");
} else {
passedResultBuilder.foundInspector(dockerInspectorInfo.getDockerInspectorJar());
}
return passedResultBuilder.build();
}
use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method populateGraphUnderNode.
private void populateGraphUnderNode(ConanGraphNode curGraphNode, Map<String, ConanNode<String>> graphNodes) throws DetectableException {
Set<String> dependencyRefs = new HashSet<>(curGraphNode.getConanNode().getRequiresRefs().orElse(new ArrayList<>(0)));
dependencyTypeFilter.ifShouldInclude(ConanDependencyType.BUILD, curGraphNode.getConanNode().getBuildRequiresRefs(), dependencyRefs::addAll);
for (String childRef : dependencyRefs) {
ConanNode<String> childNode = graphNodes.get(childRef);
if (childNode == null) {
throw new DetectableException(String.format("%s requires non-existent node %s", curGraphNode.getConanNode().getRef(), childRef));
}
ConanGraphNode childGraphNode = new ConanGraphNode(childNode);
populateGraphUnderNode(childGraphNode, graphNodes);
curGraphNode.addChild(childGraphNode);
}
}
use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method generateDependency.
@NotNull
private Dependency generateDependency(ExternalIdFactory externalIdFactory, ConanGraphNode graphNode) throws DetectableException {
String depName = graphNode.getConanNode().getName().orElseThrow(() -> new DetectableException(String.format("Missing dependency name: %s", graphNode.getConanNode())));
String fullVersion = ConanExternalIdVersionGenerator.generateExternalIdVersionString(graphNode.getConanNode(), preferLongFormExternalIds);
ExternalId externalId = externalIdFactory.createNameVersionExternalId(conanForge, depName, fullVersion);
logger.trace("Generated Dependency for {}/{} with externalID: {}", depName, fullVersion, externalId.getExternalIdPieces());
return new Dependency(depName, graphNode.getConanNode().getVersion().orElseThrow(() -> new DetectableException(String.format("Missing dependency version: %s", graphNode.getConanNode()))), externalId);
}
use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.
the class ConanCliExtractor method extract.
public Extraction extract(File projectDir, ExecutableTarget conanExe) {
toolVersionLogger.log(projectDir, conanExe);
ExecutableOutput conanInfoOutput;
try {
conanInfoOutput = conanCommandRunner.runConanInfoCommand(projectDir, conanExe);
} catch (Exception e) {
logger.error(String.format("Exception thrown executing conan info command: %s", e.getMessage()));
return new Extraction.Builder().exception(e).build();
}
if (!conanCommandRunner.wasSuccess(conanInfoOutput)) {
return new Extraction.Builder().failure("Conan info command reported errors").build();
}
if (!conanCommandRunner.producedOutput(conanInfoOutput)) {
return new Extraction.Builder().failure("Conan info command produced no output").build();
}
try {
ConanDetectableResult result = conanInfoParser.generateCodeLocationFromConanInfoOutput(conanInfoOutput.getStandardOutput());
return new Extraction.Builder().success(result.getCodeLocation()).projectName(result.getProjectName()).projectVersion(result.getProjectVersion()).build();
} catch (DetectableException e) {
return new Extraction.Builder().failure(e.getMessage()).build();
}
}
use of com.synopsys.integration.detectable.detectable.exception.DetectableException in project synopsys-detect by blackducksoftware.
the class HaskellCabalLibraryJsonProtoParser method extractDependency.
private NameVersion extractDependency(List<AttributeItem> attributes) throws DetectableException {
String dependencyName = null;
String dependencyVersion = null;
for (AttributeItem attributeItem : attributes) {
if ("name".equals(attributeItem.getName())) {
dependencyName = attributeItem.getStringValue();
} else if ("version".equals(attributeItem.getName())) {
dependencyVersion = attributeItem.getStringValue();
}
if (dependencyName != null && dependencyVersion != null) {
return new NameVersion(dependencyName, dependencyVersion);
}
}
throw new DetectableException(String.format("Dependency name/version not found in attribute list: %s", attributes));
}
Aggregations