Our main execution of the task.

@throws BuildException
@throws Exception

@access public
@return void
164955
public function main()
    {
        if ($this->useSass) {
            if (strlen($this->executable) < 0) {
                throw new BuildException("'executable' must be defined.");
            }
        }

        if (empty($this->filesets) && $this->file === null) {
            throw new BuildException(
                "Missing either a nested fileset or attribute 'file'"
            );
        }

        try {
            $compiler = (new SassTaskCompilerFactory(FileSystem::getFileSystem()))->prepareCompiler($this);
        } catch (BuildException $exception) {
            if ($this->failonerror) {
                throw $exception;
            }
            $this->log($exception->getMessage());
            return;
        }

        if (count($this->filesets) > 0) {
            $this->processFilesets($compiler);
        } elseif ($this->file !== null) {
            $this->processFile($compiler);
        }
    }
1344349
public function main()
    {
        if ($this->name === null || $this->classname === null) {
            throw new BuildException("You must specify name and class attributes for <typedef>.");
        }
        $this->project->addDataTypeDefinition($this->name, $this->classname, $this->classpath);
    }
122411
public function main()
    {
        $this->ini = new IniFileConfig();
        $readFile = null;
        $writeFile = null;

        if (null !== $this->source && null === $this->dest) {
            $readFile = $this->source;
        } elseif (null !== $this->dest && null === $this->source) {
            $readFile = $this->dest;
        } else {
            $readFile = $this->source;
        }

        if (null !== $this->dest) {
            $writeFile = $this->dest;
        } elseif (null !== $this->source) {
            $writeFile = $this->source;
        } else {
            $writeFile = $this->dest;
        }

        if ($readFile === null && $writeFile === null) {
            $msg = "Neither source nor dest is set";
            if ($this->haltonerror) {
                throw new BuildException($msg);
            }
            $this->log($msg, Project::MSG_ERR);
            return;
        }

        if (!$this->checkReadFile($readFile)) {
            return;
        }

        if (!$this->checkWriteFile($writeFile)) {
            return;
        }

        $this->enumerateGets();
        $this->enumerateSets();
        $this->enumerateRemoves();

        if (count($this->sets) || count($this->removals)) {
            try {
                $this->ini->write($writeFile);
                $this->log("Wrote to $writeFile");
            } catch (Exception $ex) {
                $msg = $ex->getMessage();
                if ($this->haltonerror) {
                    throw new BuildException($msg);
                }
                $this->log($msg, Project::MSG_ERR);
            }
        }
    }
952209
public function main()
    {
        if (empty($this->lockFile)) {
            throw new \BuildException('Lockfile needs to be set!');
        }

        if (!file_exists($this->lockFile) || !is_readable($this->lockFile)) {
            throw new \BuildException('Given Lockfile does not exist or is not readable!');
        }

        $checker = $this->getSecurityChecker();
        try {
            if (!empty($this->timeout)) {
                $checker->getCrawler()->setTimeout($this->timeout);
            }
            if (!empty($this->endPoint)) {
                $checker->getCrawler()->setEndPoint($this->endPoint);
            }

            $vulnerabilities = $checker->check($this->lockFile, 'json');
            if ($vulnerabilities->count() === 0) {
                $this->log('No vulnerabilities found!');
                return;
            }

            if ($vulnerabilities->getFormat() !== 'json') {
                throw new \BuildException('Was expecting JSON response, but got "' . $vulnerabilities->getFormat().'"');
            }

            $dependencies = json_decode($vulnerabilities->__toString(), true);
            if (!is_array($dependencies)) {
                throw new \BuildException('The web service response could not be parsed!');
            }

            foreach ($dependencies as $dependency => $issues) {
                $dependencyFullName = $dependency . ' (' . $issues['version'] . ')';
                $this->log($dependencyFullName);
                $this->log(str_repeat('-', strlen($dependencyFullName)));

                foreach ($issues['advisories'] as $issue => $details) {
                    $title = ' * ' . $details['title'];
                    if ($details['cve']) {
                        $title .= ' (CVE: ' . $details['cve'] . ')';
                    }
                    $this->log($title);

                    if ('' !== $details['link']) {
                        $this->log('   ' . $details['link']);
                    }

                    $this->log('');
                }
            }
        } catch (\Exception $e) {
            throw new \BuildException($e);
        }

        throw new \BuildException('Vulnerabilities found!');
    }
366228
public function main()
    {
        if (!$this->isValidOs()) {
            return null;
        }

        try {
            $this->commandline->setExecutable($this->resolveExecutable($this->executable, $this->searchPath));
        } catch (IOException | NullPointerException $e) {
            throw new BuildException($e);
        }

        $this->prepare();
        $this->buildCommand();
        [$return, $output] = $this->executeCommand();
        $this->cleanup($return, $output);

        return $return;
    }
640142
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('tag');
        $command
            ->setOption('a', $this->isAnnotate())
            ->setOption('s', $this->isSign())
            ->setOption('f', $this->isReplace())
            ->setOption('d', $this->isDelete())
            ->setOption('v', $this->isVerify())
            ->setOption('l', $this->isList());

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

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

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

        // Use 'name' arg, if relevant
        if (null != $this->getName() && false == $this->isList()) {
            $command->addArgument($this->getName());
        }

        if (null !== $this->getKeySign() || $this->isAnnotate() || $this->isSign()) {
            // Require a tag message or file
            if (null === $this->getMessage() && null === $this->getFile()) {
                throw new BuildException('"message" or "file" required to make a tag');
            }
        }

        // Use 'commit' or 'object' args, if relevant
        if (null !== $this->getCommit()) {
            $command->addArgument($this->getCommit());
        } else {
            if (null !== $this->getObject()) {
                $command->addArgument($this->getObject());
            }
        }

        // Customize list (-l) options
        if ($this->isList()) {
            if (null !== $this->getContains()) {
                $command->setOption('contains', $this->getContains());
            }
            if (null !== $this->getPattern()) {
                $command->addArgument($this->getPattern());
            }
            if (null != $this->getNum()) {
                $command->setOption('n', $this->getNum());
            }
        }

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

        try {
            $output = $command->execute();
        } catch (Exception $e) {
            $this->log($e->getMessage(), Project::MSG_ERR);
            throw new BuildException('Task execution failed. ' . $e->getMessage());
        }

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

        $this->log(
            sprintf('git-tag: tags for "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-tag output: ' . trim($output), Project::MSG_INFO);
    }
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);
    }
471729
public function main()
    {
        $errorMessages = '';
        for ($i = 0; $i <= $this->retryCount; $i++) {
            try {
                $this->nestedTask->perform();
                break;
            } catch (Exception $e) {
                $errorMessages .= $e->getMessage();
                if ($i >= $this->retryCount) {
                    $taskName = $this->nestedTask->getTaskName();
                    $exceptionMessage = <<<EXCEPTION_MESSAGE
Task [{$taskName}] failed after [{$this->retryCount}] attempts; giving up
Error messages:
$errorMessages
EXCEPTION_MESSAGE;
                    throw new BuildException(
                        $exceptionMessage,
                        $this->getLocation()
                    );
                }

                if ($this->retryDelay > 0) {
                    $msg = sprintf(
                        'Attempt [%s]: error occurred; retrying after %s s...',
                        $i,
                        $this->retryDelay
                    );
                } else {
                    $msg = sprintf(
                        'Attempt [%s]: error occurred; retrying...',
                        $i
                    );
                }

                $this->log($msg, Project::MSG_INFO);
                $errorMessages .= PHP_EOL;

                if ($this->retryDelay > 0) {
                    sleep($this->retryDelay);
                }
            }
        }
    }
1307018
public function main()
    {
        if ($this->property === null) {
            throw new BuildException("property attribute required", $this->getLocation());
        }

        if ($this->file === null) {
            throw new BuildException("file attribute required", $this->getLocation());
        }

        $this->getProject()->setNewProperty(
            $this->property,
            $this->removeExtension($this->file->getName(), $this->suffix)
        );
    }
