use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class PipenvExtractor method extract.
public Extraction extract(File directory, ExecutableTarget pythonExe, ExecutableTarget pipenvExe, File setupFile, String providedProjectName, String providedProjectVersionName, boolean includeOnlyProjectTree) {
Extraction extraction;
try {
String projectName = resolveProjectName(directory, pythonExe, setupFile, providedProjectName);
String projectVersionName = resolveProjectVersionName(directory, pythonExe, setupFile, providedProjectVersionName);
ExecutableOutput pipFreezeOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("run", "pip", "freeze")));
ExecutableOutput graphOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("graph", "--bare", "--json-tree")));
PipFreeze pipFreeze = pipenvFreezeParser.parse(pipFreezeOutput.getStandardOutputAsList());
PipenvGraph pipenvGraph = pipEnvJsonGraphParser.parse(graphOutput.getStandardOutput());
CodeLocation codeLocation = pipenvTransformer.transform(projectName, projectVersionName, pipFreeze, pipenvGraph, includeOnlyProjectTree);
return new Extraction.Builder().projectName(projectName).projectVersion(projectVersionName).success(codeLocation).build();
} catch (Exception e) {
extraction = new Extraction.Builder().exception(e).build();
}
return extraction;
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class SwiftExtractor method extract.
public Extraction extract(File environmentDirectory, ExecutableTarget swiftExecutable) {
try {
toolVersionLogger.log(environmentDirectory, swiftExecutable);
SwiftPackage rootSwiftPackage = getRootSwiftPackage(environmentDirectory, swiftExecutable);
CodeLocation codeLocation = swiftPackageTransformer.transform(rootSwiftPackage);
return new Extraction.Builder().success(codeLocation).projectName(rootSwiftPackage.getName()).projectVersion(rootSwiftPackage.getVersion()).build();
} catch (IntegrationException | ExecutableRunnerException e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.extraction.Extraction 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.extraction.Extraction 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.extraction.Extraction 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();
}
Aggregations