Main method builds all the targets for a typical propel project.
164976
public function main()
    {
        // check to make sure task received all correct params
        $this->validate();

        $generatorConfig = $this->getGeneratorConfig();

        // loading model from database
        $this->log('Reading databases structure...');
        $connections = $generatorConfig->getBuildConnections();
        if (!$connections) {
            throw new Exception('You must define database connection settings in a buildtime-conf.xml file to use diff');
        }
        $manager = new PropelMigrationManager();
        $manager->setConnections($connections);
        $manager->setMigrationDir($this->getOutputDirectory());
        $manager->setMigrationTable($this->getGeneratorConfig()->getBuildProperty('migrationTable'));

        if ($manager->hasPendingMigrations()) {
            throw new Exception('Uncommitted migrations have been found ; you should either execute or delete them before rerunning the \'diff\' task');
        }

        $totalNbTables = 0;
        $ad = new AppData();
        foreach ($connections as $name => $params) {
            $this->log(sprintf('Connecting to database "%s" using DSN "%s"', $name, $params['dsn']), Project::MSG_VERBOSE);
            $pdo = $generatorConfig->getBuildPDO($name);
            $database = new Database($name);
            $platform = $generatorConfig->getConfiguredPlatform($pdo);
            if (!$platform->supportsMigrations()) {
                $this->log(sprintf('Skipping database "%s" since vendor "%s" does not support migrations', $name, $platform->getDatabaseType()));
                continue;
            }
            $database->setPlatform($platform);
            $database->setDefaultIdMethod(IDMethod::NATIVE);
            $parser = $generatorConfig->getConfiguredSchemaParser($pdo);
            $nbTables = $parser->parse($database, $this);
            $ad->addDatabase($database);
            $totalNbTables += $nbTables;
            $this->log(sprintf('%d tables found in database "%s"', $nbTables, $name), Project::MSG_VERBOSE);
        }
        if ($totalNbTables) {
            $this->log(sprintf('%d tables found in all databases.', $totalNbTables));
        } else {
            $this->log('No table found in all databases');
        }

        // loading model from XML
        $this->packageObjectModel = true;
        $appDatasFromXml = $this->getDataModels();
        $appDataFromXml = array_pop($appDatasFromXml);

        // comparing models
        $this->log('Comparing models...');
        $migrationsUp = array();
        $migrationsDown = array();
        foreach ($ad->getDatabases() as $database) {
            $name = $database->getName();
            $this->log(sprintf('Comparing database "%s"', $name), Project::MSG_VERBOSE);
            if (!$appDataFromXml->hasDatabase($name)) {
                // FIXME: tables present in database but not in XML
                continue;
            }
            $databaseDiff = PropelDatabaseComparator::computeDiff($database, $appDataFromXml->getDatabase($name), $this->isCaseInsensitive());

            if (!$databaseDiff) {
                $this->log(sprintf('Same XML and database structures for datasource "%s" - no diff to generate', $name), Project::MSG_VERBOSE);
                continue;
            }

            $this->log(sprintf('Structure of database was modified in datasource "%s": %s', $name, $databaseDiff->getDescription()));
            $platform = $generatorConfig->getConfiguredPlatform(null, $name);
            $migrationsUp[$name] = $platform->getModifyDatabaseDDL($databaseDiff);
            $migrationsDown[$name] = $platform->getModifyDatabaseDDL($databaseDiff->getReverseDiff());
        }

        if (!$migrationsUp) {
            $this->log('Same XML and database structures for all datasource - no diff to generate');

            return;
        }

        $timestamp = time();
        $migrationFileName = $manager->getMigrationFileName($timestamp);
        $migrationClassBody = $manager->getMigrationClassBody($migrationsUp, $migrationsDown, $timestamp);

        $_f = new PhingFile($this->getOutputDirectory(), $migrationFileName);
        file_put_contents($_f->getAbsolutePath(), $migrationClassBody);
        $this->log(sprintf('"%s" file successfully created in %s', $_f->getName(), $_f->getParent()));
        if ($editorCmd = $this->getEditorCmd()) {
            $this->log(sprintf('Using "%s" as text editor', $editorCmd));
            shell_exec($editorCmd . ' ' . escapeshellarg($_f->getAbsolutePath()));
        } else {
            $this->log('  Please review the generated SQL statements, and add data migration code if necessary.');
            $this->log('  Once the migration class is valid, call the "migrate" task to execute it.');
        }
    }
