Example usage for org.apache.maven.model.locator DefaultModelLocator DefaultModelLocator

List of usage examples for org.apache.maven.model.locator DefaultModelLocator DefaultModelLocator

Introduction

In this page you can find the example usage for org.apache.maven.model.locator DefaultModelLocator DefaultModelLocator.

Prototype

DefaultModelLocator

Source Link

Usage

From source file:com.google.devtools.build.workspace.maven.Resolver.java

License:Open Source License

/**
 * Given a local path to a Maven project, this attempts to find the transitive dependencies of
 * the project./*from  ww  w  .ja va 2s.  com*/
 * @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();
}

From source file:org.springframework.boot.cli.compiler.dependencies.SpringBootDependenciesDependencyManagement.java

License:Apache License

private static Model readModel() {
    DefaultModelProcessor modelProcessor = new DefaultModelProcessor();
    modelProcessor.setModelLocator(new DefaultModelLocator());
    modelProcessor.setModelReader(new DefaultModelReader());

    try {//from  w  w w . j a  v  a2 s  .  c om
        return modelProcessor.read(
                SpringBootDependenciesDependencyManagement.class.getResourceAsStream("effective-pom.xml"),
                null);
    } catch (IOException ex) {
        throw new IllegalStateException("Failed to build model from effective pom", ex);
    }
}

From source file:org.springframework.boot.loader.thin.PomLoader.java

License:Apache License

private static Model readModel(Resource resource) {
    DefaultModelProcessor modelProcessor = new DefaultModelProcessor();
    modelProcessor.setModelLocator(new DefaultModelLocator());
    modelProcessor.setModelReader(new DefaultModelReader());

    try {//from  w w  w  . jav a 2 s .  c  o  m
        return modelProcessor.read(resource.getInputStream(), null);
    } catch (IOException ex) {
        throw new IllegalStateException("Failed to build model from effective pom", ex);
    }
}