The main entry point method.

@throws BuildException
@return void
503474
public function main()
    {
        $filesAdded = false;
        $clone = $this->getFactoryInstance('add');
        $clone->setQuiet($this->getQuiet());

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

        if (!file_exists($dir)) {
            throw new BuildException("\"$dir\" does not exist.");
        } elseif (!is_dir($dir)) {
            throw new BuildException("\"$dir\" is not a directory.");
        }

        chdir($dir);

        if (file_exists('.hgignore')) {
            $this->loadIgnoreFile();
        }
        if (count($this->filesets)) {
            $this->log('filesets set', Project::MSG_DEBUG);
            /**
             * $fs is a FileSet
             *
             * @var $fs FileSet
             */
            foreach ($this->filesets as $fs) {
                $ds = $fs->getDirectoryScanner($project);
                $fromDir = $fs->getDir($project);
                if ($fromDir->getName() === '.') {
                    $statusClone = $this->getFactoryInstance('status');
                    $statusClone->setUnknown(true);
                    $statusClone->setNoStatus(true);
                    $statusClone->setRepository($this->getRepository());
                    $statusOut = $statusClone->execute();
                    if ($statusOut !== '') {
                        $files = explode(PHP_EOL, $statusOut);
                        foreach ($files as $file) {
                            if ($file != '') {
                                $clone->addFile($file);
                                $filesAdded = true;
                            }
                        }
                    }
                }
            }
        }

        if ($filesAdded) {
            try {
                $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
                $output = $clone->execute();
                if ($output !== '') {
                    $this->log($output);
                }
            } catch (Exception $ex) {
                $msg = $ex->getMessage();
                $this->log("Exception: $msg", Project::MSG_INFO);
                $p = strpos($msg, 'hg returned:');
                if ($p !== false) {
                    $msg = substr($msg, $p + 13);
                }
                chdir($cwd);
                throw new BuildException($msg);
            }
        }
        chdir($cwd);
    }
901400
public function main()
    {
        $tool = $this->getToolPath($this->format);
        if (count($this->filterChains)) {
            $this->fileUtils = new FileUtils();
        }

        if ($this->file != '') {
            $file = $this->file;
            $targetFile = $this->getTargetFile($file, $this->destination);
            $this->render($tool, $file, $targetFile);

            return;
        }

        if (!count($this->filesets)) {
            throw new BuildException(
                '"file" attribute or "fileset" subtag required'
            );
        }

        // process filesets
        $mapper = null;
        if ($this->mapperElement !== null) {
            $mapper = $this->mapperElement->getImplementation();
        }

        $project = $this->getProject();
        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($project);
            $fromDir = $fs->getDir($project);
            $srcFiles = $ds->getIncludedFiles();

            foreach ($srcFiles as $src) {
                $file = new PhingFile($fromDir, $src);
                if ($mapper !== null) {
                    $results = $mapper->main($file);
                    if ($results === null) {
                        throw new BuildException(
                            sprintf(
                                'No filename mapper found for "%s"',
                                $file
                            )
                        );
                    }
                    $targetFile = reset($results);
                } else {
                    $targetFile = $this->getTargetFile($file, $this->destination);
                }
                $this->render($tool, $file, $targetFile);
            }
        }
    }
1002361
public function main()
    {
        $this->checkFile();
        $this->checkPropertyName();

        $size = filesize($this->file);

        if ($size === false) {
            throw new BuildException(sprintf('[FileSize] Cannot determine size of file: %s', $this->file));
        }

        // publish hash value
        $this->project->setProperty($this->propertyName, $size);
    }
14364
public function main()
    {
        if ($this->getOwningTarget()->getName() === "") {
            $this->log("Cowardly refusing to call target '{$this->subTarget}' from the root", Project::MSG_WARN);
            return;
        }

        $this->log("Running PhingCallTask for target '" . $this->subTarget . "'", Project::MSG_DEBUG);
        if ($this->callee === null) {
            $this->init();
        }

        if ($this->subTarget === null) {
            throw new BuildException("Attribute target is required.", $this->getLocation());
        }

        $this->callee->setPhingFile($this->project->getProperty("phing.file"));
        $this->callee->setTarget($this->subTarget);
        $this->callee->setInheritAll($this->inheritAll);
        $this->callee->setInheritRefs($this->inheritRefs);
        $this->callee->main();
    }
