Search in sources :

Example 1 with DefaultModelReader

use of org.apache.maven.model.io.DefaultModelReader in project bazel by bazelbuild.

the class Resolver method resolvePomDependencies.

/**
   * Given a local path to a Maven project, this attempts to find the transitive dependencies of
   * the project.
   * @param projectPath The path to search for Maven projects.
   */
public String resolvePomDependencies(String projectPath) {
    DefaultModelProcessor processor = new DefaultModelProcessor();
    processor.setModelLocator(new DefaultModelLocator());
    processor.setModelReader(new DefaultModelReader());
    File pom = processor.locatePom(new File(projectPath));
    FileModelSource pomSource = new FileModelSource(pom);
    // First resolve the model source locations.
    resolveSourceLocations(pomSource);
    // Next, fully resolve the models.
    resolveEffectiveModel(pomSource, Sets.<String>newHashSet(), null);
    return pom.getAbsolutePath();
}
Also used : DefaultModelReader(org.apache.maven.model.io.DefaultModelReader) DefaultModelProcessor(org.apache.maven.model.building.DefaultModelProcessor) FileModelSource(org.apache.maven.model.building.FileModelSource) DefaultModelLocator(org.apache.maven.model.locator.DefaultModelLocator) File(java.io.File)

Example 2 with DefaultModelReader

use of org.apache.maven.model.io.DefaultModelReader in project spring-boot by spring-projects.

the class SpringBootDependenciesDependencyManagement method readModel.

private static Model readModel() {
    DefaultModelProcessor modelProcessor = new DefaultModelProcessor();
    modelProcessor.setModelLocator(new DefaultModelLocator());
    modelProcessor.setModelReader(new DefaultModelReader());
    try {
        return modelProcessor.read(SpringBootDependenciesDependencyManagement.class.getResourceAsStream("spring-boot-dependencies-effective-bom.xml"), null);
    } catch (IOException ex) {
        throw new IllegalStateException("Failed to build model from effective pom", ex);
    }
}
Also used : DefaultModelReader(org.apache.maven.model.io.DefaultModelReader) DefaultModelProcessor(org.apache.maven.model.building.DefaultModelProcessor) DefaultModelLocator(org.apache.maven.model.locator.DefaultModelLocator) IOException(java.io.IOException)

Aggregations

DefaultModelProcessor (org.apache.maven.model.building.DefaultModelProcessor)2 DefaultModelReader (org.apache.maven.model.io.DefaultModelReader)2 DefaultModelLocator (org.apache.maven.model.locator.DefaultModelLocator)2 File (java.io.File)1 IOException (java.io.IOException)1 FileModelSource (org.apache.maven.model.building.FileModelSource)1