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


Java ProjectBuilder.build方法代码示例

本文整理汇总了Java中org.apache.maven.project.ProjectBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java ProjectBuilder.build方法的具体用法?Java ProjectBuilder.build怎么用?Java ProjectBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.project.ProjectBuilder的用法示例。


在下文中一共展示了ProjectBuilder.build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveDependenciesFromPOM

import org.apache.maven.project.ProjectBuilder; //导入方法依赖的package包/类
public List<Dependency> resolveDependenciesFromPOM(File pomFile) throws Exception
{
   PlexusContainer plexus = new PlexusContainer();
   List<Dependency> result;
   try
   {
      ProjectBuildingRequest request = getBuildingRequest(plexus);
      request.setResolveDependencies(true);
      ProjectBuilder builder = plexus.lookup(ProjectBuilder.class);
      ProjectBuildingResult build = builder.build(pomFile, request);
      result = build.getDependencyResolutionResult().getDependencies();
   }
   finally
   {
      plexus.shutdown();
   }
   return result;
}
 
开发者ID:forge,项目名称:furnace,代码行数:19,代码来源:ProjectHelper.java

示例2: testSensibleSession

import org.apache.maven.project.ProjectBuilder; //导入方法依赖的package包/类
public void testSensibleSession(MavenSession s) throws Exception {
    MavenSession ms = newMavenSession();  //((LicenseAuditMojo)mojo).mavenSession;
    assertNotNull( ms );
    assertNotNull( ms.getLocalRepository().getBasedir() );
    System.out.println("Basedir: "+ms.getLocalRepository().getBasedir());
    // The following artifacts could not be resolved: org.apache.maven:maven-core:jar:2.0.7

    RepositorySystem rs = lookup(RepositorySystem.class);
    assertNotNull( rs );

    // check we can access stuff in remote repos
    // (fails if we don't have proper aether connectors + transforms,
    // or if we've not "populated" with default remote repos)
    ArtifactResult art;
    art = resolveArtifact(rs, ms, "org.apache.maven:maven-core:jar:2.0.7");
    System.out.println(art);
    assertNotNull(art.getArtifact());

    // check we avoid this:
    // [ERROR] Failed to determine Java version for profile java-1.5-detected @ org.apache.commons:commons-parent:22, /Users/alex/.m2/repository/org/apache/commons/commons-parent/22/commons-parent-22.pom, line 909, column 14
    art = resolveArtifact(rs, ms, "org.apache.commons:commons-lang3:3.1");
    System.out.println(art);
    assertNotNull(art.getArtifact());
    
    ProjectBuilder projectBuilder = lookup(ProjectBuilder.class);
    ProjectBuildingResult res = projectBuilder.build(RepositoryUtils.toArtifact(art.getArtifact()), true, ms.getProjectBuildingRequest());
    System.out.println(res);
    if (!res.getProblems().isEmpty()) fail("Problems: "+res.getProblems());
}
 
开发者ID:ahgittin,项目名称:license-audit-maven-plugin,代码行数:30,代码来源:BetterAbstractMojoTestCaseTest.java

示例3: addAllProjects

import org.apache.maven.project.ProjectBuilder; //导入方法依赖的package包/类
private void addAllProjects(
    final List<MavenProject> projects,
    final MavenProject project,
    final ProjectBuilder builder,
    final ProjectBuildingRequest request
) {

  final List<String> modules = root.getModules();
  File file = project.getFile().getParentFile();
  for (String module : modules) {
    final File moduleFile = new File(
        new File(file, module),
        "pom.xml"
    );
    try {
      final ProjectBuildingResult result = builder.build(
          moduleFile,
          request
      );
      if (!result.getProblems().isEmpty()) {
        X_Log.warn(getClass(), "Problems encountered looking up module ", moduleFile, result.getProblems());
      }
      projects.add(result.getProject());
      if (!result.getProject().getModules().isEmpty()) {
        addAllProjects(projects, result.getProject(), builder, request);
      }
    } catch (ProjectBuildingException e) {
      X_Log.warn(getClass(), "Unable to build module for ", moduleFile);
    }
  }
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:32,代码来源:ProjectIterable.java


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