795740
public function buildPropelModels()
    {
        $fs = new Filesystem();

        // cache testing
        if ($fs->exists($this->getPropelModelDir() . 'hash')
            && file_get_contents($this->getPropelCacheDir() . 'hash') === file_get_contents($this->getPropelModelDir() . 'hash')) {
            return;
        }

        $fs->remove($this->getPropelModelDir());

        $this->runCommand(
            new ModelBuildCommand(),
            [
                '--config-dir' => $this->getPropelConfigDir(),
                '--schema-dir' => $this->getPropelSchemaDir(),
            ]
        );

        $fs->copy(
            $this->getPropelCacheDir() . 'hash',
            $this->getPropelModelDir() . 'hash'
        );
    }
597010
public function main()
    {
        $cmd = $this->getCmdString();

        $this->silent ?: $this->log("executing $cmd");
        $return = null;
        $output = [];
        exec($cmd, $output, $return);

        $lines = implode("\r\n", $output);

        $this->silent ?: $this->log($lines, Project::MSG_INFO);

        if ($this->propertyName != null) {
            $this->project->setProperty($this->propertyName, $lines);
        }

        if ($return != 0 && $this->checkreturn) {
            $this->log('Task exited with code: ' . $return, Project::MSG_ERR);
            throw new BuildException("SymfonyConsole execution failed");
        }
    }
1108168
public function main()
    {
        $pull = $this->getFactoryInstance('update');
        try {
            $pull->setBranch($this->getBranch());
        } catch (Exception $ex) {
            $this->log("Caught: " . $ex->getMessage(), Project::MSG_DEBUG);
        }
        $pull->setClean($this->getClean());
        $pull->setQuiet($this->getQuiet());

        $cwd = getcwd();

        if ($this->repository === '') {
            $prog = $this->getProject();
            $dir = $prog->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }

        $this->checkRepositoryIsDirAndExists($dir);
        chdir($dir);
        try {
            $this->log("Executing: " . $pull->asString(), Project::MSG_INFO);
            $output = $pull->execute();
            if ($output !== '') {
                $this->log($output);
            }
        } catch (Exception $ex) {
            $msg = $ex->getMessage();
            $p = strpos($msg, 'hg returned:');
            if ($p !== false) {
                $msg = substr($msg, $p + 13);
            }
            chdir($cwd);
            throw new BuildException($msg);
        }
        chdir($cwd);
    }
496368
public function main() {
    $this->validate();

    // Remove existing destination first.
    if ($this->dest->exists()) {
      $this->log("Replacing existing resource '" . $this->dest->getPath() . "'");

      if ($this->dest->delete(TRUE) === FALSE) {
        throw new BuildException("Failed to delete existing destination '$this->dest'");
      }
    }

    // Link or copy the source artifact.
    $this->dest->getParentFile()->mkdirs();
    if ($this->mode == 'copy') {
      $this->log(sprintf("Copying '%s' to '%s'", $this->source->getPath(), $this->dest->getPath()));
      $this->source->copyTo($this->dest);
    }
    else {
      $this->log(sprintf("Linking '%s' to '%s'", $this->source->getPath(), $this->dest->getPath()));
      FileSystem::getFileSystem()->symlink($this->source->getPath(), $this->dest->getPath());
    }
  }
