Package org.apache.maven.project

Examples of org.apache.maven.project.Project


    public static Project getProject( List projects, String id )
    {
        Iterator iter = projects.iterator();
        while ( iter.hasNext() )
        {
            Project project = (Project) iter.next();
            if ( project.getId().equals( id ) )
            {
                return project;
            }
        }
        return null;
View Full Code Here


        LOGGER.info( "Our processing order:" );

        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
        {
            Project p = (Project) i.next();
            LOGGER.info( p.getName() );
        }

        ArrayList reactorProjects = new ArrayList();

        Runtime r = Runtime.getRuntime();
        for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
        {
            // The basedir needs to be set for the project
            // We just need the descriptor.

            Project project = (Project) i.next();
            beforeProject( project );

            final long mb = 1024 * 1024;
            LOGGER.info( "+----------------------------------------" );
            LOGGER.info( "| " + getBanner() + " " + project.getName() );
            LOGGER.info( "| Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb ) + "M/" + ( r.totalMemory() / mb )
                + "M" );
            LOGGER.info( "+----------------------------------------" );

            // We only try to attain goals if they have been set. The reactor
View Full Code Here

    public void doTag( XMLOutput output )
        throws MissingAttributeException, JellyTagException
    {
        checkAttribute( getDescriptor(), "descriptor" );

        Project project = null;
        try
        {
            project = MavenUtils.getProject( getDescriptor(), getMavenContext().getMavenSession().getRootContext() );
            project.verifyDependencies();
            getMavenContext().getMavenSession().getPluginManager().processDependencies( project );

            // Set the project goals if they have been specified.
            List goalList = new ArrayList();
            if ( getGoals() != null )
View Full Code Here

            displayGoals( true, plugin );

            if ( plugin != null )
            {
                Project project = mavenSession.getPluginProjectFromGoal( plugin );
                if ( ( project != null ) && ( project.getDescription() != null ) )
                {
                    LOGGER.info( wrapConsoleMessage( project.getDescription(), 0, CONSOLE_WIDTH ) );
                }
            }

            exit( RC_OK );
        }
View Full Code Here

            String title = MavenUtils.getMessage( "displayProjectHelp.title" );
            LOGGER.info( title );
            LOGGER.info( format( "", title.length(), '=' ) );
            LOGGER.info( "" );

            Project rootProject = mavenSession.getRootProject();
            if ( ( rootProject.getBuild() != null ) && ( rootProject.getBuild().getDefaultGoal() != null ) )
            {
                String defaultGoal = rootProject.getBuild().getDefaultGoal();
                String msg = MavenUtils.getMessage( "displayGoals.defaultGoal" ) + defaultGoal;
                LOGGER.info( wrapConsoleMessage( msg, WRAP_INDENT + 1, CONSOLE_WIDTH ) );
            }

            displayGoals( false, null, goals );
View Full Code Here

        else
        {
            // A type of null pattern. We don't really have a root project per se
            // but want the rest of the system to believe there is for consistency
            // in the rest of the code.
            Project globalProject = new Project();
            globalProject.setId( "Global Project" );
            // even though it doesn't exist, we need something to
            globalProject.setFile( descriptorFile );

            // We need to set the project of the root context so the plugin manager
            // has a project to run jelly scripts against.
            getRootContext().setProject( globalProject );

            globalProject.setContext( getRootContext() );
            setRootProject( globalProject );
        }
    }
View Full Code Here

     *             when any errors occur
     */
    public static Project getProject( File projectDescriptor, MavenJellyContext parentContext, boolean useParentPom )
        throws MavenException
    {
        Project project = null;
        try
        {
            project = getNonJellyProject( projectDescriptor, parentContext, useParentPom );
            project = getJellyProject( project );
            project.setFile( projectDescriptor );

            // Fully initialize the project.
            project.initialize();
        }
        catch ( IntrospectionException e )
        {
            throw new MavenException( "Error creating a string from the project", e );
        }
View Full Code Here

     */
    public static Project getNonJellyProject( File projectDescriptor, MavenJellyContext parentContext,
                                              boolean useParentPom ) throws MavenException, IOException
    {
        // 1)
        Project project = null;
        try
        {
            project = new Project( projectDescriptor.toURL() );
        }
        catch ( Exception e )
        {
            throw new MavenException( "Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'", e );
        }

        // 2)
        MavenJellyContext context =
            MavenUtils.createContextNoDefaults( projectDescriptor.getParentFile(), parentContext );

        // 3)
        String pomToExtend = project.getExtend();

        if ( ( pomToExtend != null ) && useParentPom )
        {
            // We must look in the <extend/> element for expressions that may be present as
            //
            // <extend>../project.xml</extend>
            Expression e = JellyUtils.decomposeExpression( pomToExtend, context );
            pomToExtend = e.evaluateAsString( context );
            pomToExtend = MavenUtils.makeAbsolutePath( projectDescriptor.getParentFile(), pomToExtend );
            project.setExtend( pomToExtend );

            File parentPom = new File( pomToExtend );
            parentPom = parentPom.getCanonicalFile();
            if ( !parentPom.exists() )
            {
                throw new FileNotFoundException( "Parent POM not found: " + parentPom );
            }

            String parentPomPath = parentPom.getPath();
            if ( parentPomPath.equals( projectDescriptor.getCanonicalPath() ) )
            {
                throw new MavenException( "Parent POM is equal to the current POM" );
            }

            Project parent = (Project) parentPoms.get( parentPomPath );
            if ( parent == null )
            {
                parent = getNonJellyProject( parentPom, parentContext, true );
                parent.setFile( parentPom );
                parentPoms.put( parentPom.getCanonicalPath(), parent );
                context.setParent( parent.getContext() );
            }

            // Map in the parent context which already has the properties loaded
            integrateMapInContext( parent.getContext().getVariables(), context );

            project.mergeParent( parent );
        }

        project.resolveIds();
View Full Code Here

        List projects = new ArrayList();

        for ( int i = 0; i < files.length; i++ )
        {
            Project p = getProject( new File( files[i] ), context );
            projects.add( p );
        }

        return projects;
    }
View Full Code Here

        JellyUtils.populateVariables( context, originalContext );

        // We don't want the context or the parent being written out into the XML which
        // is the interpolated POM.
        project.setContext( null );
        Project parent = project.getParent();
        project.setParent( null );

        // Interpolate
        project = getInterpolatedPOM( project, context );
View Full Code Here

TOP

Related Classes of org.apache.maven.project.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.