163564
public function main()
    {
        switch ($this->getAction()) {
            case "start":
                $this->start();
                break;
            case "stop":
                $this->stop();
                break;
            case "lap":
                $this->lap();
                break;
            default:
                throw new BuildException('action should be one of start, stop, lap.');
        }
    }
535461
public function main()
    {
        if ($this->property === '') {
            throw new BuildException('no property specified');
        }
        if ($this->destDir === null) {
            $this->destDir = $this->getProject()->resolveFile('.');
        }
        $fu = new FileUtils;
        $tmpFile = $fu->createTempFile(
            $this->prefix,
            $this->suffix,
            $this->destDir,
            $this->deleteOnExit,
            $this->createFile
        );
        $this->getProject()->setNewProperty($this->property, (string) $tmpFile);
    }
866987
public function main()
    {
        // Check to make sure the input and output files were specified and that the input file exists.

        if (!$this->xmlConfFile || !$this->xmlConfFile->exists()) {
            throw new BuildException("No valid xmlConfFile specified.", $this->getLocation());
        }

        if (!$this->outputFile) {
            throw new BuildException("No outputFile specified.", $this->getLocation());
        }

        $this->log('Loading XML configuration file...');

        // Create a PHP array from the runtime-conf.xml file
        $xmlDom = new DOMDocument();
        $xmlDom->load($this->xmlConfFile->getAbsolutePath());
        $xml = simplexml_load_string($xmlDom->saveXML());
        $phpconf = self::simpleXmlToArray($xml);
        $this->log(sprintf('Loaded "%s" successfully', $this->xmlConfFile->getAbsolutePath()), Project::MSG_VERBOSE);

        /* For some reason the array generated from runtime-conf.xml has separate
         * 'log' section and 'propel' sections. To maintain backward compatibility
         * we need to put 'log' back into the 'propel' section.
         */
        $log = array();
        if (isset($phpconf['log'])) {
            $phpconf['propel']['log'] = $phpconf['log'];
            unset($phpconf['log']);
        }

        if (isset($phpconf['propel'])) {
            $phpconf = $phpconf['propel'];
        }

        // add generator version
        $phpconf['generator_version'] = $this->getGeneratorConfig()->getBuildProperty('version');

        if (!$this->outputClassmapFile) {
            // We'll create a default one for BC
            $this->outputClassmapFile = 'classmap-' . $this->outputFile;
        }

        // Write resulting PHP data to output file
        $outfile = new PhingFile($this->outputDirectory, $this->outputFile);
        $output = "<?php\n";
        $output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
        $output .= "// from XML runtime conf file " . $this->xmlConfFile->getPath() . "\n";
        $output .= "\$conf = ";
        $output .= var_export($phpconf, true);
        $output .= ";\n";
        $output .= "\$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . '" . $this->outputClassmapFile . "');\n";
        $output .= "return \$conf;";

        $mustWriteRuntimeConf = true;
        if (file_exists($outfile->getAbsolutePath())) {
            $currentRuntimeConf = file_get_contents($outfile->getAbsolutePath());
            if ($currentRuntimeConf == $output) {
                $this->log(sprintf('No change in PHP runtime conf file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
                $mustWriteRuntimeConf = false;
            } else {
                $this->log(sprintf('Updating PHP runtime conf file "%s"', $outfile->getPath()));
            }
        } else {
            $this->log(sprintf('Creating PHP runtime conf file "%s"', $outfile->getPath()));
        }
        if ($mustWriteRuntimeConf && !file_put_contents($outfile->getAbsolutePath(), $output)) {
            throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
        }

        // add classmap
        $phpconfClassmap = $this->getClassMap();
        $outfile = new PhingFile($this->outputDirectory, $this->outputClassmapFile);
        $output = '<' . '?' . "php\n";
        $output .= "// This file generated by Propel " . $phpconf['generator_version'] . " convert-conf target" . ($this->getGeneratorConfig()->getBuildProperty('addTimestamp') ? " on " . strftime("%c") : '') . "\n";
        $output .= "return ";
        $output .= var_export($phpconfClassmap, true);
        $output .= ";";

        $mustWriteClassMap = true;
        if (file_exists($outfile->getAbsolutePath())) {
            $currentClassmap = file_get_contents($outfile->getAbsolutePath());
            if ($currentClassmap == $output) {
                $this->log(sprintf('No change in PHP classmap file "%s"', $outfile->getPath()), Project::MSG_VERBOSE);
                $mustWriteClassMap = false;
            } else {
                $currentPhpconfClassmap = include $outfile->getAbsolutePath();
                if ($addedMaps = array_diff_assoc($phpconfClassmap, $currentPhpconfClassmap)) {
                    $this->log('Added classmap for the following classes:', Project::MSG_VERBOSE);
                    $this->logClassMap($addedMaps);
                }
                if ($removedMaps = array_diff_assoc($currentPhpconfClassmap, $phpconfClassmap)) {
                    $this->log('Removed classmap for the following classes:', Project::MSG_VERBOSE);
                    $this->logClassMap($removedMaps);
                }
                $this->log(sprintf('Updating PHP classmap file "%s"', $outfile->getPath()));
            }
        } else {
            $this->log(sprintf('Creating PHP classmap file "%s"', $outfile->getPath()));
            $this->logClassMap($phpconfClassmap);
        }
        if ($mustWriteClassMap && !file_put_contents($outfile->getAbsolutePath(), $output)) {
            throw new BuildException("Error writing output file: " . $outfile->getAbsolutePath(), $this->getLocation());
        }

        if (!$mustWriteRuntimeConf && !$mustWriteClassMap) {
            $this->log('No change in compiled configuration files');
        }
    }
753033
public function main()
    {
        if (empty($this->message)) {
            throw new BuildException(
                '"message" attribute cannot be empty'
            );
        }

        $notifications = [
            $this->notification
        ];
        $options = [
            'host' => $this->host,
            'protocol' => $this->protocol,
        ];
        if (!empty($this->appicon)) {
            $options['AppIcon'] = $this->appicon;
        }

        try {
            if ($this->growl instanceof Net_Growl) {
                $growl = $this->growl;
            } else {
                $growl = Net_Growl::singleton(
                    $this->name,
                    $notifications,
                    $this->password,
                    $options
                );
            }
            $response = $growl->register();

            if ($this->protocol == 'gntp') {
                if ($response->getStatus() != 'OK') {
                    throw new BuildException(
                        'Growl Error ' . $response->getErrorCode() .
                        ' - ' . $response->getErrorDescription()
                    );
                }
            }
            $this->log(
                'Application ' . $this->name . ' registered',
                Project::MSG_VERBOSE
            );

            $logRequest = [
                'Application-Name' => $this->name,
                'Application-Icon' => $this->appicon,
                'Notification-Name' => $this->notification,
                'Notification-Title' => $this->title,
                'Notification-Text' => $this->message,
                'Notification-Priority' => $this->priority,
                'Notification-Icon' => $this->icon,
                'Notification-Sticky' => $this->sticky,
            ];
            foreach ($logRequest as $key => $value) {
                $this->log($key . ': ' . $value, Project::MSG_DEBUG);
            }

            $options = [
                'sticky' => $this->sticky,
                'priority' => $this->priority,
                'icon' => $this->icon,
            ];
            $response = $growl->publish(
                $this->notification,
                $this->title,
                $this->message,
                $options
            );

            if ($this->protocol == 'gntp') {
                if ($response->getStatus() != 'OK') {
                    throw new BuildException(
                        'Growl Error ' . $response->getErrorCode() .
                        ' - ' . $response->getErrorDescription()
                    );
                }
            }
            $this->log('Notification was sent to remote host ' . $this->host);
        } catch (Net_Growl_Exception $e) {
            throw new BuildException(
                'Growl Exception : ' . $e->getMessage()
            );
        }
    }
451469
public function main()
    {
        $clone = $this->getFactoryInstance('clone');
        $repository = $this->getRepository();
        if ($repository === '') {
            throw new BuildException('"repository" is a required parameter');
        }
        $target = $this->getTargetPath();
        if ($target === '') {
            throw new BuildException('"targetPath" is a required parameter');
        }
        // Is target path empty?
        if (file_exists($target)) {
            $files = scandir($target);
            if (is_array($files) && count($files) > 2) {
                throw new BuildException("Directory \"$target\" is not empty");
            }
            if (!is_dir($target)) {
                throw new BuildException("\"$target\" is not a directory");
            }
        }
        $msg = sprintf('hg cloning %s to %s', $repository, $target);
        $this->log($msg, Project::MSG_INFO);
        $clone->setSource($repository);
        $clone->setDestination($target);
        $clone->setInsecure($this->getInsecure());
        $clone->setQuiet($this->getQuiet());
        try {
            $this->log("Executing: " . $clone->asString(), Project::MSG_INFO);
            $output = $clone->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);
            }
            throw new BuildException($msg);
        }
    }