883006
public function main()
    {
        if (method_exists($this->proxy, "setLocation")) {
            try { // try to set location
                $this->proxy->setLocation($this->getLocation());
            } catch (Exception $ex) {
                $this->log("Error setting location in " . get_class($this->proxy) . Project::MSG_ERR);
                throw new BuildException($ex);
            }
        } else {
            throw new Exception("Error setting location in class " . get_class($this->proxy));
        }

        if (method_exists($this->proxy, "setProject")) {
            try { // try to set project
                $this->proxy->setProject($this->project);
            } catch (Exception $ex) {
                $this->log("Error setting project in " . get_class($this->proxy) . Project::MSG_ERR);
                throw new BuildException($ex);
            }
        } else {
            throw new Exception("Error setting project in class " . get_class($this->proxy));
        }

        try { //try to call main
            DispatchUtils::main($this->proxy);
        } catch (BuildException $be) {
            throw $be;
        } catch (Exception $ex) {
            $this->log("Error in " . get_class($this->proxy), Project::MSG_ERR);
            throw new BuildException("Error in " . get_class($this->proxy), $ex);
        }
    }
1237357
public function performTasks()
    {
        try { // try to execute this target
            $this->project->fireTargetStarted($this);
            $this->main();
            $this->project->fireTargetFinished($this, $null = null);
        } catch (BuildException $exc) {
            // log here and rethrow
            $this->project->fireTargetFinished($this, $exc);
            throw $exc;
        }
    }
1321
def main():
    """"""
    conf = init_and_get_conf()
    logger = make_logger(__name__)
    logger.info('YaBT version {}', __version__)
    handlers = {
        'build': YabtCommand(func=cmd_build, requires_project=True),
        'dot': YabtCommand(func=cmd_dot, requires_project=True),
        'test': YabtCommand(func=cmd_test, requires_project=True),
        'tree': YabtCommand(func=cmd_tree, requires_project=True),
        'version': YabtCommand(func=cmd_version, requires_project=False),
        'list-builders': YabtCommand(func=cmd_list, requires_project=False),
    }
    command = handlers[conf.cmd]
    if command.requires_project and not conf.in_yabt_project():
        fatal('Not a YABT project (or any of the parent directories): {}',
              BUILD_PROJ_FILE)
    try:
        command.func(conf)
    except Exception as ex:
        fatal('{}', ex)
1189215
public function build()
    {
        $this->clean();
        $this->prepare();
        $this->runCs();
        $this->runCpd();
        $this->runMd();
        $this->runTestsUnit();
    }
587008
def main():
    
    version = get_version()
    circleci_build = six.moves.input("CircleCI Build ID: ")
    appveyor_build = six.moves.input("AppVeyor Build ID: ")
    coveralls_build = six.moves.input("Coveralls Build ID: ")
    travis_build = six.moves.input("Travis Build ID: ")
    populate_readme(
        version, circleci_build, appveyor_build, coveralls_build, travis_build
    )
    populate_index(
        version, circleci_build, appveyor_build, coveralls_build, travis_build
    )
    populate_native_libraries(version)
    populate_development(version)
1302480
public function main()
    {
        if ($this->dir === null) {
            throw new BuildException("You must specify the \"dir\" attribute for PEAR package 2 task.");
        }

        if ($this->package === null) {
            throw new BuildException("You must specify the \"name\" attribute for PEAR package 2 task.");
        }

        $this->pkg = new PEAR_PackageFileManager2();

        $this->setVersion2Options();
        $this->setOptions();

        $this->pkg->addRelease();
        $this->pkg->generateContents();
        $e = $this->pkg->writePackageFile();
        if (@PEAR::isError($e)) {
            throw new BuildException("Unable to write package file.", new Exception($e->getMessage()));
        }
    }
328633
public function build()
    {
        $files = $this->iterator->getFiles();
        $generators = $this->generatorRegistry->generators();

        foreach ($files as $file) {
            foreach ($generators as $generator) {
                $generator->parseFile($file);
            }
        }

        foreach ($generators as $generator) {
            $generator->generate();
        }
    }