322540
public function main()
    {
        if ($this->file === null && empty($this->filesets)) {
            throw new BuildException("You must specify a file or fileset(s) for the <ReplaceRegexp> task.");
        }

        // compile a list of all files to modify, both file attrib and fileset elements
        // can be used.
        $files = [];

        if ($this->file !== null) {
            $files[] = $this->file;
        }

        if (!empty($this->filesets)) {
            $filenames = [];
            foreach ($this->filesets as $fs) {
                try {
                    $ds = $fs->getDirectoryScanner($this->project);
                    $filenames = $ds->getIncludedFiles(); // get included filenames
                    $dir = $fs->getDir($this->project);
                    foreach ($filenames as $fname) {
                        $files[] = new PhingFile($dir, $fname);
                    }
                } catch (BuildException $be) {
                    $this->log($be->getMessage(), Project::MSG_WARN);
                }
            }
        }

        $this->log("Applying Regexp processing to " . count($files) . " files.");

        // These "slots" allow filters to retrieve information about the currently-being-process files
        $slot = $this->getRegisterSlot("currentFile");
        $basenameSlot = $this->getRegisterSlot("currentFile.basename");

        $filter = new FilterChain($this->project);

        $r = new ReplaceRegexp();
        $r->setRegexps([$this->_regexp]);

        $filter->addReplaceRegexp($r);
        $filters = [$filter];

        foreach ($files as $file) {
            // set the register slots

            $slot->setValue($file->getPath());
            $basenameSlot->setValue($file->getName());

            // 1) read contents of file, pulling through any filters
            $in = null;
            try {
                $contents = "";
                $in = FileUtils::getChainedReader(new FileReader($file), $filters, $this->project);
                while (-1 !== ($buffer = $in->read())) {
                    $contents .= $buffer;
                }
                $in->close();
            } catch (Exception $e) {
                if ($in) {
                    $in->close();
                }
                $this->log("Error reading file: " . $e->getMessage(), Project::MSG_WARN);
            }

            try {
                // now create a FileWriter w/ the same file, and write to the file
                $out = new FileWriter($file);
                $out->write($contents);
                $out->close();
                $this->log("Applying regexp processing to " . $file->getPath(), Project::MSG_VERBOSE);
            } catch (Exception $e) {
                if ($out) {
                    $out->close();
                }
                $this->log("Error writing file back: " . $e->getMessage(), Project::MSG_WARN);
            }
        }
    }
297041
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }
        if (null === $this->getBranchname()) {
            throw new BuildException('"branchname" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('checkout');
        $command
            ->setOption('no-track', $this->isNoTrack())
            ->setOption('q', $this->isQuiet())
            ->setOption('force', $this->isForce())
            ->setOption('b', $this->isCreate())
            ->setOption('B', $this->isForceCreate())
            ->setOption('m', $this->isMerge());
        if ($this->isNoTrack()) {
            $command->setOption('track', $this->isTrack());
        }

        $command->addArgument($this->getBranchname());

        if (null !== $this->getStartPoint()) {
            $command->addArgument($this->getStartPoint());
        }

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

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

        $this->log(
            sprintf('git-checkout: checkout "%s" repository', $this->getRepository()),
            Project::MSG_INFO
        );
        $this->log('git-checkout output: ' . str_replace('\'', '', trim($output)), Project::MSG_INFO);
    }
275364
public function main()
    {
        if (null === $this->getRepository()) {
            throw new BuildException('"repository" is required parameter');
        }
        $remotes = trim($this->getRemote());
        if (null === $remotes || '' === $remotes) {
            throw new BuildException('"remote" is required parameter');
        }

        $client = $this->getGitClient(false, $this->getRepository());
        $command = $client->getCommand('merge');
        $command
            ->setOption('commit', $this->isCommit())
            ->setOption('q', $this->isQuiet());

        if ($this->getMessage()) {
            $command->setOption('message', $this->getMessage());
        }

        if (!$this->isCommit()) {
            $command->setOption('no-commit', $this->isNoCommit());
        }

        if ($this->isFastForwardCommit()) {
            $command->setOption('no-ff', true);
        }

        $strategy = $this->getStrategy();
        if ($strategy) {
            // check if strategy is valid
            if (false === in_array($strategy, $this->validStrategies)) {
                throw new BuildException(
                    "Could not find merge strategy '" . $strategy . "'\n" .
                    "Available strategies are: " . implode(', ', $this->validStrategies)
                );
            }
            $command->setOption('strategy', $strategy);
            if ($this->getStrategyOption()) {
                $command->setOption(
                    'strategy-option',
                    $this->getStrategyOption()
                );
            }
        }

        $remotes = explode(' ', $this->getRemote());
        foreach ($remotes as $remote) {
            $command->addArgument($remote);
        }

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

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

        $this->log(
            sprintf('git-merge: replaying "%s" commits', $this->getRemote()),
            Project::MSG_INFO
        );
        $this->log('git-merge output: ' . trim($output), Project::MSG_INFO);
    }
407449
public function main()
    {
        $message = $this->getMessage();
        if ($message === '') {
            throw new BuildException('"message" is a required parameter');
        }

        $user = $this->getUser();

        $clone = $this->getFactoryInstance('commit');
        $msg = sprintf("Commit: '%s'", $message);
        $this->log($msg, Project::MSG_INFO);
        $clone->setQuiet($this->getQuiet());
        $clone->setMessage($message);

        if (trim($user) === "") {
            throw new BuildException('"user" parameter can not be set to ""');
        }
        if ($user !== null) {
            $clone->setUser($user);
            $this->log("Commit: user = '$user'", Project::MSG_VERBOSE);
        }

        if ($this->repository === '') {
            $project = $this->getProject();
            $dir = $project->getProperty('application.startdir');
        } else {
            $dir = $this->repository;
        }
        $this->log('DIR:' . $dir, Project::MSG_INFO);
        $this->log('REPO: ' . $this->repository, Project::MSG_INFO);
        $cwd = getcwd();
        chdir($dir);

        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);
    }
