当前位置: 首页>>代码示例>>Java>>正文


Java DefaultModelBuildingRequest类代码示例

本文整理汇总了Java中org.apache.maven.model.building.DefaultModelBuildingRequest的典型用法代码示例。如果您正苦于以下问题:Java DefaultModelBuildingRequest类的具体用法?Java DefaultModelBuildingRequest怎么用?Java DefaultModelBuildingRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultModelBuildingRequest类属于org.apache.maven.model.building包,在下文中一共展示了DefaultModelBuildingRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateDependencyResolutionContext

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
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);
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:DependencyManagementBomTransformation.java

示例2: testLocationTrackerShouldBeExcludedFromInterpolation

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public void testLocationTrackerShouldBeExcludedFromInterpolation()
{
    Properties props = new Properties();
    props.setProperty( "expression", "value" );
    DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
    request.setUserProperties( props );

    InputSource source = new InputSource();
    source.setLocation( "${expression}" );
    source.setModelId( "${expression}" );
    Model model = new Model();
    model.setLocation( "", new InputLocation( 1, 1, source ) );

    SimpleProblemCollector problems = new SimpleProblemCollector();
    StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
    interpolator.interpolateObject( model, model, null, request, problems );

    assertProblemFree( problems );
    assertEquals( "${expression}", source.getLocation() );
    assertEquals( "${expression}", source.getModelId() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:22,代码来源:StringSearchModelInterpolatorTest.java

示例3: getModelFromFile

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**f
 * Read the given POM so it can be used as the source of coordinates, etc.
 * during artifact construction. Note that if this object's
 * {@link #snapshots} property is true, and we're working with a development
 * build ({@link #buildNumber} ends with 'd'), the POM is modified to remove
 * the SNAPSHOT qualifier.
 * 
 * @param pom
 *            the POM file containing the artifact metadata
 * @return A Maven model to be used at
 *         {@link com.isomorphic.maven.packaging.Module#Module(Model)}
 *         Module construction
 * @throws ModelBuildingException
 *             if the Model cannot be built from the given POM
 * @throws IOException
 *             if the Model cannot be built from the given POM
 */
private Model getModelFromFile(File pom) throws ModelBuildingException, IOException {

    if (buildNumber.endsWith("d") && !snapshots) {
        LOGGER.info(
            "Rewriting file to remove SNAPSHOT qualifier from development POM '{}'",
            pom.getName());
        String content = FileUtils.readFileToString(pom);
        content = content.replaceAll("-SNAPSHOT", "");
        FileUtils.write(pom, content);
    }

    ModelBuildingRequest request = new DefaultModelBuildingRequest();
    request.setPomFile(pom);

    ModelBuildingResult result = modelBuilder.build(request);
    return result.getEffectiveModel();
}
 
开发者ID:isomorphic-software,项目名称:isc-maven-plugin,代码行数:35,代码来源:AbstractPackagerMojo.java

示例4: modelBuildingRequestTemplate

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
@Bean
public ModelBuildingRequest modelBuildingRequestTemplate(RepositorySystemSession repositorySystemSession, LocalRepositoryModelResolver localRepositoryModelResolver) {
    Properties userProperties = new Properties();
    userProperties.putAll(repositorySystemSession.getUserProperties());

    Properties systemProperties = new Properties();
    systemProperties.putAll(repositorySystemSession.getSystemProperties());

    DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
    request.setProcessPlugins(true);
    request.setLocationTracking(true);
    request.setModelResolver(localRepositoryModelResolver);
    request.setUserProperties(userProperties);
    request.setSystemProperties(systemProperties);

    return request;
}
 
开发者ID:release-engineering,项目名称:redhat-repository-validator,代码行数:18,代码来源:AppConfig.java

示例5: complexModelBuilding

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**
 *
 * 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;
}
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:20,代码来源:Main.java

示例6: createModelBuildingRequest

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private ModelBuildingRequest createModelBuildingRequest( File pomFile )
{

    FlattenModelResolver resolver = new FlattenModelResolver( this.localRepository, this.artifactFactory,
        this.dependencyResolver, this.session.getProjectBuildingRequest(), this.session.getAllProjects() );
    Properties userProperties = this.session.getUserProperties();
    List<String> activeProfiles = this.session.getRequest().getActiveProfiles();

    // @formatter:off
    ModelBuildingRequest buildingRequest =
        new DefaultModelBuildingRequest().setUserProperties( userProperties ).setSystemProperties( System.getProperties() ).setPomFile( pomFile ).setModelResolver( resolver ).setActiveProfileIds( activeProfiles );
    // @formatter:on
    return buildingRequest;
}
 
开发者ID:mojohaus,项目名称:flatten-maven-plugin,代码行数:15,代码来源:FlattenMojo.java

示例7: testCreateEffectivePom

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
/**
 * Tests method to create effective POM.
 *
 * @throws Exception if something goes wrong.
 */
@Test
public void testCreateEffectivePom()
    throws Exception
{

    String magicValue = "magic-value";
    Properties userProperties = new Properties();
    userProperties.setProperty( "cmd.test.property", magicValue );

    File pomFile = new File( "src/test/resources/cmdpropertysubstituion/pom.xml" );
    ArtifactRepository localRepository = new MavenArtifactRepository();
    localRepository.setLayout( new DefaultRepositoryLayout() );
    ArtifactFactory artifactFactory = new DefaultArtifactFactory();
    ArtifactHandlerManager artifactHandlerManager = new DefaultArtifactHandlerManager();
    setDeclaredField( artifactFactory, "artifactHandlerManager", artifactHandlerManager );
    Map<String, ArtifactHandler> artifactHandlers = new HashMap<String, ArtifactHandler>();
    setDeclaredField( artifactHandlerManager, "artifactHandlers", artifactHandlers );
    DefaultDependencyResolver depencencyResolver = new DefaultDependencyResolver();
    DefaultProjectBuildingRequest projectBuildingRequest = new DefaultProjectBuildingRequest();
    FlattenModelResolver resolver = new FlattenModelResolver( localRepository, artifactFactory,
            depencencyResolver, projectBuildingRequest, Collections.<MavenProject>emptyList() );
    ModelBuildingRequest buildingRequest =
        new DefaultModelBuildingRequest().setPomFile( pomFile ).setModelResolver( resolver ).setUserProperties( userProperties );
    Model effectivePom = FlattenMojo.createEffectivePom( buildingRequest, false );
    assertThat( effectivePom.getName() ).isEqualTo( magicValue );
}
 
开发者ID:mojohaus,项目名称:flatten-maven-plugin,代码行数:32,代码来源:CreateEffectivePomTest.java

示例8: createModel

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
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();
}
 
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:10,代码来源:Maven.java

示例9: loadPomFromFile

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
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();
}
 
开发者ID:forge,项目名称:furnace,代码行数:35,代码来源:ProjectHelper.java

示例10: validateEffective

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private SimpleProblemCollector validateEffective( String pom, int level )
    throws Exception
{
    ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level );

    SimpleProblemCollector problems = new SimpleProblemCollector();

    validator.validateEffectiveModel( read( pom ), request, problems );

    return problems;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:12,代码来源:DefaultModelValidatorTest.java

示例11: validateRaw

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private SimpleProblemCollector validateRaw( String pom, int level )
    throws Exception
{
    ModelBuildingRequest request = new DefaultModelBuildingRequest().setValidationLevel( level );

    SimpleProblemCollector problems = new SimpleProblemCollector();

    validator.validateRawModel( read( pom ), request, problems );

    return problems;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:12,代码来源:DefaultModelValidatorTest.java

示例12: createModelBuildingRequest

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private ModelBuildingRequest createModelBuildingRequest( Properties p )
{
    ModelBuildingRequest config = new DefaultModelBuildingRequest();
    if ( p != null )
    {
        config.setSystemProperties( p );
    }
    return config;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:10,代码来源:AbstractModelInterpolatorTest.java

示例13: testFinalFieldsExcludedFromInterpolation

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
public void testFinalFieldsExcludedFromInterpolation()
{
    Properties props = new Properties();
    props.setProperty( "expression", "value" );
    DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
    request.setUserProperties( props );

    SimpleProblemCollector problems = new SimpleProblemCollector();
    StringSearchModelInterpolator interpolator = new StringSearchModelInterpolator();
    interpolator.interpolateObject( new ClassWithFinalField(), new Model(), null, request, problems );

    assertProblemFree(  problems );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:14,代码来源:StringSearchModelInterpolatorTest.java

示例14: loadPomModel

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
private Model loadPomModel(Path pomFile) {
  DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
  request.setPomFile(pomFile.toFile());
  try {
    ModelBuildingResult result = modelBuilder.build(request);
    return result.getRawModel();
  } catch (ModelBuildingException | IllegalArgumentException e) {
    // IllegalArg can be thrown if the parent POM cannot be resolved.
    throw new RuntimeException(e);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:Resolver.java

示例15: constructModel

import org.apache.maven.model.building.DefaultModelBuildingRequest; //导入依赖的package包/类
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);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:15,代码来源:Pom.java


注:本文中的org.apache.maven.model.building.DefaultModelBuildingRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。