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


Java MavenProjectBuilder类代码示例

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


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

示例1: MavenEnvironment

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
public MavenEnvironment(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
        DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
        SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
        LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
        ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation,
        MojoExecution aExecution) {
    mavenSession = aMavenSession;
    buildPluginManager = aBuildPluginManager;
    log = aLog;
    dependencyTreeBuilder = aDependencyTreeBuilder;
    localRepository = aLocalRepository;
    securityDispatcher = aSecurityDispatcher;
    projectBuilder = aProjectBuilder;
    lifecycleExecutor = aLifecycleExecutor;
    artifactFactory = aArtifactFactory;
    artifactMetadataSource = aArtifactMetadataSource;
    artifactCollector = aArtifactCollector;
    runtimeInformation = aRuntimeInformation;
    mojoExecution = aExecution;
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:21,代码来源:MavenEnvironment.java

示例2: setUpProject

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
    throws Exception
{
    MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );

    ArtifactRepositoryLayout localRepositoryLayout =
        (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );

    String path = "src/test/repository";

    ArtifactRepository localRepository =
        new DefaultArtifactRepository( "local", "file://" + new File( path ).getAbsolutePath(),
                                       localRepositoryLayout );

    MavenProject project = builder.buildWithDependencies( pomFile, localRepository, null );
    // this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
    project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
    setVariableValueToObject( mojo, "project", project );
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:20,代码来源:ExecJavaMojoTest.java

示例3: DependenciesRenderer

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
/**
 * 
 * @param sink
 * @param project
 * @param mavenProjectBuilder
 * @param locale
 * @param listener
 */
public DependenciesRenderer(	Sink sink, 
								MavenProject project, 
								MavenProjectBuilder mavenProjectBuilder,
								ArtifactRepository localRepository,
								ArtifactFactory factory,
								I18N i18n,
								Locale locale, 
								ReportingResolutionListener listener,
								Log log )
{
    super( sink );

    this.project = project;
    this.locale = locale;
    this.listener = listener;
    this.mavenProjectBuilder = mavenProjectBuilder;
    this.localRepository = localRepository;
    this.i18n 	= i18n;
    this.factory = factory;
    this.log = log;
}
 
开发者ID:bsorrentino,项目名称:maven-confluence-plugin,代码行数:30,代码来源:DependenciesRenderer.java

示例4: setUpProject

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
    throws Exception
{
    MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );

    ArtifactRepositoryFactory artifactRepositoryFactory =
        (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );

    ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" );

    String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository";

    ArtifactRepository localRepository =
        artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(),
                                                            policy, policy );

    ProfileManager profileManager = new DefaultProfileManager( getContainer() );

    MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager );

    //this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
    project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
    setVariableValueToObject( mojo, "project", project );
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:25,代码来源:AbstractJnlpMojoTest.java

示例5: findEffectiveReactor

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
/**
 * Manually constructs an list of effective reactor projects by recursively
 * searching parent and submodule projects. This allows the intention of the
 * reactor to be preserved, as long as it is fully available on disk, even
 * when building a submodule directly.
 *
 * @param defaultReactor Return value to use if a comprehensive list can not
 *          be discovered.
 * @param baseProject {@link MavenProject} where invocation started.
 * @return A list of MavenProjects that can be treated as though within the
 *         current reactor.
 * @throws ProjectBuildingException
 */
public static List<MavenProject> findEffectiveReactor(
	final List<MavenProject> defaultReactor, final MavenSession session,
	final MavenProject baseProject, final MavenProjectBuilder projectBuilder,
	final ArtifactRepository localRepository) throws ProjectBuildingException
{
	final Set<MavenProject> reactor = new HashSet<MavenProject>();
	final Set<MavenProject> visited = new HashSet<MavenProject>();
	final ProfileManager profileManager = getProfileManager(session);

	findEffectiveReactor(reactor, visited, baseProject, baseProject,
		projectBuilder, localRepository, profileManager);

	if (reactor.size() <= 1 || !reactor.contains(baseProject)) return defaultReactor;
	return new ArrayList<MavenProject>(reactor);
}
 
