use of com.synopsys.integration.bdio.graph.DependencyGraph 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.synopsys.integration.bdio.graph.DependencyGraph 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.synopsys.integration.bdio.graph.DependencyGraph 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.synopsys.integration.bdio.graph.DependencyGraph in project hub-detect by blackducksoftware.
the class GopkgLockParser method parseDepLock.
public DependencyGraph parseDepLock(final String depLockContents) {
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
final GopkgLock gopkgLock = new Toml().read(depLockContents).to(GopkgLock.class);
for (final Project project : gopkgLock.getProjects()) {
if (project != null) {
final NameVersion projectNameVersion = createProjectNameVersion(project);
project.getPackages().stream().map(packageName -> createDependencyName(projectNameVersion.getName(), packageName)).map(dependencyName -> createGoDependency(dependencyName, projectNameVersion.getVersion())).forEach(graph::addChildToRoot);
}
}
return graph;
}
use of com.synopsys.integration.bdio.graph.DependencyGraph 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