use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class GoModCliExtractor method extract.
public Extraction extract(File directory, ExecutableTarget goExe) throws ExecutableFailedException, JsonSyntaxException, DetectableException {
List<GoListModule> goListModules = listModules(directory, goExe);
List<GoListAllData> goListAllModules = listAllModules(directory, goExe);
List<GoGraphRelationship> goGraphRelationships = listGraphRelationships(directory, goExe);
Set<String> excludedModules = listExcludedModules(directory, goExe);
GoRelationshipManager goRelationshipManager = new GoRelationshipManager(goGraphRelationships, excludedModules);
GoModDependencyManager goModDependencyManager = new GoModDependencyManager(goListAllModules, externalIdFactory);
List<CodeLocation> codeLocations = goListModules.stream().map(goListModule -> goModGraphGenerator.generateGraph(goListModule, goRelationshipManager, goModDependencyManager)).collect(Collectors.toList());
// No project info - hoping git can help with that.
return new Extraction.Builder().success(codeLocations).build();
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class IvyParseExtractor method extract.
public Extraction extract(File ivyXmlFile, File buildXmlFile) throws IOException {
try (InputStream ivyXmlInputStream = new FileInputStream(ivyXmlFile)) {
IvyDependenciesHandler ivyDependenciesHandler = new IvyDependenciesHandler(externalIdFactory);
saxParser.parse(ivyXmlInputStream, ivyDependenciesHandler);
List<Dependency> dependencies = ivyDependenciesHandler.getDependencies();
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(dependencies);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
Optional<NameVersion> projectName = projectNameParser.parseProjectName(buildXmlFile);
return new Extraction.Builder().success(codeLocation).nameVersionIfPresent(projectName).build();
} catch (SAXException e) {
return new Extraction.Builder().failure(String.format("There was an error parsing file %s: %s", ivyXmlFile.getAbsolutePath(), e.getMessage())).build();
}
}
use of com.synopsys.integration.detectable.extraction.Extraction in project synopsys-detect by blackducksoftware.
the class LernaExtractor method extract.
public Extraction extract(File sourceDirectory, File packageJson, ExecutableTarget lernaExecutable) {
try {
List<LernaPackage> lernaPackages = lernaPackageDiscoverer.discoverLernaPackages(sourceDirectory, lernaExecutable);
LernaResult lernaResult = lernaPackager.generateLernaResult(sourceDirectory, packageJson, lernaPackages);
if (lernaResult.getException().isPresent()) {
throw lernaResult.getException().get();
}
return new Extraction.Builder().projectName(lernaResult.getProjectName()).projectVersion(lernaResult.getProjectVersionName()).success(lernaResult.getCodeLocations()).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 MavenParseExtractor method extract.
public Extraction extract(File pomXmlFile, MavenParseOptions mavenParseOptions) {
try (InputStream pomXmlInputStream = new FileInputStream(pomXmlFile)) {
// we have to create a new handler or the state of all handlers would be shared.
// we could create a handler factory or some other indirection so it could be injected but for now we make a new one.
PomDependenciesHandler pomDependenciesHandler = new PomDependenciesHandler(mavenParseOptions.isIncludePlugins());
saxParser.parse(pomXmlInputStream, pomDependenciesHandler);
List<Dependency> dependencies = pomDependenciesHandler.getDependencies();
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(dependencies);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return Extraction.success(codeLocation);
} 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 NpmLockfileExtractor method extract.
/*
packageJson is optional
*/
public Extraction extract(File lockfile, File packageJson) {
try {
String lockText = FileUtils.readFileToString(lockfile, StandardCharsets.UTF_8);
String packageText = null;
if (packageJson != null) {
packageText = FileUtils.readFileToString(packageJson, StandardCharsets.UTF_8);
}
NpmPackagerResult result = npmLockfilePackager.parseAndTransform(packageText, lockText);
return new Extraction.Builder().success(result.getCodeLocation()).projectName(result.getProjectName()).projectVersion(result.getProjectVersion()).build();
} catch (IOException e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations