本文整理汇总了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;
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}