use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class MavenCliExtractor method extract.
// TODO: Limit 'extractors' to 'execute' and 'read', delegate all other work.
public Extraction extract(File directory, ExecutableTarget mavenExe, MavenCliExtractorOptions mavenCliExtractorOptions) throws ExecutableFailedException {
toolVersionLogger.log(directory, mavenExe);
List<String> commandArguments = commandParser.parseCommandString(mavenCliExtractorOptions.getMavenBuildCommand().orElse("")).stream().filter(arg -> !arg.equals("dependency:tree")).collect(Collectors.toList());
commandArguments.add("dependency:tree");
// Force maven to use a single thread to ensure the tree output is in the correct order.
commandArguments.add("-T1");
ExecutableOutput mvnExecutableResult = executableRunner.executeSuccessfully(ExecutableUtils.createFromTarget(directory, mavenExe, commandArguments));
List<String> mavenOutput = mvnExecutableResult.getStandardOutputAsList();
List<String> excludedScopes = mavenCliExtractorOptions.getMavenExcludedScopes();
List<String> includedScopes = mavenCliExtractorOptions.getMavenIncludedScopes();
List<String> excludedModules = mavenCliExtractorOptions.getMavenExcludedModules();
List<String> includedModules = mavenCliExtractorOptions.getMavenIncludedModules();
List<MavenParseResult> mavenResults = mavenCodeLocationPackager.extractCodeLocations(directory.toString(), mavenOutput, excludedScopes, includedScopes, excludedModules, includedModules);
List<CodeLocation> codeLocations = Bds.of(mavenResults).map(MavenParseResult::getCodeLocation).toList();
Optional<MavenParseResult> firstWithName = Bds.of(mavenResults).firstFiltered(it -> StringUtils.isNotBlank(it.getProjectName()));
Extraction.Builder builder = new Extraction.Builder().success(codeLocations);
if (firstWithName.isPresent()) {
builder.projectName(firstWithName.get().getProjectName());
builder.projectVersion(firstWithName.get().getProjectVersion());
}
return builder.build();
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class MavenCodeLocationPackager method createMavenParseResult.
private MavenParseResult createMavenParseResult(String sourcePath, String line, DependencyGraph graph) {
Dependency dependency = textToProject(line);
if (null != dependency) {
String codeLocationSourcePath = sourcePath;
if (!sourcePath.endsWith(dependency.getName())) {
codeLocationSourcePath += "/" + dependency.getName();
}
CodeLocation codeLocation = new CodeLocation(graph, dependency.getExternalId(), new File(codeLocationSourcePath));
return new MavenParseResult(dependency.getName(), dependency.getVersion(), codeLocation);
}
return null;
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GoVndrExtractor method extract.
public Extraction extract(File vndrConfig) {
try {
VndrParser vndrParser = new VndrParser(externalIdFactory);
List<String> vendorConfContents = Files.readAllLines(vndrConfig.toPath(), StandardCharsets.UTF_8);
logger.debug(String.join("\n", vendorConfContents));
DependencyGraph dependencyGraph = vndrParser.parseVendorConf(vendorConfContents);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).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 YarnTransformer method generateCodeLocations.
public List<CodeLocation> generateCodeLocations(YarnLockResult yarnLockResult, List<NameVersion> externalDependencies, @Nullable ExcludedIncludedWildcardFilter workspaceFilter) throws MissingExternalIdException {
List<CodeLocation> codeLocations = new LinkedList<>();
logger.debug("Adding root dependencies for project: {}:{}", yarnLockResult.getRootPackageJson().getNameString(), yarnLockResult.getRootPackageJson().getVersionString());
DependencyGraph rootProjectGraph = buildGraphForProjectOrWorkspace(yarnLockResult, yarnLockResult.getRootPackageJson(), externalDependencies);
codeLocations.add(new CodeLocation(rootProjectGraph));
for (YarnWorkspace workspace : yarnLockResult.getWorkspaceData().getWorkspaces()) {
if ((workspaceFilter == null) || workspaceFilter.shouldInclude(workspace.getWorkspacePackageJson().getDirRelativePath())) {
logger.debug("Adding root dependencies for workspace: {}", workspace.getWorkspacePackageJson().getDirRelativePath());
DependencyGraph workspaceGraph = buildGraphForProjectOrWorkspace(yarnLockResult, workspace.getWorkspacePackageJson().getPackageJson(), externalDependencies);
ExternalId workspaceExternalId = externalIdFactory.createNameVersionExternalId(Forge.NPMJS, workspace.getWorkspacePackageJson().getDirRelativePath(), "local");
codeLocations.add(new CodeLocation(workspaceGraph, workspaceExternalId));
}
}
return codeLocations;
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class SwiftExtractor method extract.
public Extraction extract(File environmentDirectory, ExecutableTarget swiftExecutable) throws ExecutableFailedException {
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();
}
Aggregations