开发者ID:scijava,项目名称:scijava-maven-plugin,代码行数:29,代码来源:DependencyUtils.java

示例6: initialize

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
public static void initialize(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
        DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
        SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
        LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
        ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation, MojoExecution aExecution) {
    ENVIRONMENT.set(new MavenEnvironment(aMavenSession, aBuildPluginManager, aLog,
            aDependencyTreeBuilder, aLocalRepository,
            aSecurityDispatcher, aProjectBuilder,
            aLifecycleExecutor, aArtifactFactory,
            aArtifactMetadataSource, aArtifactCollector, aRuntimeInformation, aExecution));
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:12,代码来源:MavenEnvironment.java

示例7: setUpProject

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
private void setUpProject( File pomFile, ExecMojo mojo )
    throws Exception
{
    MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );

    ArtifactRepositoryLayout localRepositoryLayout =
        (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" );

    String path = "src/test/repository";

    ArtifactRepository localRepository =
        new DefaultArtifactRepository( "local", "file://" + new File( path ).getAbsolutePath(),
                                       localRepositoryLayout );

    mojo.setBasedir( File.createTempFile( "mvn-temp", "txt" ).getParentFile() );

    MavenProject project = builder.buildWithDependencies( pomFile, localRepository, null );

    // this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
    project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );

    mojo.setProject( project );

    mojo.setLog( new SystemStreamLog()
    {
        public boolean isDebugEnabled()
        {
            return true;
        }
    } );
}
 
开发者ID:mojohaus,项目名称:exec-maven-plugin,代码行数:32,代码来源:ExecMojoTest.java

示例8: 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

示例9: 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

示例10: setUp

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
protected void setUp() throws Exception {
	super.setUp();

	mavenProjectBuilder = (MavenProjectBuilder) getContainer().lookup(
			MavenProjectBuilder.ROLE);
	ArtifactFactory artifactFactory = (ArtifactFactory) getContainer()
			.lookup(ArtifactFactory.ROLE);

	final Map<String, Mojo> mojos = (Map<String, Mojo>) getContainer()
			.lookupMap(Mojo.ROLE);

	for (Mojo mojo : mojos.values()) {
		if (mojo instanceof Hyperjaxb3Mojo) {
			this.mojo = (Hyperjaxb3Mojo) mojo;
		}
	}

	MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) getContainer()
			.lookup(MavenSettingsBuilder.ROLE);
	ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) getContainer()
			.lookup(ArtifactRepositoryLayout.ROLE, "default");

	Settings settings = settingsBuilder.buildSettings();

	String url = settings.getLocalRepository();

	if (!url.startsWith("file:")) {
		url = "file://" + url;
	}

	localRepository = new DefaultArtifactRepository("local", url,
			new DefaultRepositoryLayout());
}
 
开发者ID:highsource,项目名称:hyperjaxb3,代码行数:34,代码来源:RunEpisodesBPlugin.java

示例11: SnapshotFinder

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
public SnapshotFinder(final MavenProjectBuilder projectBuilder,
	final ArtifactRepository localRepository,
	@SuppressWarnings("rawtypes") final List remoteRepositories)
{
	this.projectBuilder = projectBuilder;
	this.localRepository = localRepository;
	this.remoteRepositories = remoteRepositories;
}
 
开发者ID:scijava,项目名称:scijava-maven-plugin,代码行数:9,代码来源:SnapshotFinder.java

