Package org.apache.maven.project

Examples of org.apache.maven.project.Project


    }

    List readMavenXml( Project project, GoalToJellyScriptHousingMapper mapper )
        throws MavenException
    {
        Project p = project;
        List projectHousings = new ArrayList();

        // Project's Jelly script
        while ( p != null )
        {
            if ( p.hasMavenXml() )
            {
                File mavenXml = p.getMavenXml();

                JellyScriptHousing jellyScriptHousing = createJellyScriptHousing( project, mavenXml );
                jellyScriptHousing.parse( mapper );
                projectHousings.add( jellyScriptHousing );
            }
            p = p.getParent();
        }
        return projectHousings;
    }
View Full Code Here


    }

    private MavenJellyContext initialiseHousingPluginContext( JellyScriptHousing housing, MavenJellyContext baseContext )
        throws Exception
    {
        Project project = housing.getProject();

        // TODO: I think this should merge into pluginContext, but that seems to break existing jelly as it depends on
        // that kind of warped scoping. Fix this in 1.1
        MavenUtils.integrateMapInContext( housing.getPluginProperties(), baseContext );

        /*
         // Instead, we must go through each property and merge from previous plugin contexts, or the original property
         // first integrate new ones
         MavenUtils.integrateMapInContext( project.getContext().getVariables(), baseContext );
         // now integrate properties that have a new value
         Properties p = new Properties();
         for ( Iterator i = housing.getPluginProperties().keySet().iterator(); i.hasNext(); )
         {
         String key = (String) i.next();
         Object value = project.getContext().getVariable( key );
         if ( value != null )
         {
         baseContext.setVariable( key, value );
         }
         else
         {
         p.setProperty( key, (String) housing.getPluginProperties().get( key ) );
         }
         }
         MavenUtils.integrateMapInContext( p, baseContext );
         // but leave alone anything in there that is not a plugin property, and already exists in baseContext
         */
        // TODO necessary to create a new one every time?
        MavenJellyContext pluginContext = new MavenJellyContext( baseContext );
        project.pushContext( pluginContext );
        pluginContext.setInherit( true );
        pluginContext.setVariable( "context", pluginContext );
        pluginContext.setVariable( "plugin", project );
        pluginContext.setVariable( "plugin.dir", housing.getPluginDirectory() );
        pluginContext.setVariable( "plugin.resources", new File( housing.getPluginDirectory(), "plugin-resources" ) );
View Full Code Here

        throws MavenException, UnknownPluginException
    {
        JellyScriptHousing housing = (JellyScriptHousing) artifactIdToHousingMap.get( id );
        if ( housing != null )
        {
            Project project = housing.getProject();
            if ( baseContext.equals( project.getContext().getParent() ) )
            {
                log.debug( "Plugin context for " + id + " already initialised for this base context" );
                return project.getContext();
            }
            else
            {
                log.debug( "Plugin context for " + id
                    + " not initialised for this base context: initialising inside getPluginContext" );
View Full Code Here

     * @throws MavenException 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

    private static Project getNonJellyProject( File projectDescriptor, MavenJellyContext parentContext,
                                               boolean useParentPom )
        throws MavenException, IOException
    {
        // 1)
        Project project = null;
        FileReader fr = null;
        try
        {
            fr = new FileReader( projectDescriptor );
            project = new Project( fr );
        }
        catch ( Exception e )
        {
            throw new MavenException( "Error parsing project.xml '" + projectDescriptor.getAbsolutePath() + "'", e );
        }
        finally
        {
            if ( fr != null )
            {
                try
                {
                    fr.close();
                }
                catch ( IOException e )
                {
                    log.debug( "WARNING: Cannot close stream!", e );
                }
                fr = null;
            }
        }

        // 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

        throws Exception
    {
        String projectString = project.getProjectAsString();
        Expression e = JellyUtils.decomposeExpression( projectString, context );
        String newProjectString = e.evaluateAsString( context );
        project = new Project( new StringReader( newProjectString ) );
        return project;
    }
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

    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

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.