コード例 #1
0
 /**
  *  Run the task.
  *
  * @throws BuildException  trouble, probably file IO
  */
 public function main()
 {
     if ($this->prefix != null && $this->regex != null) {
         throw new BuildException("Please specify either prefix or regex, but not both", $this->getLocation());
     }
     //copy the properties file
     $allProps = array();
     /* load properties from file if specified, otherwise use Phing's properties */
     if ($this->inFile == null) {
         // add phing properties
         $allProps = $this->getProject()->getProperties();
     } elseif ($this->inFile != null) {
         if ($this->inFile->exists() && $this->inFile->isDirectory()) {
             $message = "srcfile is a directory!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         if ($this->inFile->exists() && !$this->inFile->canRead()) {
             $message = "Can not read from the specified srcfile!";
             $this->failOnErrorAction(null, $message, Project::MSG_ERR);
             return;
         }
         try {
             $props = new Properties();
             $props->load(new PhingFile($this->inFile));
             $allProps = $props->getProperties();
         } catch (IOException $ioe) {
             $message = "Could not read file " . $this->inFile->getAbsolutePath();
             $this->failOnErrorAction($ioe, $message, Project::MSG_WARN);
             return;
         }
     }
     $os = null;
     try {
         if ($this->destfile == null) {
             $os = Phing::getOutputStream();
             $this->saveProperties($allProps, $os);
             $this->log($os, Project::MSG_INFO);
         } else {
             if ($this->destfile->exists() && $this->destfile->isDirectory()) {
                 $message = "destfile is a directory!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             if ($this->destfile->exists() && !$this->destfile->canWrite()) {
                 $message = "Can not write to the specified destfile!";
                 $this->failOnErrorAction(null, $message, Project::MSG_ERR);
                 return;
             }
             $os = new FileOutputStream($this->destfile);
             $this->saveProperties($allProps, $os);
         }
     } catch (IOException $ioe) {
         $this->failOnErrorAction($ioe);
     }
 }
コード例 #2
0
ファイル: DiagnosticsTask.php プロジェクト: Ingewikkeld/phing
 /**
  * Execute the task.
  * This delegates to the Diagnostics class.
  * @throws BuildException on error.
  */
 public function main()
 {
     Diagnostics::doReport(new PrintStream(Phing::getOutputStream()));
 }