public void execute()

in src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java [773:885]


    public void execute() throws MojoExecutionException, MojoFailureException {
        if (skipInvocation) {
            getLog().info("Skipping invocation per configuration."
                    + " If this is incorrect, ensure the skipInvocation parameter is not set to true.");
            return;
        }

        if (encoding == null || encoding.isEmpty()) {
            getLog().warn("File encoding has not been set, using platform encoding "
                    + Charset.defaultCharset().displayName() + ", i.e. build is platform dependent!");
        }

        // done it here to prevent issues with concurrent access in case of parallel run
        if (!disableReports) {
            setupReportsFolder();
        }

        List<BuildJob> buildJobs;
        if (pom == null) {
            try {
                buildJobs = getBuildJobs();
            } catch (final IOException e) {
                throw new MojoExecutionException(
                        "Error retrieving POM list from includes, " + "excludes, and projects directory. Reason: "
                                + e.getMessage(),
                        e);
            }
        } else {
            try {
                projectsDirectory = pom.getCanonicalFile().getParentFile();
            } catch (IOException e) {
                throw new MojoExecutionException(
                        "Failed to discover projectsDirectory from " + "pom File parameter. Reason: " + e.getMessage(),
                        e);
            }

            buildJobs = Collections.singletonList(new BuildJob(pom.getName()));
        }

        if (buildJobs.isEmpty()) {
            doFailIfNoProjects();

            getLog().info("No projects were selected for execution.");
            return;
        }

        setupActualMavenVersion();

        handleScriptRunnerWithScriptClassPath();

        File projectsDir = projectsDirectory;

        if (cloneProjectsTo == null && "maven-plugin".equals(project.getPackaging())) {
            cloneProjectsTo = new File(project.getBuild().getDirectory(), "its");
        }

        if (updateOnly) {
            if (cloneProjectsTo == null) {
                getLog().warn("updateOnly functionality is not supported without cloning the projects");
            } else if (lastModifiedRecursive(projectsDirectory) <= lastModifiedRecursive(cloneProjectsTo)) {
                getLog().debug("Skipping invocation as cloned projects are up-to-date "
                        + "and updateOnly parameter is set to true.");
                return;
            } else {
                getLog().debug("Cloned projects are out of date");
            }
        }

        if (cloneProjectsTo != null) {
            Collection<String> collectedProjects = this.collectedProjects;
            if (collectedProjects == null) {
                collectedProjects = new LinkedHashSet<>();
                for (BuildJob buildJob : buildJobs) {
                    collectProjects(projectsDirectory, buildJob.getProject(), collectedProjects, true);
                }
            }
            cloneProjects(collectedProjects);
            addMissingDotMvnDirectory(cloneProjectsTo, buildJobs);
            projectsDir = cloneProjectsTo;
        } else {
            getLog().warn("Filtering of parent/child POMs is not supported without cloning the projects");
        }

        // First run setup jobs.
        List<BuildJob> setupBuildJobs = getSetupJobs(buildJobs);

        if (!setupBuildJobs.isEmpty()) {
            // Run setup jobs in single thread mode.
            //
            // Jobs are ordered according to ordinal value from invoker.properties
            getLog().info("Running " + setupBuildJobs.size() + " setup job" + ((setupBuildJobs.size() < 2) ? "" : "s")
                    + ":");
            runBuilds(projectsDir, setupBuildJobs, 1);
            getLog().info("Setup done.");
        }

        List<BuildJob> nonSetupBuildJobs = getNonSetupJobs(buildJobs);

        if (setupBuildJobs.isEmpty() || setupBuildJobs.stream().allMatch(BuildJob::isNotError)) {
            // We will run the non setup jobs with the configured
            // parallelThreads number.
            runBuilds(projectsDir, nonSetupBuildJobs, getParallelThreadsCount());
        } else {
            for (BuildJob buildJob : nonSetupBuildJobs) {
                buildJob.setResult(BuildJob.Result.SKIPPED);
                buildJob.setFailureMessage("Skipped due to setup job(s) failure");
                writeBuildReport(buildJob);
            }
        }

        writeSummaryFile(buildJobs);
        processResults(new InvokerSession(buildJobs));
    }