767032
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('log');
        $command
            ->setOption('stat', $this->getStat())
            ->setOption('name-status', $this->isNameStatus())
            ->setOption('no-merges', $this->isNoMerges())
            ->setOption('format', $this->getFormat());

        if (null !== $this->getMaxCount()) {
            $command->setOption('max-count', $this->getMaxCount());
        }

        if (null !== $this->getDate()) {
            $command->setOption('date', $this->getDate());
        }

        if (null !== $this->getSince()) {
            $command->setOption('since', $this->getSince());
        }

        if (null !== $this->getUntil()) {
            $command->setOption('until', $this->getUntil());
        }

        $command->addDoubleDash(true);
        if (null !== $this->getPaths()) {
            $command->addDoubleDash(false);
            $paths = explode(PATH_SEPARATOR, $this->getPaths());
            foreach ($paths as $path) {
                $command->addArgument($path);
            }
        }

        $this->log('git-log command: ' . $command->createCommandString(), Project::MSG_INFO);

        try {
            $output = $command->execute();
        } catch (Exception $e) {
            throw new BuildException('Task execution failed', $e);
        }

        if (null !== $this->outputProperty) {
            $this->project->setProperty($this->outputProperty, trim($output));
        }

        $this->log(
            sprintf('git-log: commit log for "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-log output: ' . trim($output), Project::MSG_INFO);
    }
