Package org.apache.maven.plugin

Examples of org.apache.maven.plugin.MojoExecution


    {
        List reports = new ArrayList();
       
        for ( Iterator it = reportExecutions.iterator(); it.hasNext(); )
        {
            MojoExecution reportExecution = (MojoExecution) it.next();
            PluginDescriptor pluginDescriptor = reportExecution.getMojoDescriptor().getPluginDescriptor();
           
            try
            {
                MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
View Full Code Here


                                configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ),
                                                                      configuration );
                            }

                            MojoDescriptor desc = getMojoDescriptor( lifecyclePluginDescriptor, lifecycleGoal );
                            MojoExecution mojoExecution = new MojoExecution( desc, configuration );
                            addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution,
                                                    session.getSettings() );
                        }
                    }

                    if ( phase.getConfiguration() != null )
                    {
                        // Merge in general configuration for a phase.
                        // TODO: this is all kind of backwards from the POMM. Let's align it all under 2.1.
                        //   We should create a new lifecycle executor for modelVersion >5.0.0
                        for ( Iterator j = lifecycleMappings.values().iterator(); j.hasNext(); )
                        {
                            List tasks = (List) j.next();

                            for ( Iterator k = tasks.iterator(); k.hasNext(); )
                            {
                                MojoExecution exec = (MojoExecution) k.next();

                                Xpp3Dom configuration = Xpp3Dom.mergeXpp3Dom(
                                    new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ), exec.getConfiguration() );

                                exec.setConfiguration( configuration );
                            }
                        }
                    }

                }
            }

            removeFromLifecycle( forkEntryPoints, lifecycleMappings );
        }

        if ( targetPhase != null )
        {
            Lifecycle lifecycle = getLifecycleForPhase( targetPhase );

            executeGoalWithLifecycle( targetPhase, forkEntryPoints, session, lifecycleMappings, project, lifecycle );
        }
        else
        {
            String goal = mojoDescriptor.getExecuteGoal();
            MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
            executeGoals( Collections.singletonList( new MojoExecution( desc ) ), forkEntryPoints, session, project );
        }
    }
View Full Code Here

        {
            List tasks = (List) lifecycleIterator.next();

            for ( Iterator taskIterator = tasks.iterator(); taskIterator.hasNext(); )
            {
                MojoExecution execution = (MojoExecution) taskIterator.next();

                if ( lifecycleForkers.contains( execution.getMojoDescriptor() ) )
                {
                    taskIterator.remove();
                    getLogger().warn( "Removing: " + execution.getMojoDescriptor().getGoal()
                                      + " from forked lifecycle, to prevent recursive invocation." );
                }
            }
        }
    }
View Full Code Here

                        throw new LifecycleExecutionException( "Mojo: \'" + goal +
                            "\' requires direct invocation. It cannot be used as part of lifecycle: \'" +
                            project.getPackaging() + "\'." );
                    }

                    addToLifecycleMappings( lifecycleMappings, phase, new MojoExecution( mojoDescriptor ),
                                            session.getSettings() );
                }
            }

            if ( phase.equals( selectedPhase ) )
View Full Code Here

            }

            // We have to check to see that the inheritance rules have been applied before binding this mojo.
            if ( execution.isInheritanceApplied() || mojoDescriptor.isInheritedByDefault() )
            {
                MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() );

                String phase = execution.getPhase();

                if ( phase == null )
                {
View Full Code Here

    private void executeStandaloneGoal( final String task, final Stack forkEntryPoints, final MavenSession session, final MavenProject project )
        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
    {
        // guaranteed to come from the CLI and not be part of a phase
        MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true, false );
        executeGoals( Collections.singletonList( new MojoExecution( mojoDescriptor, MojoExecution.CLI_EXECUTION_ID ) ),
                      forkEntryPoints, session, project );
    }
