use of com.synopsys.integration.detectable.detectables.swift.lock.model.PackageResolvedResult in project synopsys-detect by blackducksoftware.
the class XcodeWorkspaceDetectable method extract.
@Override
public Extraction extract(ExtractionEnvironment extractionEnvironment) throws IOException, ParserConfigurationException, SAXException {
List<CodeLocation> codeLocations = new LinkedList<>();
if (foundPackageResolvedFile != null) {
PackageResolvedResult localResult = packageResolvedExtractor.extract(foundPackageResolvedFile);
Optional<FailedDetectableResult> failedDetectableResult = localResult.getFailedDetectableResult();
if (failedDetectableResult.isPresent()) {
return Extraction.failure(failedDetectableResult.get());
}
codeLocations.add(new CodeLocation(localResult.getDependencyGraph(), environment.getDirectory()));
}
if (foundWorkspaceDataFile != null) {
XcodeWorkspaceResult xcodeWorkspaceResult = xcodeWorkspaceExtractor.extract(foundWorkspaceDataFile, workspaceDirectory);
if (xcodeWorkspaceResult.isFailure()) {
return Extraction.failure(xcodeWorkspaceResult.getFailedDetectableResults());
}
codeLocations.addAll(xcodeWorkspaceResult.getCodeLocations());
}
return Extraction.success(codeLocations);
}
use of com.synopsys.integration.detectable.detectables.swift.lock.model.PackageResolvedResult in project synopsys-detect by blackducksoftware.
the class XcodeWorkspaceExtractor method extract.
public XcodeWorkspaceResult extract(File workspaceDataFile, File workspaceDirectory) throws IOException, ParserConfigurationException, SAXException {
String workspaceFileContents = FileUtils.readFileToString(workspaceDataFile, Charset.defaultCharset());
XcodeWorkspace xcodeWorkspace = xcodeWorkspaceParser.parse(workspaceFileContents);
xcodeWorkspaceFormatChecker.checkForVersionCompatibility(xcodeWorkspace);
List<CodeLocation> codeLocations = new LinkedList<>();
List<FailedDetectableResult> failedDetectableResults = new LinkedList<>();
for (XcodeFileReference fileReference : xcodeWorkspace.getFileReferences()) {
File workspaceReferencedDirectory = workspaceDirectory.getParentFile().toPath().resolve(fileReference.getRelativeLocation()).toFile();
if (!workspaceReferencedDirectory.exists()) {
logger.warn("Failed to find subproject '{}' as defined in the workspace at '{}'", workspaceReferencedDirectory, workspaceDataFile.getParentFile().getAbsolutePath());
continue;
}
switch(fileReference.getFileReferenceType()) {
case DIRECTORY:
PackageResolvedResult swiftProjectResult = extractStandalonePackageResolved(workspaceReferencedDirectory);
swiftProjectResult.getFailedDetectableResult().ifPresent(failedDetectableResults::add);
codeLocations.add(new CodeLocation(swiftProjectResult.getDependencyGraph(), workspaceReferencedDirectory));
break;
case XCODE_PROJECT:
PackageResolvedResult xcodeProjectResult = extractFromXcodeProject(workspaceReferencedDirectory);
xcodeProjectResult.getFailedDetectableResult().ifPresent(failedDetectableResults::add);
codeLocations.add(new CodeLocation(xcodeProjectResult.getDependencyGraph(), workspaceReferencedDirectory));
break;
default:
throw new UnsupportedOperationException(String.format("Unrecognized FileReferenceType: %s", fileReference.getFileReferenceType()));
}
}
if (CollectionUtils.isNotEmpty(failedDetectableResults)) {
return XcodeWorkspaceResult.failure(failedDetectableResults);
}
return XcodeWorkspaceResult.success(codeLocations);
}
Aggregations