@param mixed $buildFile

@return $this
@throws \Exception
961665
public function setBuildFile($buildFile)
    {
        if (!file_exists($this->getDirectory() . $buildFile)) {
            throw new \Exception(Lang::get('build_file_missing'));
        }

        $this->buildFile = $buildFile;
    }
887779
public function upload(UploadedFile $uploadedFile)
    {
        if ($this->blob === null) {
            throw new \Exception('Blob path is not set yet.');
        }

        $this->makeDirectory();

        $path = $this->blob->path;
        $ext = $uploadedFile->getClientOriginalExtension();
        $name = Slug::make(pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME));
        $uniqueName = $this->getUniqueFileName($path, $name, $ext);

        $fullName = $uniqueName . '.' . $ext;

        $this->storage->putFileAs($path, $uploadedFile, $fullName);

        $path .= '/' . $fullName;

        $this->blob->path = $path;

        if ($this->getMetaData()->isImage()) {
            (new ThumbService($this->package))
                ->resize($this->getMetaData()->getPath());
        }

        return $this->fullDetails();
    }
593961
private function write()
    {
        $project = $this->getProject();

        if (!touch($this->file->getPath())) {
            throw new BuildException("Unable to write to " . $this->file->getPath() . ".");
        }

        $this->log("Writing to " . $this->file->__toString(), Project::MSG_INFO);

        if (is_array($this->checksum)) {
            $this->log("Using " . implode(', ', $this->checksum) . " for checksuming.", Project::MSG_INFO);
        }

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

            $ds = $fs->getDirectoryScanner($project);
            $fromDir = $fs->getDir($project);
            $srcFiles = $ds->getIncludedFiles();
            $srcDirs = $ds->getIncludedDirectories();

            foreach ($ds->getIncludedFiles() as $file_path) {
                $line = $file_path;
                if ($this->checksum) {
                    foreach ($this->checksum as $algo) {
                        if (!$hash = $this->hashFile($dir . '/' . $file_path, $algo)) {
                            throw new BuildException("Hashing $dir/$file_path with $algo failed!");
                        }

                        $line .= "\t" . $hash;
                    }
                }
                $line .= "\n";
                $manifest[] = $line;
                $this->log("Adding file " . $file_path, Project::MSG_VERBOSE);
                $this->meta['totalFileCount']++;
                $this->meta['totalFileSize'] += filesize($dir . '/' . $file_path);
            }
        }

        file_put_contents($this->file, $manifest);

        $this->log(
            "Done. Total files: " . $this->meta['totalFileCount'] . ". Total file size: " . $this->meta['totalFileSize'] . " bytes.",
            Project::MSG_INFO
        );
    }
997106
public function addBuild(Build $build)
    {
        $this->getBuilds();
        $build->setRepositoryId($this->getId());
        $this->builds[$build->getId()] = $build;
    }
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!');
    }
1186868
protected function prepare()
    {
        if ($this->dir === null) {
            $this->dir = $this->getProject()->getBasedir();
        }

        if ($this->commandline->getExecutable() === null) {
            throw new BuildException(
                'ExecTask: Please provide "executable"'
            );
        }

        // expand any symbolic links first
        try {
            if (!$this->dir->getCanonicalFile()->exists()) {
                throw new BuildException(
                    "The directory '" . (string) $this->dir . "' does not exist"
                );
            }
            if (!$this->dir->getCanonicalFile()->isDirectory()) {
                throw new BuildException(
                    "'" . (string) $this->dir . "' is not a directory"
                );
            }
        } catch (IOException $e) {
            throw new BuildException(
                "'" . (string) $this->dir . "' is not a readable directory"
            );
        }
        $this->currdir = getcwd();
        @chdir($this->dir->getPath());

        $this->commandline->setEscape($this->escape);
    }
751019
public function setFile($file, $sourceFile = null) {
        if (!$file instanceof File) {
            $file = new File($file);
        }
        $this->file = $file;
        $this->sourceFile = empty($sourceFile) ? $file : $sourceFile;
        return $this;
    }