262720
public function main()
    {
        if (!isset($this->url)) {
            throw new BuildException("Required attribute 'url' is missing");
        }

        try {
            $this->processResponse($this->createRequest()->send());
        } catch (HTTP_Request2_MessageException $e) {
            throw new BuildException($e);
        }
    }
1234381
public function main()
    {
        if (isset($this->schema) && !file_exists($this->schema->getPath())) {
            throw new BuildException("Schema file not found: " . $this->schema->getPath());
        }
        if (!isset($this->file) and count($this->filesets) == 0) {
            throw new BuildException("Missing either a nested fileset or attribute 'file' set");
        }

        set_error_handler([$this, 'errorHandler']);
        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);
                }
            }
        }
        restore_error_handler();
    }
1235381
public function main()
    {
        $buildFileRoot = $this->getProject()->getProperty('phing.file');
        $buildFile     = isset($this->_buildFile) ? $this->_buildFile : $buildFileRoot;
        $buildList     = $this->getBuildList($buildFileRoot);
        $parents       = array();
        $targets       = array();

        if (isset($this->_buildFile) && is_file($this->_buildFile)
            && !empty($this->getOwningTarget()->getName())
        ) {
            foreach ($buildList as $buildFile => $buildInfo) {
                if ($this->_buildFile === $buildFile
                    || in_array($buildInfo['parent'], $parents)
                ) {
                    $parents[] = $buildFile;
                    $targets   = array_merge(
                        $targets,
                        $this->getBuildTargets($buildFile)
                    );
                }
            }

            $targets = array_merge($targets, $this->project->helpTargets);
            $this->printBuildTargets($targets, $buildFile, $buildList);
        }

    }
672504
public function main(){
        
        if(is_null($this->getDomain())){
            throw new \BuildException('the domain property is required');
        }

        if(is_null($this->getName())){
            throw new \BuildException('the name property is required');
        }

        if(is_null($this->getVersion())){
            throw new \BuildException('the version property is required');
        }

        if(is_null($this->getTasklist())){
            throw new \BuildException('the tasklist property is required');
        }

        try {
            $workflow = $this->getService()->describeWorkflowType([
                'domain' => $this->getDomain(),
                'workflowType' => [
                    'name' => $this->getName(),
                    'version' => $this->getVersion()
                ]
            ]);

            if ($workflow->get('typeInfo')['status'] != 'REGISTERED') {
                throw new \BuildException('the workflow "' . $this->getName() . '" is no more available');
            }

            $this->log('The workflow "' . $this->getName() . '" already exists');
        } catch (SwfException $e) {
            $this->log('Creating "' . $this->getName() . '" v.' . $this->getVersion() . ' workflow');

            $params = [
                'domain' => $this->getDomain(),
                'name' => $this->getName(),
                'version' => $this->getVersion(),
                'description' => $this->getDescription(),
                'defaultTaskStartToCloseTimeout' => $this->getTaskStartToCloseTimeout() ?: 'NONE',
                'defaultExecutionStartToCloseTimeout' => $this->getExecutionStartToCloseTimeout() ?: 'NONE',
                'defaultTaskList' => [
                    'name' => $this->getTasklist()
                ]
            ];

            if ($this->getChildPolicy()) {
                $params['defaultChildPolicy'] = $this->getChildPolicy();
            }

            $this->getService()->registerWorkflowType($params);

            $this->log('"' . $this->getName() . '" v.' . $this->getVersion() . ' workflow successfully created');
        }
    }