Search in sources :

Example 1 with SwiftPackage

use of com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage 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();
    }
}
Also used : SwiftPackage(com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) IntegrationException(com.synopsys.integration.exception.IntegrationException) Extraction(com.synopsys.integration.detectable.extraction.Extraction) ExecutableRunnerException(com.synopsys.integration.executable.ExecutableRunnerException)

Example 2 with SwiftPackage

use of com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage in project synopsys-detect by blackducksoftware.

the class SwiftPackageTransformer method transform.

public CodeLocation transform(SwiftPackage rootSwiftPackage) {
    MutableDependencyGraph dependencyGraph = new MutableMapDependencyGraph();
    for (SwiftPackage swiftPackageDependency : rootSwiftPackage.getDependencies()) {
        Dependency dependency = convertToDependency(dependencyGraph, swiftPackageDependency);
        dependencyGraph.addChildToRoot(dependency);
    }
    return new CodeLocation(dependencyGraph);
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) SwiftPackage(com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 3 with SwiftPackage

use of com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage in project synopsys-detect by blackducksoftware.

the class SwiftPackageTransformer method convertToDependency.

private Dependency convertToDependency(MutableDependencyGraph dependencyGraph, SwiftPackage swiftPackage) {
    ExternalId externalId;
    if ("unspecified".equals(swiftPackage.getVersion())) {
        externalId = externalIdFactory.createModuleNamesExternalId(SWIFT_FORGE, swiftPackage.getName());
    } else {
        externalId = externalIdFactory.createNameVersionExternalId(SWIFT_FORGE, swiftPackage.getName(), swiftPackage.getVersion());
    }
    Dependency dependency = new Dependency(externalId);
    for (SwiftPackage swiftPackageDependency : swiftPackage.getDependencies()) {
        Dependency childDependency = convertToDependency(dependencyGraph, swiftPackageDependency);
        dependencyGraph.addParentWithChild(dependency, childDependency);
    }
    return dependency;
}
Also used : SwiftPackage(com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

SwiftPackage (com.synopsys.integration.detectable.detectables.swift.model.SwiftPackage)3 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)2 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)1 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 Extraction (com.synopsys.integration.detectable.extraction.Extraction)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 ExecutableRunnerException (com.synopsys.integration.executable.ExecutableRunnerException)1