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

项目:incubator-netbeans    文件:ExtensionModule.java   
@Override
    public void configure(Binder binder) {
        binder.bind(PluginDependenciesResolver.class).to(NbPluginDependenciesResolver.class);
        binder.bind(Roles.componentKey(RepositoryConnectorFactory.class, "offline")).to(OfflineConnector.class);
        //#212214 the EnhancedLocalRepositoryManager will claim artifact is not locally present even if file is there but some metadata is missing
        //we just replace it with the simple variant that relies on file's presence only. 
        //I'm a bit afraid to remove the binding altogether, that's why we map simple to enhanced.
        binder.bind(Roles.componentKey(LocalRepositoryManagerFactory.class, "enhanced")).to(SimpleLocalRepositoryManagerFactory.class);

        //exxperimental only.
//        binder.bind(InheritanceAssembler.class).to(NbInheritanceAssembler.class);
        binder.bind(ModelBuilder.class).to(NBModelBuilder.class);
    }
项目: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;
}
项目:tycho-gen    文件:Maven.java   
public static Model createModel(File pom) throws ModelBuildingException, ComponentLookupException
{
    ModelBuilder builder = mavenContainer.lookup(ModelBuilder.class);
    ModelBuildingRequest req = new DefaultModelBuildingRequest();
    req.setProcessPlugins(false);
    req.setModelResolver(new RepoModelResolver());
    req.setPomFile(pom);
    return builder.build(req).getEffectiveModel();
}
项目: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() );
    }
}
项目:oceano    文件:DefaultArtifactDescriptorReader.java   
public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder )
{
    if ( modelBuilder == null )
    {
        throw new IllegalArgumentException( "model builder has not been specified" );
    }
    this.modelBuilder = modelBuilder;
    return this;
}
项目:buck    文件:Pom.java   
private Model constructModel(File file, Model model) {
  ModelBuilder modelBuilder = MODEL_BUILDER_FACTORY.newInstance();

  try {
    ModelBuildingRequest req = new DefaultModelBuildingRequest().setPomFile(file);
    ModelBuildingResult modelBuildingResult = modelBuilder.build(req);

    Model constructed = Preconditions.checkNotNull(modelBuildingResult.getRawModel());

    return merge(model, constructed);
  } catch (ModelBuildingException e) {
    throw new RuntimeException(e);
  }
}
项目: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();
}