Java 类org.apache.maven.model.building.DefaultModelBuilder 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DependencyManagementBomTransformation.java   
private void updateDependencyResolutionContext(
        List<Map<String, String>> bomDependencies) {
    URI[] uris = Grape.getInstance().resolve(null,
            bomDependencies.toArray(new Map[bomDependencies.size()]));
    DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
    for (URI uri : uris) {
        try {
            DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
            request.setModelResolver(new GrapeModelResolver());
            request.setModelSource(new UrlModelSource(uri.toURL()));
            request.setSystemProperties(System.getProperties());
            Model model = modelBuilder.build(request).getEffectiveModel();
            this.resolutionContext.addDependencyManagement(
                    new MavenModelDependencyManagement(model));
        }
        catch (Exception ex) {
            throw new IllegalStateException("Failed to build model for '" + uri
                    + "'. Is it a valid Maven bom?", ex);
        }
    }
}
项目:spring-boot-concourse    文件:DependencyManagementBomTransformation.java   
private void updateDependencyResolutionContext(
        List<Map<String, String>> bomDependencies) {
    URI[] uris = Grape.getInstance().resolve(null,
            bomDependencies.toArray(new Map[bomDependencies.size()]));
    DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
    for (URI uri : uris) {
        try {
            DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
            request.setModelResolver(new GrapeModelResolver());
            request.setModelSource(new UrlModelSource(uri.toURL()));
            request.setSystemProperties(System.getProperties());
            Model model = modelBuilder.build(request).getEffectiveModel();
            this.resolutionContext.addDependencyManagement(
                    new MavenModelDependencyManagement(model));
        }
        catch (Exception ex) {
            throw new IllegalStateException("Failed to build model for '" + uri
                    + "'. Is it a valid Maven bom?", ex);
        }
    }
}
项目:contestparser    文件:DependencyManagementBomTransformation.java   
private void updateDependencyResolutionContext(
        List<Map<String, String>> bomDependencies) {
    URI[] uris = Grape.getInstance().resolve(null,
            bomDependencies.toArray(new Map[bomDependencies.size()]));
    DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
    for (URI uri : uris) {
        try {
            DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
            request.setModelResolver(new GrapeModelResolver());
            request.setModelSource(new UrlModelSource(uri.toURL()));
            request.setSystemProperties(System.getProperties());
            Model model = modelBuilder.build(request).getEffectiveModel();
            this.resolutionContext.addDependencyManagement(
                    new MavenModelDependencyManagement(model));
        }
        catch (Exception ex) {
            throw new IllegalStateException("Failed to build model for '" + uri
                    + "'. Is it a valid Maven bom?", ex);
        }
    }
}
项目:playground    文件:Main.java   
/**
 *
 * TODO: This does not currently work.
 *
 */
@SuppressWarnings("unused")
private static Model complexModelBuilding(File file) throws Exception {

    ModelBuilder builder = new DefaultModelBuilder();
    ModelBuildingRequest request = new DefaultModelBuildingRequest();
    request.setProcessPlugins(false);
    request.setPomFile(file);
    // request.setModelResolver(new ModelResolver() {});
    request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);

    //noinspection UnnecessaryLocalVariable
    Model model = builder.build(request).getEffectiveModel();
    return model;
}