309104
public function main()
    {
        if (!isset($this->analyzerPath)) {
            throw new BuildException("Missing attribute 'analyzerPath'");
        }

        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        if ($this->file instanceof PhingFile) {
            $this->analyze($this->file->getPath());
        } else { // process filesets
            $project = $this->getProject();

            foreach ($this->filesets as $fs) {
                $ds = $fs->getDirectoryScanner($project);
                $files = $ds->getIncludedFiles();
                $dir = $fs->getDir($this->project)->getPath();

                foreach ($files as $file) {
                    $this->analyze($dir . DIRECTORY_SEPARATOR . $file);
                }
            }
        }

        $this->log("Number of findings: " . $this->counter, Project::MSG_INFO);
    }
201609
function main() {
    const options = queryOptions();
    switch (options.porting) {
        case 'build':
            runBuild(options)
            .catch((reason) => {
                console.error(reason);
                process.exit(1);
            });
            break;
        case 'arrange':
            runArrange(options);
            break;
        case 'rebase':
            runRebase(options);
            break;
        case 'clean':
            runClean(options);
            break;
    }
}
733650
public function main()
    {
        // check supplied attributes
        $this->checkReleasetype();
        $this->checkFile();
        $this->checkProperty();

        // read file (or use fallback value if file is empty)
        try {
            if ($this->propFile) {
                $properties = $this->loadProperties();
                $content = $properties->getProperty($this->property);
            } else {
                $content = trim($this->file->contents());
            }
            if (empty($content)) {
                $content = $this->startingVersion;
            }
        } catch (Exception $e) {
            throw new BuildException($e);
        }

        // get new version
        $this->log("Old version: $content", Project::MSG_INFO);
        $newVersion = $this->getVersion($content);
        $this->log("New version: $newVersion", Project::MSG_INFO);

        if ($this->propFile) {
            $properties->put($this->property, $newVersion);
            try {
                $header = "Build Number for PHING. Do not edit!";
                $properties->store($this->file, $header);
            } catch (IOException $ioe) {
                $message = "Error while writing " . $this->file;
                throw new BuildException($message, $ioe);
            }
        } else {
            // write new Version to file
            file_put_contents($this->file, $newVersion . $this->getProject()->getProperty('line.separator'));
        }

        //Finally set the property
        $this->getProject()->setNewProperty($this->property, $newVersion);
    }
