Example usage for org.apache.maven.model.building DefaultModelProcessor setModelLocator

List of usage examples for org.apache.maven.model.building DefaultModelProcessor setModelLocator

Introduction

In this page you can find the example usage for org.apache.maven.model.building DefaultModelProcessor setModelLocator.

Prototype

public DefaultModelProcessor setModelLocator(ModelLocator locator) 

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  w w  w. j a va 2 s.c om
 * @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 {//  ww  w  . j ava2s .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 . java2 s  . c o m
        return modelProcessor.read(resource.getInputStream(), null);
    } catch (IOException ex) {
        throw new IllegalStateException("Failed to build model from effective pom", ex);
    }
}