Ticket #461: r773t461.patch

File r773t461.patch, 3.5 KB (added by simple.square@…, 2 years ago)

Patch adding phingVersion to project entity

  • classes/phing/Phing.php

     
    536536            $this->targets[] = $project->getDefaultTarget(); 
    537537        } 
    538538 
     539        // make sure that minimum required phing version is satisfied 
     540        try { 
     541            $this->comparePhingVersion($project->getPhingVersion());  
     542        } catch(Exception $exc) { 
     543            $project->fireBuildFinished($exc); 
     544            restore_error_handler(); 
     545            self::unsetCurrentProject(); 
     546            throw $exc; 
     547        } 
     548 
    539549        // execute targets if help param was not given 
    540550        if (!$this->projectHelp) { 
    541551 
     
    570580        self::unsetCurrentProject(); 
    571581    } 
    572582 
     583    private function comparePhingVersion($version) { 
     584        $current = strtolower(self::getPhingVersion()); 
     585        $current = trim(str_replace('phing', '', $current));  
     586 
     587        // make sure that version checks are not applied to trunk 
     588        if('dev' === $current) { 
     589            return 1; 
     590        } 
     591 
     592        if(-1 == version_compare($current, $version)) { 
     593            throw new BuildException( 
     594                sprintf('Incompatible Phing version (%s). Version "%s" required.', $current, $version)); 
     595        } 
     596    } 
     597 
    573598    /** 
    574599     * Bind any registered build listeners to this project. 
    575600     * 
  • classes/phing/Project.php

     
    9898    /** project description */ 
    9999    private $description; 
    100100 
     101    /** require phing version */ 
     102    private $phingVersion; 
     103 
    101104    /** a FileUtils object */ 
    102105    private $fileUtils; 
    103106     
     
    440443        return $this->description; 
    441444    } 
    442445 
     446    /** Set the minimum required phing version **/ 
     447    function setPhingVersion($version) { 
     448        $version = str_replace('phing', '', strtolower($version)); 
     449        $this->phingVersion = (string)trim($version); 
     450    } 
     451 
     452    /** Get the minimum required phing version **/ 
     453    function getPhingVersion() { 
     454        if($this->phingVersion === null) { 
     455            $this->setPhingVersion(Phing::getPhingVersion()); 
     456        } 
     457        return $this->phingVersion; 
     458    } 
     459 
    443460    /** Set basedir object from xml*/ 
    444461    function setBasedir($dir) { 
    445462        if ($dir instanceof PhingFile) { 
  • classes/phing/parser/ProjectHandler.php

     
    6969        $id    = null; 
    7070        $desc = null; 
    7171        $baseDir = null; 
     72        $ver = null; 
    7273 
    7374        // some shorthands 
    7475        $project = $this->configurator->project; 
     
    8586                $baseDir = $value; 
    8687            } elseif ($key === "description") { 
    8788                $desc = $value; 
     89            } elseif ($key === "phingVersion") { 
     90                $ver = $value; 
    8891            } else { 
    8992                throw new ExpatParseException("Unexpected attribute '$key'"); 
    9093            } 
     
    118121            $project->setDescription($desc); 
    119122          }         
    120123 
     124          if($ver !== null) { 
     125              $project->setPhingVersion($ver); 
     126          } 
     127 
    121128          if ($project->getProperty("project.basedir") !== null) { 
    122129            $project->setBasedir($project->getProperty("project.basedir")); 
    123130          } else {