46874
public function main()
    {
        if ($this->target == null) {
            throw new BuildException('target property required');
        }

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

        if (empty($this->executable)) {
            throw new BuildException("Missing the 'executable' attribute");
        }

        if ($this->file instanceof PhingFile) {
            $this->lint($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->lint($dir . DIRECTORY_SEPARATOR . $file);
                }
            }
        }

        // write list of 'bad files' to file (if specified)
        if ($this->tofile) {
            $writer = new FileWriter($this->tofile);

            foreach ($this->badFiles as $file => $messages) {
                foreach ($messages as $msg) {
                    $writer->write($file . "=" . $msg . PHP_EOL);
                }
            }

            $writer->close();
        }

        if ($this->haltOnFailure && $this->hasErrors) {
            throw new BuildException(
                'Syntax error(s) in JS files:' . implode(
                    ', ',
                    array_keys($this->badFiles)
                )
            );
        }
        if ($this->haltOnWarning && $this->hasWarnings) {
            throw new BuildException(
                'Syntax warning(s) in JS files:' . implode(
                    ', ',
                    array_keys($this->badFiles)
                )
            );
        }
    }
484141
public function main()
    {
        if ($this->name === null) {
            throw new BuildException("The name attribute is required for adhoc task definition.", $this->getLocation());
        }

        $this->execute();

        $classes = $this->getNewClasses();
        if (count($classes) !== 1) {
            throw new BuildException("You must define one (and only one) class for AdhocTypedefTask.");
        }
        $classname = array_shift($classes);

        // instantiate it to make sure it is an instance of ProjectComponent
        $t = new $classname();
        if (!($t instanceof ProjectComponent)) {
            throw new BuildException(
                "The adhoc class you defined must be an instance of phing.ProjectComponent",
                $this->getLocation()
            );
        }

        $this->log("Datatype " . $this->name . " will be handled by class " . $classname, Project::MSG_VERBOSE);
        $this->project->addDataTypeDefinition($this->name, $classname);
    }