926495
public function main()
    {
        if (empty($this->file)) {
            throw new BuildException("Attribute 'file' required", $this->getLocation());
        }

        if (empty($this->property)) {
            throw new BuildException("Attribute 'property' required", $this->getLocation());
        }
        if ($this->quiet && $this->failOnError) {
            throw new BuildException("quiet and failonerror cannot both be set to true");
        }

        try {
            if (is_string($this->file)) {
                $this->file = new PhingFile($this->file);
            }
            if (!$this->file->exists()) {
                $message = (string) $this->file . ' doesn\'t exist';
                if ($this->failOnError) {
                    throw new BuildException($message);
                } else {
                    $this->log($message, $this->quiet ? Project::MSG_WARN : Project::MSG_ERR);
                    return;
                }
            }

            $this->log("loading " . (string) $this->file . " into property " . $this->property, Project::MSG_VERBOSE);
            // read file (through filterchains)
            $contents = "";

            if ($this->file->length() > 0) {
                $reader = FileUtils::getChainedReader(new FileReader($this->file), $this->filterChains, $this->project);
                while (-1 !== ($buffer = $reader->read())) {
                    $contents .= $buffer;
                }
                $reader->close();
            } else {
                $this->log(
                    "Do not set property " . $this->property . " as its length is 0.",
                    $this->quiet ? Project::MSG_VERBOSE : Project::MSG_INFO
                );
            }

            // publish as property
            if ($contents !== '') {
                $this->project->setNewProperty($this->property, $contents);
                $this->log("loaded " . strlen($contents) . " characters", Project::MSG_VERBOSE);
                $this->log($this->property . " := " . $contents, Project::MSG_DEBUG);
            }
        } catch (IOException $ioe) {
            $message = "Unable to load resource: " . $ioe->getMessage();
            if ($this->failOnError) {
                throw new BuildException($message, $ioe, $this->getLocation());
            } else {
                $this->log($message, $this->quiet ? Project::MSG_VERBOSE : Project::MSG_ERR);
            }
        } catch (BuildException $be) {
            if ($this->failOnError) {
                throw $be;
            } else {
                $this->log($be->getMessage(), $this->quiet ? Project::MSG_VERBOSE : Project::MSG_ERR);
            }
        }
    }
1300164
public function parseFromFile($pathToFile)
    {
        if (!file_exists($pathToFile)) {
            throw new Exception(
                "There is no {$pathToFile} file for parsing"
            );
        }

        try {
            $return = Yaml::parseFile($pathToFile);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $return;
    }
1361343
public static function build($file, $searchPath)
    {
        $builder = self::getInstance();

        $searchPath = empty($searchPath) ? __DIR__ : $searchPath;
        $searchPath = (array) $searchPath;

        $builder->setFile($file);
        $builder->readMap();

        foreach ($searchPath as $folder) {
            $files = $builder->getIterator($folder);
            $builder->iterateOverFiles($files);
        }

        $builder->save();
    }
159610
public function setTemplateFile(string $templateFile)
    {
        if (!$templateFile) {
            return $this;
        }
        $this->templateFile = (string) $templateFile;

        return $this;
    }
404456
protected function copyFile($sourceFile, $destFile) {
        $status = copy($sourceFile, $destFile);

        if ($status === false) {
            throw new Exception(sprintf(
                'Unable to copy file "%s" to "%s"',
                $sourceFile,
                $destFile
            ), ExitApp::RUNTIME_ERROR);
        }

        return $this;
    }
428984
public function build(): SetFileInputFilesRequest
	{
		$instance = new SetFileInputFilesRequest();
		if ($this->files === null) {
			throw new BuilderException('Property [files] is required.');
		}
		$instance->files = $this->files;
		$instance->nodeId = $this->nodeId;
		$instance->backendNodeId = $this->backendNodeId;
		$instance->objectId = $this->objectId;
		return $instance;
	}
104667
public function put($remoteFile, $localFile, $startPosision = 0)
    {
        $mode = $this->getMode();
        $result = @ftp_put($this->connection, $remoteFile, $localFile, $mode, $startPosision);
        
        if ($result === false) {
            throw new Exception('Unable to put file');
        }

        return $this;
    }
156093
public function setFile(File $file = null)
    {
        $this->file = $file;

        if (!empty($file)) {
            $size = @getimagesize($file->getPathname());

            if (is_array($size)) {
                list($this->width, $this->height) = $size;
            }

            $this->refreshUpdatedAt();
        }

        return $this;
    }
804723
public function addCoverageFromFile(string $coverageFile = null)
    {
        if ($coverageFile === null || !file_exists($coverageFile)) {
            return;
        }

        $file = new \SplFileObject($coverageFile);

        if (0 === $file->getSize()) {
            $extra = 'This means a PHPUnit process has crashed.';

            if (!\function_exists('xdebug_get_code_coverage')) {
                $extra = 'Xdebug is disabled! Enable for coverage.';
            }

            throw new \RuntimeException(
                "Coverage file {$file->getRealPath()} is empty. " . $extra
            );
        }

        $this->addCoverage($this->getCoverageObject($file));

        unlink($file->getRealPath());
    }
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();
            }
        }
    }