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

项目: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);
        }
    }
}
项目:buck    文件:Resolver.java   
public Resolver(ArtifactConfig config) {
  this.modelBuilder =
      new DefaultModelBuilderFactory()
          .newInstance()
          .setProfileSelector(new DefaultProfileSelector())
          .setPluginConfigurationExpander(new DefaultPluginConfigurationExpander())
          .setPluginManagementInjector(new DefaultPluginManagementInjector())
          .setDependencyManagementImporter(new DefaultDependencyManagementImporter())
          .setDependencyManagementInjector(new DefaultDependencyManagementInjector());
  ServiceLocator locator = AetherUtil.initServiceLocator();
  this.repoSys = locator.getService(RepositorySystem.class);
  this.localRepo = new LocalRepository(Paths.get(config.mavenLocalRepo).toFile());
  this.session = newSession(repoSys, localRepo);

  this.buckRepoRoot = Paths.get(Preconditions.checkNotNull(config.buckRepoRoot));
  this.buckThirdPartyRelativePath = Paths.get(Preconditions.checkNotNull(config.thirdParty));
  this.visibility = config.visibility;

  this.repos =
      config
          .repositories
          .stream()
          .map(AetherUtil::toRemoteRepository)
          .collect(ImmutableList.toImmutableList());
}
项目:apache-archiva    文件:Maven3DependencyTreeBuilder.java   
@PostConstruct
public void initialize()
    throws PlexusSisuBridgeException
{
    factory = plexusSisuBridge.lookup( ArtifactFactory.class, "default" );

    DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
    builder = defaultModelBuilderFactory.newInstance();
}
项目:archiva    文件:Maven3DependencyTreeBuilder.java   
@PostConstruct
public void initialize()
    throws PlexusSisuBridgeException
{
    factory = plexusSisuBridge.lookup( ArtifactFactory.class, "default" );

    DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
    builder = defaultModelBuilderFactory.newInstance();
}
项目:furnace    文件:MavenContainer.java   
public RepositorySystem getRepositorySystem()
{

   final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
   locator.setServices(ModelBuilder.class, new DefaultModelBuilderFactory().newInstance());
   // Installing Wagon to fetch from HTTP repositories
   locator.setServices(WagonProvider.class, new ManualWagonProvider());
   locator.addService(TransporterFactory.class, WagonTransporterFactory.class);
   locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
   final RepositorySystem repositorySystem = locator.getService(RepositorySystem.class);
   return repositorySystem;
}
项目:furnace    文件:ProjectHelper.java   
public Model loadPomFromFile(File pomFile, String... profiles)
{
   RepositorySystem system = mavenContainer.getRepositorySystem();
   Settings settings = mavenContainer.getSettings();
   DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
   final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
            .setSystemProperties(System.getProperties())
            .setPomFile(pomFile)
            .setActiveProfileIds(settings.getActiveProfiles());
   ModelBuilder builder = new DefaultModelBuilderFactory().newInstance();
   ModelBuildingResult result;
   try
   {
      request.setModelResolver(new MavenModelResolver(system, session,
               MavenRepositories.getRemoteRepositories(mavenContainer, settings)));
      result = builder.build(request);
   }
   // wrap exception message
   catch (ModelBuildingException e)
   {
      String pomPath = request.getPomFile().getAbsolutePath();
      StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size())
               .append(" problems while building POM model from ").append(pomPath).append("\n");

      int counter = 1;
      for (ModelProblem problem : e.getProblems())
      {
         sb.append(counter++).append("/ ").append(problem).append("\n");
      }

      throw new RuntimeException(sb.toString());
   }
   return result.getEffectiveModel();
}
项目:oceano    文件:DefaultArtifactDescriptorReader.java   
public void initService( ServiceLocator locator )
{
    setLogger( locator.getService( Logger.class ) );
    setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
    setVersionResolver( locator.getService( VersionResolver.class ) );
    setArtifactResolver( locator.getService( ArtifactResolver.class ) );
    setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
    modelBuilder = locator.getService( ModelBuilder.class );
    if ( modelBuilder == null )
    {
        setModelBuilder( new DefaultModelBuilderFactory().newInstance() );
    }
}
项目:forge-furnace    文件:MavenContainer.java   
public RepositorySystem getRepositorySystem()
{

   final DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
   locator.setServices(ModelBuilder.class, new DefaultModelBuilderFactory().newInstance());
   // Installing Wagon to fetch from HTTP repositories
   locator.setServices(WagonProvider.class, new ManualWagonProvider());
   locator.addService(RepositoryConnectorFactory.class, WagonRepositoryConnectorFactory.class);
   final RepositorySystem repositorySystem = locator.getService(RepositorySystem.class);
   return repositorySystem;
}
项目:forge-furnace    文件:ProjectHelper.java   
public Model loadPomFromFile(File pomFile, String... profiles)
{
   RepositorySystem system = mavenContainer.getRepositorySystem();
   Settings settings = mavenContainer.getSettings();
   DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
   final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
            .setSystemProperties(System.getProperties())
            .setPomFile(pomFile)
            .setActiveProfileIds(settings.getActiveProfiles());
   ModelBuilder builder = new DefaultModelBuilderFactory().newInstance();
   ModelBuildingResult result;
   try
   {
      request.setModelResolver(new MavenModelResolver(system, session, mavenContainer
               .getEnabledRepositoriesFromProfile(settings)));
      result = builder.build(request);
   }
   // wrap exception message
   catch (ModelBuildingException e)
   {
      String pomPath = request.getPomFile().getAbsolutePath();
      StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size())
               .append(" problems while building POM model from ").append(pomPath).append("\n");

      int counter = 1;
      for (ModelProblem problem : e.getProblems())
      {
         sb.append(counter++).append("/ ").append(problem).append("\n");
      }

      throw new RuntimeException(sb.toString());
   }
   return result.getEffectiveModel();
}
项目:apache-archiva    文件:Maven2RepositoryStorage.java   
@PostConstruct
public void initialize()
{
    builder = new DefaultModelBuilderFactory().newInstance();

}