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


Java MavenProjectBuilder.build方法代码示例

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


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

示例1: getLocalRoot

import org.apache.maven.project.MavenProjectBuilder; //导入方法依赖的package包/类
/**
 * Finds the local root of the specified project.
 *
 * @param project The project to find the local root for.
 * @param localRepository the local repo.
 * @param globalProfileManager the global profile manager.
 * @param logger The logger to log to.
 * @return The local root (note this may be the project passed as an argument).
 */
public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project,
                                         ArtifactRepository localRepository, ProfileManager globalProfileManager,
                                         Log logger )
{
    logger.info( "Searching for local aggregator root..." );
    while ( true )
    {
        final File parentDir = project.getBasedir().getParentFile();
        if ( parentDir != null && parentDir.isDirectory() )
        {
            logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" );
            File parent = new File( parentDir, "pom.xml" );
            if ( parent.isFile() )
            {
                try
                {
                    final MavenProject parentProject =
                        builder.build( parent, localRepository, globalProfileManager );
                    if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) )
                    {
                        logger.debug( parentDir + " is an aggregator parent" );
                        project = parentProject;
                        continue;
                    }
                    else
                    {
                        logger.debug( parentDir + " is not an aggregator parent" );
                    }
                }
                catch ( ProjectBuildingException e )
                {
                    logger.warn( e );
                }
            }
        }
        logger.debug( "Local aggregation root is " + project.getBasedir() );
        return project;
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:49,代码来源:PomHelper.java

示例2: getLocalRoot

import org.apache.maven.project.MavenProjectBuilder; //导入方法依赖的package包/类
/**
 * Finds the local root of the specified project.
 *
 * @param project              The project to find the local root for.
 * @param localRepository      the local repo.
 * @param globalProfileManager the global profile manager.
 * @param logger               The logger to log to.
 * @return The local root (note this may be the project passed as an argument).
 */
public static MavenProject getLocalRoot( MavenProjectBuilder builder, MavenProject project,
                                         ArtifactRepository localRepository, ProfileManager globalProfileManager,
                                         Log logger )
{
    logger.info( "Searching for local aggregator root..." );
    while ( true )
    {
        final File parentDir = project.getBasedir().getParentFile();
        if ( parentDir.isDirectory() )
        {
            logger.debug( "Checking to see if " + parentDir + " is an aggregator parent" );
            File parent = new File( parentDir, "pom.xml" );
            if ( parent.isFile() )
            {
                try
                {
                    final MavenProject parentProject =
                        builder.build( parent, localRepository, globalProfileManager );
                    if ( getAllChildModules( parentProject, logger ).contains( project.getBasedir().getName() ) )
                    {
                        logger.debug( parentDir + " is an aggregator parent" );
                        project = parentProject;
                        continue;
                    }
                    else
                    {
                        logger.debug( parentDir + " is not an aggregator parent" );
                    }
                }
                catch ( ProjectBuildingException e )
                {
                    logger.warn( e );
                }
            }
        }
        logger.debug( "Local aggregation root is " + project.getBasedir() );
        return project;
    }
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:49,代码来源:PomHelper.java

示例3: findEffectiveReactor

import org.apache.maven.project.MavenProjectBuilder; //导入方法依赖的package包/类
/**
 * Helper method to recursively populate a set of {@link MavenProject}s that
 * can be considered to be within the same reactor.
 */
private static void findEffectiveReactor(final Set<MavenProject> reactor,
	final Set<MavenProject> visited, final MavenProject currentProject,
	final MavenProject target, final MavenProjectBuilder projectBuilder,
	final ArtifactRepository localRepository,
	final ProfileManager profileManager) throws ProjectBuildingException
{
	// short-circuit if already visited this project
	if (!visited.add(currentProject)) return;

	final File baseDir = currentProject.getBasedir();

	// We only are interested in local projects
	if (baseDir != null && baseDir.exists()) {

		// If the current project lists any modules , then that project itself
		// needs to be included in the reactor
		if (currentProject.getModules().size() > 0) {
			reactor.add(currentProject);
		}

		// Recursively add each submodule to the reactor
		for (final Object o : currentProject.getModules()) {
			final File submodule =
				new File(baseDir.getAbsolutePath() + File.separator + o.toString() +
					File.separator + "pom.xml");
			final MavenProject p =
				projectBuilder.build(submodule, localRepository, profileManager);
			reactor.add(p);
			findEffectiveReactor(reactor, visited, p, target, projectBuilder,
				localRepository, profileManager);
		}
	}

	// Recurse into parent
	if (currentProject.hasParent()) findEffectiveReactor(reactor, visited,
		currentProject.getParent(), target, projectBuilder, localRepository,
		profileManager);
}
 
开发者ID:scijava,项目名称:scijava-maven-plugin,代码行数:43,代码来源:DependencyUtils.java

示例4: resolveProject

import org.apache.maven.project.MavenProjectBuilder; //导入方法依赖的package包/类
@NotNull
public MavenExecutionResult resolveProject(@NotNull final File file,
                                           @NotNull final List<String> activeProfiles,
                                           @NotNull final List<String> inactiveProfiles,
                                           List<ResolutionListener> listeners) {
  MavenExecutionRequest request = createRequest(file, activeProfiles, inactiveProfiles, Collections.<String>emptyList());
  ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration();

  request.getGlobalProfileManager().loadSettingsProfiles(mySettings);

  ProfileManager globalProfileManager = request.getGlobalProfileManager();
  globalProfileManager.loadSettingsProfiles(request.getSettings());

  List<Exception> exceptions = new ArrayList<Exception>();
  MavenProject project = null;
  try {
    // copied from DefaultMavenProjectBuilder.buildWithDependencies
    MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
    project = builder.build(new File(file.getPath()), config);
    builder.calculateConcreteState(project, config, false);

    // copied from DefaultLifecycleExecutor.execute
    findExtensions(project);
    // end copied from DefaultLifecycleExecutor.execute

    Artifact projectArtifact = project.getArtifact();
    Map managedVersions = project.getManagedVersionMap();
    ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
    project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));

    ArtifactResolver resolver = getComponent(ArtifactResolver.class);
    ArtifactResolutionResult result = resolver
      .resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository,
                           project.getRemoteArtifactRepositories(), metadataSource, null, listeners);
    project.setArtifacts(result.getArtifacts());
    // end copied from DefaultMavenProjectBuilder.buildWithDependencies
  }
  catch (Exception e) {
    return handleException(e);
  }

  return new MavenExecutionResult(project, exceptions);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:MavenEmbedder.java

