use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class CpanCliExtractor method extract.
public Extraction extract(ExecutableTarget cpanExe, ExecutableTarget cpanmExe, File workingDirectory) throws ExecutableRunnerException {
toolVersionLogger.log(workingDirectory, cpanExe);
// TODO: Consider command runner to reduce cognitive load.
ExecutableOutput cpanListOutput = executableRunner.execute(ExecutableUtils.createFromTarget(workingDirectory, cpanExe, "-l"));
List<String> listText = cpanListOutput.getStandardOutputAsList();
ExecutableOutput showdepsOutput = executableRunner.execute(ExecutableUtils.createFromTarget(workingDirectory, cpanmExe, "--showdeps", "."));
List<String> showdeps = showdepsOutput.getStandardOutputAsList();
DependencyGraph dependencyGraph = cpanListParser.parse(listText, showdeps);
CodeLocation detectCodeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(detectCodeLocation).build();
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PackratLockExtractor method extract.
public Extraction extract(File directory, File packratlock) {
try {
NameVersion nameVersion = determineProjectNameVersion(directory);
List<String> packratLockText = Files.readAllLines(packratlock.toPath(), StandardCharsets.UTF_8);
DependencyGraph dependencyGraph = packRatLockFileParser.parseProjectDependencies(packratLockText);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).projectName(nameVersion.getName()).projectVersion(nameVersion.getVersion()).build();
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GradleInspectorExtractor method extract.
public Extraction extract(File directory, ExecutableTarget gradleExe, @Nullable String gradleCommand, ProxyInfo proxyInfo, File gradleInspector, File outputDirectory) throws ExecutableFailedException {
try {
toolVersionLogger.log(directory, gradleExe);
gradleRunner.runGradleDependencies(directory, gradleExe, gradleInspector, gradleCommand, proxyInfo, outputDirectory);
File rootProjectMetadataFile = fileFinder.findFile(outputDirectory, "rootProjectMetadata.txt");
List<File> reportFiles = fileFinder.findFiles(outputDirectory, "*_dependencyGraph.txt");
List<CodeLocation> codeLocations = new ArrayList<>();
reportFiles.stream().map(gradleReportParser::parseReport).filter(Optional::isPresent).map(Optional::get).map(gradleReportTransformer::transform).forEach(codeLocations::add);
Optional<NameVersion> projectNameVersion = Optional.empty();
if (rootProjectMetadataFile != null) {
projectNameVersion = parseRootProjectMetadataFile(rootProjectMetadataFile);
} else {
logger.warn("Gradle inspector did not create a meta data report so no project version information was found.");
}
return new Extraction.Builder().success(codeLocations).nameVersionIfPresent(projectNameVersion).build();
} catch (IOException e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PubSpecExtractor method extract.
public Extraction extract(File pubSpecLockFile, @Nullable File pubSpecYamlFile) throws IOException {
List<String> pubSpecLockLines = Files.readAllLines(pubSpecLockFile.toPath(), StandardCharsets.UTF_8);
Optional<NameVersion> nameVersion = Optional.empty();
if (pubSpecYamlFile != null) {
List<String> pubSpecYamlLines = Files.readAllLines(pubSpecYamlFile.toPath(), StandardCharsets.UTF_8);
nameVersion = nameVersionParser.parseNameVersion(pubSpecYamlLines);
}
DependencyGraph dependencyGraph = pubSpecLockParser.parse(pubSpecLockLines);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).nameVersionIfPresent(nameVersion).build();
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GoModGraphGenerator method generateGraph.
public CodeLocation generateGraph(GoListModule projectModule, GoRelationshipManager goRelationshipManager, GoModDependencyManager goModDependencyManager) {
DependencyGraph graph = new BasicDependencyGraph();
String moduleName = projectModule.getPath();
if (goRelationshipManager.hasRelationshipsFor(moduleName)) {
goRelationshipManager.getRelationshipsFor(moduleName).stream().map(relationship -> relationship.getChild().getName()).forEach(childName -> addModuleToGraph(childName, null, graph, goRelationshipManager, goModDependencyManager));
}
return new CodeLocation(graph, externalIdFactory.createNameVersionExternalId(Forge.GOLANG, projectModule.getPath(), projectModule.getVersion()));
}
Aggregations