public function build(array $settings, $sourceDir, $destination = null, array $apps = [])
    {
        $this->settings = $settings;
        $this->fsHelper->setRelativeLinks(empty($settings['abslinks']));

        if (file_exists($sourceDir . '/.git')) {
            (new LocalProject())->writeGitExclude($sourceDir);
        }

        $ids = [];
        $success = true;
        foreach (LocalApplication::getApplications($sourceDir, $this->config) as $app) {
            $id = $app->getId();
            $ids[] = $id;
            if ($apps && !in_array($id, $apps)) {
                continue;
            }
            $success = $this->buildApp($app, $destination) && $success;
        }
        $notFounds = array_diff($apps, $ids);
        if ($notFounds) {
            foreach ($notFounds as $notFound) {
                $this->output->writeln("Application not found: <comment>$notFound</comment>");
            }
        }
        if (empty($settings['no-clean'])) {
            $this->output->writeln("Cleaning up...");
            $this->cleanBuilds($sourceDir);
            $this->cleanArchives($sourceDir);
        }

        return $success;
    }