private void runBuilds()

in src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java [1279:1382]


    private void runBuilds(final File projectsDir, List<BuildJob> buildJobs, int runWithParallelThreads)
            throws MojoExecutionException {
        if (!localRepositoryPath.exists()) {
            localRepositoryPath.mkdirs();
        }

        // -----------------------------------------------
        // interpolate settings file
        // -----------------------------------------------

        File interpolatedSettingsFile = interpolateSettings(settingsFile);

        final File mergedSettingsFile = mergeSettings(interpolatedSettingsFile);

        final CharSequence actualJreVersion;
        // @todo if ( javaVersions ) ... to be picked up from toolchains
        if (javaHome != null) {
            actualJreVersion = resolveExternalJreVersion();
        } else {
            actualJreVersion = SelectorUtils.getJreVersion();
        }

        final Path projectsPath = this.projectsDirectory.toPath();

        Set<Path> folderGroupSet = new HashSet<>();
        folderGroupSet.add(Paths.get("."));
        for (BuildJob buildJob : buildJobs) {
            Path p = Paths.get(buildJob.getProject());

            if (Files.isRegularFile(projectsPath.resolve(p))) {
                p = p.getParent();
            }

            if (p != null) {
                p = p.getParent();
            }

            while (p != null && folderGroupSet.add(p)) {
                p = p.getParent();
            }
        }

        List<Path> folderGroup = new ArrayList<>(folderGroupSet);
        Collections.sort(folderGroup);

        final Map<Path, Properties> globalInvokerProperties = new HashMap<>();

        for (Path path : folderGroup) {
            Properties ancestorProperties =
                    globalInvokerProperties.get(projectsPath.resolve(path).getParent());

            Path currentInvokerProperties = projectsPath.resolve(path).resolve(invokerPropertiesFile);

            Properties currentProperties;
            if (Files.isRegularFile(currentInvokerProperties)) {
                if (ancestorProperties != null) {
                    currentProperties = new Properties(ancestorProperties);

                } else {
                    currentProperties = new Properties();
                }
            } else {
                currentProperties = ancestorProperties;
            }

            if (Files.isRegularFile(currentInvokerProperties)) {
                try (InputStream in = new FileInputStream(currentInvokerProperties.toFile())) {
                    currentProperties.load(in);
                } catch (IOException e) {
                    throw new MojoExecutionException("Failed to read invoker properties: " + currentInvokerProperties);
                }
            }

            if (currentProperties != null) {
                globalInvokerProperties.put(projectsPath.resolve(path).normalize(), currentProperties);
            }
        }

        try {
            if (runWithParallelThreads > 1) {
                getLog().info("use parallelThreads " + runWithParallelThreads);
            }

            JobExecutor jobExecutor = new JobExecutor(buildJobs, runWithParallelThreads);
            jobExecutor.forEach(job -> {
                Path ancestorFolder = getAncestorFolder(projectsPath.resolve(job.getProject()));

                runBuild(
                        projectsDir,
                        job,
                        mergedSettingsFile,
                        javaHome,
                        actualJreVersion,
                        globalInvokerProperties.get(ancestorFolder));
            });
        } finally {
            if (interpolatedSettingsFile != null && cloneProjectsTo == null) {
                interpolatedSettingsFile.delete();
            }
            if (mergedSettingsFile != null && mergedSettingsFile.exists()) {
                mergedSettingsFile.delete();
            }
        }
    }