Search in sources :

Example 1 with PomDependenciesHandler

use of com.synopsys.integration.detectable.detectables.maven.parsing.parse.PomDependenciesHandler 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();
    }
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Extraction(com.synopsys.integration.detectable.extraction.Extraction) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) PomDependenciesHandler(com.synopsys.integration.detectable.detectables.maven.parsing.parse.PomDependenciesHandler) FileInputStream(java.io.FileInputStream)

Aggregations

BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 PomDependenciesHandler (com.synopsys.integration.detectable.detectables.maven.parsing.parse.PomDependenciesHandler)1 Extraction (com.synopsys.integration.detectable.extraction.Extraction)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1