示例12: getProjectBuilder

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
public MavenProjectBuilder getProjectBuilder() {
    return projectBuilder;
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:4,代码来源:MavenEnvironment.java

示例13: testInitialize

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
@Test
public void testInitialize() {
    assertNull(MavenEnvironment.get());

    MavenSession aMavenSession = mock(MavenSession.class);
    BuildPluginManager aBuildPluginManager = mock(BuildPluginManager.class);
    Log aLog = mock(Log.class);
    DependencyTreeBuilder aDependencyTreeBuilder = mock(DependencyTreeBuilder.class);
    ArtifactRepository aLocalRepository = mock(ArtifactRepository.class);
    SecDispatcher aSecurityDispatcher = mock(SecDispatcher.class);
    MavenProjectBuilder aProjectBuilder = mock(MavenProjectBuilder.class);
    LifecycleExecutor aLifecycleExecutor = mock(LifecycleExecutor.class);
    ArtifactFactory aArtifactFactory = mock(ArtifactFactory.class);
    ArtifactMetadataSource aArtifactMetadataSource = mock(ArtifactMetadataSource.class);
    ArtifactCollector aArtifactCollector = mock(ArtifactCollector.class);
    RuntimeInformation aRuntimeInformation = mock(RuntimeInformation.class);
    MojoExecution theExecution = mock(MojoExecution.class);

    MavenEnvironment.initialize(aMavenSession, aBuildPluginManager, aLog,
            aDependencyTreeBuilder, aLocalRepository,
            aSecurityDispatcher, aProjectBuilder,
            aLifecycleExecutor, aArtifactFactory,
            aArtifactMetadataSource, aArtifactCollector, aRuntimeInformation, theExecution);

    MavenEnvironment theMavenEnvironment = MavenEnvironment.get();
    assertNotNull(theMavenEnvironment);

    assertSame(aMavenSession, theMavenEnvironment.getMavenSession());
    assertSame(aBuildPluginManager, theMavenEnvironment.getBuildPluginManager());
    assertSame(aLog, theMavenEnvironment.getLog());
    assertSame(aDependencyTreeBuilder, theMavenEnvironment.getDependencyTreeBuilder());
    assertSame(aLocalRepository, theMavenEnvironment.getLocalRepository());
    assertSame(aSecurityDispatcher, theMavenEnvironment.getSecurityDispatcher());
    assertSame(aProjectBuilder, theMavenEnvironment.getProjectBuilder());
    assertSame(aLifecycleExecutor, theMavenEnvironment.getLifecycleExecutor());
    assertSame(aArtifactFactory, theMavenEnvironment.getArtifactFactory());
    assertSame(aArtifactMetadataSource, theMavenEnvironment.getArtifactMetadataSource());
    assertSame(aArtifactCollector, theMavenEnvironment.getArtifactCollector());
    assertSame(aRuntimeInformation, theMavenEnvironment.getRuntimeInformation());

    MavenEnvironment.cleanUp();;
    assertNull(MavenEnvironment.get());
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:44,代码来源:MavenEnvironmentTest.java

示例14: 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

示例15: PluginsRenderer

import org.apache.maven.project.MavenProjectBuilder; //导入依赖的package包/类
/**
 * @param log
 * @param sink
 * @param locale
 * @param i18n
 * @param plugins
 * @param reports
 * @param project
 * @param mavenProjectBuilder
 * @param artifactFactory
 * @param localRepository
 */
public PluginsRenderer( Log log, Sink sink, Locale locale, I18N i18n, Set plugins, Set reports,
                        MavenProject project, MavenProjectBuilder mavenProjectBuilder,
                        ArtifactFactory artifactFactory, ArtifactRepository localRepository )
{
    super( sink );

    this.log = log;

    this.locale = locale;

    this.plugins = new ArrayList( plugins );

    this.reports = new ArrayList( reports );

    this.i18n = i18n;

    this.project = project;

    this.mavenProjectBuilder = mavenProjectBuilder;

    this.artifactFactory = artifactFactory;

    this.localRepository = localRepository;
}
 
开发者ID:bsorrentino,项目名称:maven-confluence-plugin,代码行数:37,代码来源:PluginsRenderer.java


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