1249923
public function main()
    {
        $repo = $this->getRepository();
        if (empty($repo)) {
            throw new BuildException('"repository" is a required parameter');
        }

        $remote = $this->getRemote();
        if (empty($remote)) {
            throw new BuildException('"remote" is a required parameter');
        }

        chdir($repo);
        $this->client = $this->getGitClient(false, $repo);

        // initalized yet?
        if (!is_dir('.subsplit')) {
            $this->subsplitInit();
        } else {
            // update
            $this->subsplitUpdate();
        }

        // find all splits based on heads requested
        $this->findSplits();

        // check that GitHub has the repos
        $this->verifyRepos();

        // execute the subsplits
        $this->publish();
    }
736182
public function main()
    {
        $this->validateErrors();
        $this->validateDebug();
        $this->validateConfiguration();
        $this->validateProperties();
        $this->validateExecutable();

        $command = sprintf('%s %s', escapeshellcmd($this->executable), $this->constructOptionsString());

        $message = sprintf('Executing: [%s]', $command);
        $this->log($message, Project::MSG_VERBOSE);

        exec($command, $output, $returnCode);

        foreach ($output as $line) {
            $this->log($line);
        }

        if ($returnCode !== self::EXIT_SUCCESS) {
            throw new BuildException('Execution of SonarQube Scanner failed.');
        }
    }
1182209
public function main()
    {
        if ($this->name !== null) {
            if ($this->value === null && $this->reference === null) {
                throw new BuildException(
                    "You must specify value or refid with the name attribute",
                    $this->getLocation()
                );
            }
        } else {
            if ($this->file === null && $this->env === null) {
                throw new BuildException(
                    "You must specify file or environment when not using the name attribute",
                    $this->getLocation()
                );
            }
        }

        if ($this->file === null && $this->prefix !== null) {
            throw new BuildException("Prefix is only valid when loading from a file.", $this->getLocation());
        }

        if (($this->name !== null) && ($this->value !== null)) {
            $this->addProperty($this->name, $this->value);
        }

        if ($this->file !== null) {
            $this->loadFile($this->file);
        }

        if ($this->env !== null) {
            $this->loadEnvironment($this->env);
        }

        if (($this->name !== null) && ($this->reference !== null)) {
            // get the refereced property
            try {
                $referencedObject = $this->reference->getReferencedObject($this->project);

                if ($referencedObject instanceof Exception) {
                    $reference = $referencedObject->getMessage();
                } else {
                    $reference = (string) $referencedObject;
                }

                $this->addProperty($this->name, $reference);
            } catch (BuildException $be) {
                if ($this->fallback !== null) {
                    $referencedObject = $this->reference->getReferencedObject($this->fallback);

                    if ($referencedObject instanceof Exception) {
                        $reference = $referencedObject->getMessage();
                    } else {
                        $reference = (string) $referencedObject;
                    }
                    $this->addProperty($this->name, $reference);
                } else {
                    throw $be;
                }
            }
        }
    }
606907
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }

        $client = $this->getGitClient();
        $client->initRepository($this->isBare());

        $msg = 'git-init: initializing '
            . ($this->isBare() ? '(bare) ' : '')
            . '"' . $this->getRepository() . '" repository';
        $this->log($msg, Project::MSG_INFO);
    }