/**
* Build a project from any source directory, targeting any destination.
*
* @param string $sourceDir The absolute path to the source directory.
* @param string $destination Where the web root(s) will be linked (absolute
* path).
* @param array $apps An array of application names to build.
*
* @throws \Exception on failure
*
* @return bool
*/
public function build($sourceDir, $destination, array $apps = [])
{
$success = true;
$ids = [];
foreach (LocalApplication::getApplications($sourceDir) as $app) {
$id = $app->getId();
$ids[] = $id;
if ($apps && !in_array($id, $apps)) {
continue;
}
$success = $this->buildApp($app, $sourceDir, $destination) && $success;
}
$notFounds = array_diff($apps, $ids);
if ($notFounds) {
foreach ($notFounds as $notFound) {
$this->output->writeln("Application not found: <comment>{$notFound}</comment>");
}
}
if (empty($this->settings['noClean'])) {
if (!empty($this->settings['projectRoot'])) {
$this->output->writeln("Cleaning up...");
$this->cleanBuilds($this->settings['projectRoot']);
$this->cleanArchives($this->settings['projectRoot']);
} else {
$buildsDir = $sourceDir . '/' . LocalProject::BUILD_DIR;
if (is_dir($buildsDir)) {
$this->output->writeln("Cleaning up...");
$this->cleanDirectory($buildsDir);
}
}
}
return $success;
}