842188
public function main()
    {
        if ((count($this->sourceFileSets) === 0) && (count($this->sourceFileLists) === 0)) {
            throw new BuildException(
                'At least one <srcfileset> or <srcfilelist>'
                . ' element must be set'
            );
        }
        if ((count($this->targetFileSets) === 0) && (count($this->targetFileLists) === 0)) {
            throw new BuildException(
                'At least one <targetfileset> or'
                . ' <targetfilelist> element must be set'
            );
        }
        $now = (new DateTime())->getTimestamp();
        /*
          We have to munge the time to allow for the filesystem time
          granularity.
        */
        // $now += FILE_UTILS . getFileTimestampGranularity();

        // Grab all the target files specified via filesets:
        $allTargets = [];
        $oldestTargetTime = 0;
        $oldestTarget = null;
        foreach ($this->targetFileSets as $targetFS) {
            if (!$targetFS->getDir($this->getProject())->exists()) {
                // this is the same as if it was empty, no target files found
                continue;
            }
            $targetDS = $targetFS->getDirectoryScanner($this->getProject());
            $targetFiles = $targetDS->getIncludedFiles();

            foreach ($targetFiles as $targetFile) {
                $dest = new PhingFile($targetFS->getDir($this->getProject()), $targetFile);
                $allTargets[] = $dest;

                if ($dest->lastModified() > $now) {
                    $this->log(
                        'Warning: ' . $targetFile . ' modified in the future.',
                        Project::MSG_WARN
                    );
                }
                if ($oldestTarget === null
                    || $dest->lastModified() < $oldestTargetTime
                ) {
                    $oldestTargetTime = $dest->lastModified();
                    $oldestTarget = $dest;
                }
            }
        }
        // Grab all the target files specified via filelists:
        $upToDate = true;
        foreach ($this->targetFileLists as $targetFL) {
            $targetFiles = $targetFL->getFiles($this->getProject());

            foreach ($targetFiles as $targetFile) {
                $dest = new PhingFile($targetFL->getDir($this->getProject()), $targetFile);
                if (!$dest->exists()) {
                    $this->log($targetFile . ' does not exist.', Project::MSG_VERBOSE);
                    $upToDate = false;
                    continue;
                }

                $allTargets[] = $dest;
                if ($dest->lastModified() > $now) {
                    $this->log(
                        'Warning: ' . $targetFile . ' modified in the future.',
                        Project::MSG_WARN
                    );
                }
                if ($oldestTarget === null
                    || $dest->lastModified() < $oldestTargetTime
                ) {
                    $oldestTargetTime = $dest->lastModified();
                    $oldestTarget = $dest;
                }
            }
        }
        if ($oldestTarget !== null) {
            $this->log($oldestTarget . ' is oldest target file', Project::MSG_VERBOSE);
        } else {
            // no target files, then we cannot remove any target files and
            // skip the following tests right away
            $upToDate = false;
        }
        // Check targets vs source files specified via filelists:
        if ($upToDate) {
            foreach ($this->sourceFileLists as $sourceFL) {
                $sourceFiles = $sourceFL->getFiles($this->getProject());

                foreach ($sourceFiles as $sourceFile) {
                    $src = new PhingFile($sourceFL->getDir($this->getProject()), $sourceFile);

                    if ($src->lastModified() > $now) {
                        $this->log(
                            'Warning: ' . $sourceFile
                            . ' modified in the future.',
                            Project::MSG_WARN
                        );
                    }
                    if (!$src->exists()) {
                        $this->log(
                            $sourceFile . ' does not exist.',
                            Project::MSG_VERBOSE
                        );
                        $upToDate = false;
                        break 2;
                    }
                    if ($src->lastModified() > $oldestTargetTime) {
                        $upToDate = false;
                        $this->log(
                            $oldestTarget . ' is out of date with respect to '
                            . $sourceFile,
                            Project::MSG_VERBOSE
                        );
                        break 2;
                    }
                }
            }
        }
        // Check targets vs source files specified via filesets:
        if ($upToDate) {
            foreach ($this->sourceFileSets as $sourceFS) {
                $sourceDS = $sourceFS->getDirectoryScanner($this->getProject());
                $sourceFiles = $sourceDS->getIncludedFiles();

                foreach ($sourceFiles as $sourceFile) {
                    $src = new PhingFile($sourceFS->getDir($this->getProject()), $sourceFile);

                    if ($src->lastModified() > $now) {
                        $this->log(
                            'Warning: ' . $sourceFile
                            . ' modified in the future.',
                            Project::MSG_WARN
                        );
                    }
                    if ($src->lastModified() > $oldestTargetTime) {
                        $upToDate = false;
                        $this->log(
                            $oldestTarget . ' is out of date with respect to '
                            . $sourceFile,
                            Project::MSG_VERBOSE
                        );
                        break 2;
                    }
                }
            }
        }
        if (!$upToDate) {
            $this->log('Deleting all target files. ', Project::MSG_VERBOSE);
            foreach ($allTargets as $fileToRemove) {
                $this->log(
                    'Deleting file ' . $fileToRemove->getAbsolutePath(),
                    Project::MSG_VERBOSE
                );
                $fileToRemove->delete();
            }
        }
    }
297367
public function build()
    {
        $this->filesystem->put(

            sprintf('/%s/_blog/%s', KATANA_CONTENT_DIR, $this->nameFile()),

            $this->buildTemplate()

        );
    }