View Full Code Here

    private void executeGoals( final List goals, final Stack forkEntryPoints, final MavenSession session, final MavenProject project )
        throws LifecycleExecutionException, BuildFailureException, PluginNotFoundException
    {
        for ( Iterator i = goals.iterator(); i.hasNext(); )
        {
            MojoExecution mojoExecution = (MojoExecution) i.next();

            MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
           
            PlexusConfiguration configuration = mojoDescriptor.getMojoConfiguration();
            boolean usesReactorProjects = mojoDescriptor.isAggregator() || usesSessionOrReactorProjects( configuration );
           
            if ( usesReactorProjects )
            {
                calculateAllConcreteStates( session );
            }
            else
            {
                calculateConcreteState( project, session, true );
            }
           
            calculateConcreteConfiguration( mojoExecution, project, session );
           
            List reportExecutions = null;
            if ( mojoDescriptor.isRequiresReports() )
            {
                reportExecutions = getReportExecutions( project, forkEntryPoints, mojoExecution, session );
            }
           
            boolean hasFork = false;
            if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
            {
                hasFork = true;
            }
            else if ( reportExecutions != null )
            {
                for ( Iterator it = reportExecutions.iterator(); it.hasNext(); )
                {
                    MojoExecution reportExecution = (MojoExecution) it.next();
                    MojoDescriptor reportDescriptor = reportExecution.getMojoDescriptor();
                    if ( reportDescriptor.getExecutePhase() != null || reportDescriptor.getExecuteGoal() != null )
                    {
                        hasFork = true;
                    }
                }
            }
           
            if ( hasFork )
            {
                // NOTE: This must always happen, regardless of treatment of reactorProjects below, because
                // if we're in a forked execution right now, the current project will itself be an execution project of
                // something in the reactorProjects list, and won't have a next-stage executionProject created
                // for it otherwise, which leaves the project == null for the upcoming forked execution.
                createExecutionProject( project, session, true );
               
                if ( usesReactorProjects )
                {
                    List reactorProjects = session.getSortedProjects();
                    for ( Iterator it = reactorProjects.iterator(); it.hasNext(); )
                    {
                        MavenProject reactorProject = (MavenProject) it.next();
                        createExecutionProject( reactorProject, session, false );
                    }
                }
            }

            if ( mojoDescriptor.getExecutePhase() != null || mojoDescriptor.getExecuteGoal() != null )
            {
                forkEntryPoints.push( mojoDescriptor );

                forkLifecycle( mojoDescriptor, forkEntryPoints, session, project, mojoExecution.getExecutionId() );

                forkEntryPoints.pop();
            }
           
            if ( mojoDescriptor.isRequiresReports() )
            {
                List reports = getReports( reportExecutions, project, mojoExecution, session );

                mojoExecution.setReports( reports );

                for ( Iterator j = mojoExecution.getForkedExecutions().iterator(); j.hasNext(); )
                {
                    MojoExecution forkedExecution = (MojoExecution) j.next();
                    MojoDescriptor descriptor = forkedExecution.getMojoDescriptor();

                    if ( descriptor.getExecutePhase() != null )
                    {
                        forkEntryPoints.push( descriptor );

                        forkLifecycle( descriptor, forkEntryPoints, session, project, forkedExecution.getExecutionId() );

                        forkEntryPoints.pop();
                    }
                }
            }
View Full Code Here

                else
                {
                    id = mojoExecution.getExecutionId();
                }
               
                MojoExecution reportExecution;
                if ( id.startsWith( MojoExecution.DEFAULT_EXEC_ID_PREFIX ) )
                {
                    reportExecution = new MojoExecution( mojoDescriptor );
                }
                else
                {
                    reportExecution = new MojoExecution( mojoDescriptor, id );
                }

                reports.add( reportExecution );
            }
        }
View Full Code Here

    {
        List reports = new ArrayList();
       
        for ( Iterator it = reportExecutions.iterator(); it.hasNext(); )
        {
            MojoExecution reportExecution = (MojoExecution) it.next();
            PluginDescriptor pluginDescriptor = reportExecution.getMojoDescriptor().getPluginDescriptor();
           
            try
            {
                MavenReport reportMojo = pluginManager.getReport( project, reportExecution, session );
View Full Code Here

                                configuration = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ),
                                                                      configuration );
                            }

                            MojoDescriptor desc = getMojoDescriptor( lifecyclePluginDescriptor, lifecycleGoal );
                            MojoExecution mojoExecution;
                            if ( executionId.startsWith( MojoExecution.DEFAULT_EXEC_ID_PREFIX ) )
                            {
                                mojoExecution = new MojoExecution( desc, configuration );
                            }
                            else
                            {
                                mojoExecution = new MojoExecution( desc, configuration, executionId );
                            }
                           
                            addToLifecycleMappings( lifecycleMappings, phase.getId(), mojoExecution,
                                                    session.getSettings() );
                        }
                    }

                    if ( phase.getConfiguration() != null )
                    {
                        // Merge in general configuration for a phase.
                        // TODO: this is all kind of backwards from the POMM. Let's align it all under 2.1.
                        //   We should create a new lifecycle executor for modelVersion >5.0.0
                        for ( Iterator j = lifecycleMappings.values().iterator(); j.hasNext(); )
                        {
                            List tasks = (List) j.next();

                            for ( Iterator k = tasks.iterator(); k.hasNext(); )
                            {
                                MojoExecution exec = (MojoExecution) k.next();

                                Xpp3Dom configuration = Xpp3Dom.mergeXpp3Dom(
                                    new Xpp3Dom( (Xpp3Dom) phase.getConfiguration() ), exec.getConfiguration() );

                                exec.setConfiguration( configuration );
                            }
                        }
                    }

                }
            }

            removeFromLifecycle( forkEntryPoints, lifecycleMappings );
        }

        if ( targetPhase != null )
        {
            Lifecycle lifecycle = getLifecycleForPhase( targetPhase );

            executeGoalWithLifecycle( targetPhase, forkEntryPoints, session, lifecycleMappings, project, lifecycle );
        }
        else
        {
            String goal = mojoDescriptor.getExecuteGoal();
            MojoDescriptor desc = getMojoDescriptor( pluginDescriptor, goal );
            executeGoals( Collections.singletonList( new MojoExecution( desc, goal ) ), forkEntryPoints, session, project );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.plugin.MojoExecution

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.