示例5: resolveProject

import org.apache.maven.project.MavenProjectBuilder; //导入方法依赖的package包/类
@NotNull
public MavenExecutionResult resolveProject(@NotNull final File file,
                                           @NotNull final List<String> activeProfiles,
                                           List<ResolutionListener> listeners) {
  MavenExecutionRequest request = createRequest(file, activeProfiles, Collections.<String>emptyList(), Collections.<String>emptyList());
  ProjectBuilderConfiguration config = request.getProjectBuilderConfiguration();

  request.getGlobalProfileManager().loadSettingsProfiles(mySettings);

  ProfileManager globalProfileManager = request.getGlobalProfileManager();
  globalProfileManager.loadSettingsProfiles(request.getSettings());

  List<Exception> exceptions = new ArrayList<Exception>();
  MavenProject project = null;
  try {
    // copied from DefaultMavenProjectBuilder.buildWithDependencies
    MavenProjectBuilder builder = getComponent(MavenProjectBuilder.class);
    project = builder.build(new File(file.getPath()), config);
    builder.calculateConcreteState(project, config, false);

    // copied from DefaultLifecycleExecutor.execute
    findExtensions(project);
    // end copied from DefaultLifecycleExecutor.execute

    Artifact projectArtifact = project.getArtifact();
    Map managedVersions = project.getManagedVersionMap();
    ArtifactMetadataSource metadataSource = getComponent(ArtifactMetadataSource.class);
    project.setDependencyArtifacts(project.createArtifacts(getComponent(ArtifactFactory.class), null, null));

    ArtifactResolver resolver = getComponent(ArtifactResolver.class);
    ArtifactResolutionResult result = resolver
      .resolveTransitively(project.getDependencyArtifacts(), projectArtifact, managedVersions, myLocalRepository,
                           project.getRemoteArtifactRepositories(), metadataSource, null, listeners);
    project.setArtifacts(result.getArtifacts());
    // end copied from DefaultMavenProjectBuilder.buildWithDependencies
  }
  catch (Exception e) {
    return handleException(e);
  }

  return new MavenExecutionResult(project, exceptions);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:43,代码来源:MavenEmbedder.java


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