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


Java MavenSession.getCurrentProject方法代码示例

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


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

示例1: DefaultPluginPrefixRequest

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
/**
 * Creates a request for the specified plugin prefix and build session. The provided build session will be used to
 * configure repository settings. If the session has a current project, its plugin repositories and model will be
 * used as well.
 * 
 * @param prefix The plugin prefix to resolve, must not be {@code null}.
 * @param session The build session from which to derive further settings, must not be {@code null}.
 */
public DefaultPluginPrefixRequest( String prefix, MavenSession session )
{
    setPrefix( prefix );

    setRepositorySession( session.getRepositorySession() );

    MavenProject project = session.getCurrentProject();
    if ( project != null )
    {
        setRepositories( project.getRemotePluginRepositories() );
        setPom( project.getModel() );
    }

    setPluginGroups( session.getPluginGroups() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:24,代码来源:DefaultPluginPrefixRequest.java

示例2: retrieveContext

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
Map<String, Object> retrieveContext( MavenSession session )
{
    Map<String, Object> context = null;

    if ( session != null )
    {
        PluginDescriptor desc = new PluginDescriptor();
        desc.setGroupId( PluginDescriptor.getDefaultPluginGroupId() );
        desc.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( "toolchains" ) );

        MavenProject current = session.getCurrentProject();
        
        if ( current != null )
        {
            //TODO: why is this using the context
            context = session.getPluginContext( desc, current );
        }
    }

    return ( context != null ) ? context : new HashMap<String, Object>();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:22,代码来源:DefaultToolchainManager.java

示例3: testSystemScopeDependencyIsPresentInTheCompileClasspathElements

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements()
    throws Exception
{
    File pom = getProject( "it0063" );
    
    Properties eps = new Properties();
    eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() );        
    
    MavenSession session = createMavenSession( pom, eps );
    MavenProject project = session.getCurrentProject();
    
    // Here we will actually not have any artifacts because the ProjectDependenciesResolver is not involved here. So
    // right now it's not valid to ask for artifacts unless plugins require the artifacts.
    
    project.getCompileClasspathElements();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:ProjectBuilderTest.java

示例4: testSystemScopeDependencyIsPresentInTheCompileClasspathElements

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public void testSystemScopeDependencyIsPresentInTheCompileClasspathElements()
    throws Exception
{
    File pom = getProject( "it0063" );

    Properties eps = new Properties();
    eps.setProperty( "jre.home", new File( pom.getParentFile(), "jdk/jre" ).getPath() );

    MavenSession session = createMavenSession( pom, eps );
    MavenProject project = session.getCurrentProject();

    project.setArtifacts( resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session ) );
            
    List<String> elements = project.getCompileClasspathElements();
    assertEquals( 2, elements.size() );
    
    @SuppressWarnings( "deprecation" )
    List<Artifact> artifacts = project.getCompileArtifacts();
    assertEquals( 1, artifacts.size() );
    assertTrue( artifacts.get( 0 ).getFile().getName().endsWith( "tools.jar" ) );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:22,代码来源:ProjectDependenciesResolverTest.java

示例5: invokePITest

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
private void invokePITest() {
    MavenEnvironment theEnvironment = MavenEnvironment.get();
    MavenSession theSession = theEnvironment.getMavenSession();
    for (MavenProject theProject : theSession.getAllProjects()) {
        MavenProject theOldProject = theSession.getCurrentProject();

        log.info("Invoking PITest for {}:{}", theProject.getGroupId(), theProject.getArtifact());

        theSession.setCurrentProject(theProject);

        String theCurrentVersion = getClass().getPackage().getImplementationVersion();

        List<Dependency> theDependencies = new ArrayList<>();
        theDependencies.add(dependency("de.mirkosertic.mavensonarsputnik", "pitest-plugins", theCurrentVersion));

        try {

            executeMojo(
                    plugin(
                            groupId("org.pitest"),
                            artifactId("pitest-maven"),
                            version(properties.getProperty("pitest.pluginversion")),
                            theDependencies
                    ),
                    goal(properties.getProperty("pitest.pluginGoal")),
                    createConfiguration(),
                    executionEnvironment(
                            theProject,
                            theEnvironment.getMavenSession(),
                            theEnvironment.getBuildPluginManager()
                    )
            );
        } catch (Exception e) {
            log.warn("Error invoking PITest, but analysis will continue", e);
        } finally {
            theSession.setCurrentProject(theOldProject);
        }
    }
}
 
开发者ID:mirkosertic,项目名称:mavensonarsputnik,代码行数:40,代码来源:PITestProcessor.java

示例6: afterProjectsRead

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
	MavenProject project = session.getCurrentProject();
	SourceFoldersUtils.addSourceFolders(project);
	addPluginExecutions(project);
	logger.info("Maven builder extension initialized");
}
 
开发者ID:javabuild,项目名称:builder-parent,代码行数:8,代码来源:MavenBuilderExtension.java

示例7: newDependencyContext

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public DependencyContext newDependencyContext( MavenSession session, List<MojoExecution> mojoExecutions )
{
    Set<String> scopesToCollect = new TreeSet<String>();
    Set<String> scopesToResolve = new TreeSet<String>();

    collectDependencyRequirements( scopesToResolve, scopesToCollect, mojoExecutions );

    return new DependencyContext( session.getCurrentProject(), scopesToCollect, scopesToResolve );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:10,代码来源:MojoExecutor.java

示例8: execute

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public void execute( MavenSession session, List<MojoExecution> mojoExecutions, ProjectIndex projectIndex )
    throws LifecycleExecutionException

{
    DependencyContext dependencyContext = newDependencyContext( session, mojoExecutions );

    PhaseRecorder phaseRecorder = new PhaseRecorder( session.getCurrentProject() );

    for ( MojoExecution mojoExecution : mojoExecutions )
    {
        execute( session, mojoExecution, projectIndex, dependencyContext, phaseRecorder );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:14,代码来源:MojoExecutor.java

示例9: findPluginForPrefix

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public Plugin findPluginForPrefix( String prefix, MavenSession session )
    throws NoPluginFoundForPrefixException
{
    // [prefix]:[goal]

    if ( session.getCurrentProject() != null )
    {
        try
        {
            lifecyclePluginResolver.resolveMissingPluginVersions( session.getCurrentProject(), session );
        }
        catch ( PluginVersionResolutionException e )
        {
            // not critical here
            logger.debug( e.getMessage(), e );
        }
    }

    PluginPrefixRequest prefixRequest = new DefaultPluginPrefixRequest( prefix, session );
    PluginPrefixResult prefixResult = pluginPrefixResolver.resolve( prefixRequest );

    Plugin plugin = new Plugin();
    plugin.setGroupId( prefixResult.getGroupId() );
    plugin.setArtifactId( prefixResult.getArtifactId() );

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

示例10: DefaultPluginVersionRequest

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
/**
 * Creates a request for the specified plugin by copying settings from the specified build session. If the session
 * has a current project, its plugin repositories will be used as well.
 * 
 * @param plugin The plugin for which to resolve a version, must not be {@code null}.
 * @param repositoryRequest The repository request to copy from, must not be {@code null}.
 */
public DefaultPluginVersionRequest( Plugin plugin, MavenSession session )
{
    setGroupId( plugin.getGroupId() );
    setArtifactId( plugin.getArtifactId() );

    setRepositorySession( session.getRepositorySession() );

    MavenProject project = session.getCurrentProject();
    if ( project != null )
    {
        setRepositories( project.getRemotePluginRepositories() );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:DefaultPluginVersionRequest.java

示例11: setupPluginRealm

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public synchronized void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session,
                                           ClassLoader parent, List<String> imports, DependencyFilter filter )
    throws PluginResolutionException, PluginContainerException
{
    Plugin plugin = pluginDescriptor.getPlugin();

    MavenProject project = session.getCurrentProject();

    Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );

    PluginRealmCache.Key cacheKey =
        pluginRealmCache.createKey( plugin, parent, foreignImports, filter, project.getRemotePluginRepositories(),
                                    session.getRepositorySession() );

    PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey );

    if ( cacheRecord != null )
    {
        pluginDescriptor.setClassRealm( cacheRecord.realm );
        pluginDescriptor.setArtifacts( new ArrayList<Artifact>( cacheRecord.artifacts ) );
        for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
        {
            componentDescriptor.setRealm( cacheRecord.realm );
        }
    }
    else
    {
        createPluginRealm( pluginDescriptor, session, parent, foreignImports, filter );

        cacheRecord =
            pluginRealmCache.put( cacheKey, pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts() );
    }

    pluginRealmCache.register( project, cacheRecord );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:36,代码来源:DefaultMavenPluginManager.java

示例12: PluginParameterExpressionEvaluator

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution )
{
    this.session = session;
    this.mojoExecution = mojoExecution;
    this.properties = session.getExecutionProperties();
    this.project = session.getCurrentProject();

    String basedir = null;

    if ( project != null )
    {
        File projectFile = project.getBasedir();

        // this should always be the case for non-super POM instances...
        if ( projectFile != null )
        {
            basedir = projectFile.getAbsolutePath();
        }
    }

    if ( ( basedir == null ) && ( session != null ) )
    {
        basedir = session.getExecutionRootDirectory();
    }

    if ( basedir == null )
    {
        basedir = System.getProperty( "user.dir" );
    }

    this.basedir = basedir;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:33,代码来源:PluginParameterExpressionEvaluator.java

示例13: testSystemScopeDependencies

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public void testSystemScopeDependencies()
    throws Exception
{
    MavenSession session = createMavenSession( null );
    MavenProject project = session.getCurrentProject();

    new ProjectBuilder( project )
        .addDependency( "com.mycompany", "system-dependency", "1.0", Artifact.SCOPE_SYSTEM, new File( getBasedir(), "pom.xml" ).getAbsolutePath() );

    Set<Artifact> artifactDependencies =
        resolver.resolve( project, Collections.singleton( Artifact.SCOPE_COMPILE ), session );
    assertEquals( 1, artifactDependencies.size() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:14,代码来源:ProjectDependenciesResolverTest.java

示例14: getMavenProject

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
/** Load the Maven project for the given artifact.
 *
 * @param artifact the artifact.
 * @return the maven project.
 */
public MavenProject getMavenProject(Artifact artifact) {
	try {
		final MavenSession session = getMavenSession();
		final MavenProject current = session.getCurrentProject();
		final MavenProject prj = getMavenProjectBuilder().buildFromRepository(
				artifact,
				current.getRemoteArtifactRepositories(),
				session.getLocalRepository());
		return prj;
	} catch (ProjectBuildingException e) {
		getLog().warn(e);
	}
	return null;
}
 
开发者ID:gallandarakhneorg,项目名称:afc,代码行数:20,代码来源:AbstractArakhneMojo.java

示例15: HibernateExpressionEvaluator

import org.apache.maven.execution.MavenSession; //导入方法依赖的package包/类
public HibernateExpressionEvaluator( MavenSession session )
{
    super( session, new MojoExecution( new MojoDescriptor() ), new DefaultPathTranslator(), null,
           session.getCurrentProject(), session.getExecutionProperties() );
}
 
开发者ID:frincon,项目名称:openeos,代码行数:6,代码来源:HibernateExpressionEvaluator.java


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