use of com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction in project hub-detect by blackducksoftware.
the class CondaCliExtractor method extract.
public Extraction extract(final File directory, final File condaExe, ExtractionId extractionId) {
try {
File workingDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final List<String> condaListOptions = new ArrayList<>();
condaListOptions.add("list");
final String condaEnvironmentName = detectConfiguration.getProperty(DetectProperty.DETECT_CONDA_ENVIRONMENT_NAME, PropertyAuthority.None);
if (StringUtils.isNotBlank(condaEnvironmentName)) {
condaListOptions.add("-n");
condaListOptions.add(condaEnvironmentName);
}
condaListOptions.add("--json");
final Executable condaListExecutable = new Executable(directory, condaExe, condaListOptions);
final ExecutableOutput condaListOutput = executableRunner.execute(condaListExecutable);
final String listJsonText = condaListOutput.getStandardOutput();
final ExecutableOutput condaInfoOutput = executableRunner.execute(workingDirectory, condaExe, "info", "--json");
final String infoJsonText = condaInfoOutput.getStandardOutput();
final DependencyGraph dependencyGraph = condaListParser.parse(listJsonText, infoJsonText);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.ANACONDA, directory.toString());
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.CONDA, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(detectCodeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction in project hub-detect by blackducksoftware.
the class CpanCliExtractor method extract.
public Extraction extract(final File directory, final File cpanExe, final File cpanmExe, ExtractionId extractionId) {
try {
File workingDirectory = directoryManager.getExtractionOutputDirectory(extractionId);
final ExecutableOutput cpanListOutput = executableRunner.execute(workingDirectory, cpanExe, "-l");
final List<String> listText = cpanListOutput.getStandardOutputAsList();
final ExecutableOutput showdepsOutput = executableRunner.execute(workingDirectory, cpanmExe, "--showdeps", ".");
final List<String> showdeps = showdepsOutput.getStandardOutputAsList();
final DependencyGraph dependencyGraph = cpanListParser.parse(listText, showdeps);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.CPAN, directory.toString());
final DetectCodeLocation detectCodeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.CPAN, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(detectCodeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction in project hub-detect by blackducksoftware.
the class PackratLockExtractor method extract.
public Extraction extract(final File directory, final File packratlock) {
try {
String projectName = "";
String projectVersion = "";
if (detectFileFinder.containsAllFiles(directory, "DESCRIPTION")) {
final File descriptionFile = new File(directory, "DESCRIPTION");
final List<String> descriptionText = Files.readAllLines(descriptionFile.toPath(), StandardCharsets.UTF_8);
logger.debug(descriptionText.stream().collect(Collectors.joining("\n")));
projectName = packratPackager.getProjectName(descriptionText);
projectVersion = packratPackager.getVersion(descriptionText);
}
final List<String> packratLockText = Files.readAllLines(packratlock.toPath(), StandardCharsets.UTF_8);
final DependencyGraph dependencyGraph = packratPackager.extractProjectDependencies(packratLockText);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.CRAN, directory.toString());
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.CRAN, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(codeLocation).projectName(projectName).projectVersion(projectVersion).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction in project hub-detect by blackducksoftware.
the class GoVndrExtractor method extract.
public Extraction extract(final File directory, final File vndrConfig) {
try {
final VndrParser vndrParser = new VndrParser(externalIdFactory);
final List<String> venderConfContents = Files.readAllLines(vndrConfig.toPath(), StandardCharsets.UTF_8);
logger.debug(venderConfContents.stream().collect(Collectors.joining("\n")));
final DependencyGraph dependencyGraph = vndrParser.parseVendorConf(venderConfContents);
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.GOLANG, directory.toString());
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.GO_VNDR, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(codeLocation).build();
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction in project hub-detect by blackducksoftware.
the class PodlockExtractor method extract.
public Extraction extract(final File directory, final File podlock) {
String podLockText;
try {
logger.trace(String.format("Reading from the pod lock file %s", podlock.getAbsolutePath()));
podLockText = FileUtils.readFileToString(podlock, StandardCharsets.UTF_8);
logger.debug(podLockText);
logger.trace("Finished reading from the pod lock file.");
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
DependencyGraph dependencyGraph;
try {
logger.trace("Attempting to create the dependency graph from the pod lock file.");
dependencyGraph = podlockParser.extractDependencyGraph(podLockText);
logger.trace("Finished creating the dependency graph from the pod lock file.");
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
final ExternalId externalId = externalIdFactory.createPathExternalId(Forge.COCOAPODS, directory.toString());
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.COCOAPODS, directory.toString(), externalId, dependencyGraph).build();
return new Extraction.Builder().success(codeLocation).build();
}
Aggregations