[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/propel-generator/pear/ -> BuildPropelGenPEARPackageTask.php (source)

   1  <?php
   2  /*
   3   *  $Id: BuildPropelGenPEARPackageTask.php 1310 2006-05-04 07:36:54Z fabien $
   4   *
   5   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   6   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   7   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   8   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   9   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16   *
  17   * This software consists of voluntary contributions made by many individuals
  18   * and is licensed under the LGPL. For more information please see
  19   * <http://phing.info>.
  20   */
  21  
  22  require_once 'phing/tasks/system/MatchingTask.php';
  23  include_once 'phing/types/FileSet.php';
  24  include_once 'phing/tasks/ext/pearpackage/Fileset.php';
  25  
  26  /**
  27   *
  28   * @author   Hans Lellelid <hans@xmpl.org>
  29   * @package  phing.tasks.ext
  30   * @version  $Revision$
  31   */
  32  class BuildPropelGenPEARPackageTask extends MatchingTask {
  33  
  34      /** Base directory for reading files. */
  35      private $dir;
  36  
  37      private $version;
  38      private $state = 'stable';
  39      private $notes;
  40  
  41      private $filesets = array();
  42  
  43      /** Package file */
  44      private $packageFile;
  45  
  46      public function init() {
  47          include_once 'PEAR/PackageFileManager2.php';
  48          if (!class_exists('PEAR_PackageFileManager2')) {
  49              throw new BuildException("You must have installed PEAR_PackageFileManager2 (PEAR_PackageFileManager >= 1.6.0) in order to create a PEAR package.xml file.");
  50          }
  51      }
  52  
  53      private function setOptions($pkg){
  54  
  55          $options['baseinstalldir'] = 'propel';
  56          $options['packagedirectory'] = $this->dir->getAbsolutePath();
  57  
  58          if (empty($this->filesets)) {
  59              throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml");
  60          }
  61  
  62          $options['filelistgenerator'] = 'Fileset';
  63  
  64          // Some PHING-specific options needed by our Fileset reader
  65          $options['phing_project'] = $this->getProject();
  66          $options['phing_filesets'] = $this->filesets;
  67  
  68          if ($this->packageFile !== null) {
  69              // create one w/ full path
  70              $f = new PhingFile($this->packageFile->getAbsolutePath());
  71              $options['packagefile'] = $f->getName();
  72              // must end in trailing slash
  73              $options['outputdirectory'] = $f->getParent() . DIRECTORY_SEPARATOR;
  74              $this->log("Creating package file: " . $f->getPath(), PROJECT_MSG_INFO);
  75          } else {
  76              $this->log("Creating [default] package.xml file in base directory.", PROJECT_MSG_INFO);
  77          }
  78  
  79          // add install exceptions
  80          $options['installexceptions'] = array(    'pear/pear-propel-gen' => '/',
  81                                                  'pear/pear-propel-gen.bat' => '/',
  82                                                  'pear/pear-build.xml' => '/',
  83                                                  'pear/build.properties' => '/',
  84                                                  );
  85  
  86          $options['dir_roles'] = array(    'projects' => 'data',
  87                                          'test' => 'test',
  88                                          'templates' => 'data',
  89                                          'resources' => 'data');
  90  
  91          $options['exceptions'] = array(    'pear/pear-propel-gen.bat' => 'script',
  92                                          'pear/pear-propel-gen' => 'script',
  93                                          'pear/pear-build.xml' => 'data',
  94                                          'build.xml' => 'data',
  95                                          'build-propel.xml' => 'data',
  96                                      );
  97  
  98          $pkg->setOptions($options);
  99  
 100      }
 101  
 102      /**
 103       * Main entry point.
 104       * @return void
 105       */
 106      public function main() {
 107  
 108          if ($this->dir === null) {
 109              throw new BuildException("You must specify the \"dir\" attribute for PEAR package task.");
 110          }
 111  
 112          if ($this->version === null) {
 113              throw new BuildException("You must specify the \"version\" attribute for PEAR package task.");
 114          }
 115  
 116          $package = new PEAR_PackageFileManager2();
 117  
 118          $this->setOptions($package);
 119  
 120          // the hard-coded stuff
 121          $package->setPackage('propel_generator');
 122          $package->setSummary('Generator component of the Propel PHP object persistence layer');
 123          $package->setDescription('Propel is an object persistence layer for PHP5 based on Apache Torque. This package provides the generator engine that builds PHP classes and SQL DDL based on an XML representation of your data model.');
 124          $package->setChannel('pear.phpdb.org');
 125          $package->setPackageType('php');
 126  
 127          $package->setReleaseVersion($this->version);
 128          $package->setAPIVersion($this->version);
 129  
 130          $package->setReleaseStability($this->state);
 131          $package->setAPIStability($this->state);
 132  
 133          $package->setNotes($this->notes);
 134  
 135          $package->setLicense('LGPL', 'http://www.gnu.org/licenses/lgpl.html');
 136  
 137          // Add package maintainers
 138          $package->addMaintainer('lead', 'hans', 'Hans Lellelid', 'hans@xmpl.org');
 139          $package->addMaintainer('lead', 'david', 'David Zuelke', 'dz@bitxtender.com');
 140  
 141  
 142  
 143          // (wow ... this is a poor design ...)
 144          //
 145          // note that the order of the method calls below is creating
 146          // sub-"release" sections which have specific rules.  This replaces
 147          // the platformexceptions system in the older version of PEAR's package.xml
 148          //
 149          // Programmatically, I feel the need to re-iterate that this API for PEAR_PackageFileManager
 150          // seems really wrong.  Sub-sections should be encapsulated in objects instead of having
 151          // a "flat" API that does not represent the structure being created....
 152  
 153  
 154          // creating a sub-section for 'windows'
 155              $package->addRelease();
 156              $package->setOSInstallCondition('windows');
 157              $package->addInstallAs('pear/pear-propel-gen.bat', 'propel-gen.bat');
 158              $package->addIgnoreToRelease('pear/pear-propel-gen');
 159  
 160          // creating a sub-section for non-windows
 161              $package->addRelease();
 162              $package->addInstallAs('pear/pear-propel-gen', 'propel-gen');
 163              $package->addIgnoreToRelease('pear/pear-propel-gen.bat');
 164  
 165  
 166          // "core" dependencies
 167          $package->setPhpDep('5.0.0');
 168          $package->setPearinstallerDep('1.4.0');
 169  
 170          // "package" dependencies
 171          $package->addPackageDepWithChannel( 'required', 'phing', 'pear.phing.info', '2.2.0RC1');
 172          $package->addPackageDepWithChannel( 'required', 'creole', 'pear.phpdb.org', '1.1.0RC1');
 173  
 174          // now add the replacements ....
 175          $package->addReplacement('Phing.php', 'pear-config', '@DATA-DIR@', 'data_dir');
 176          $package->addReplacement('pear/pear-propel-gen.bat', 'pear-config', '@PHP-BIN@', 'php_bin');
 177          $package->addReplacement('pear/pear-propel-gen.bat', 'pear-config', '@BIN-DIR@', 'bin_dir');
 178          $package->addReplacement('pear/pear-propel-gen.bat', 'pear-config', '@PEAR-DIR@', 'php_dir');
 179          $package->addReplacement('pear/pear-propel-gen.bat', 'pear-config', '@DATA-DIR@', 'data_dir');
 180  
 181          $package->addReplacement('pear/pear-propel-gen', 'pear-config', '@PHP-BIN@', 'php_bin');
 182          $package->addReplacement('pear/pear-propel-gen', 'pear-config', '@BIN-DIR@', 'bin_dir');
 183          $package->addReplacement('pear/pear-propel-gen', 'pear-config', '@PEAR-DIR@', 'php_dir');
 184          $package->addReplacement('pear/pear-propel-gen', 'pear-config', '@DATA-DIR@', 'data_dir');
 185  
 186          $package->addReplacement('pear/pear-build.xml', 'pear-config', '@PHP-BIN@', 'php_bin');
 187          $package->addReplacement('pear/pear-build.xml', 'pear-config', '@BIN-DIR@', 'bin_dir');
 188          $package->addReplacement('pear/pear-build.xml', 'pear-config', '@PEAR-DIR@', 'php_dir');
 189          $package->addReplacement('pear/pear-build.xml', 'pear-config', '@DATA-DIR@', 'data_dir');
 190  
 191  
 192          // now we run this weird generateContents() method that apparently
 193          // is necessary before we can add replacements ... ?
 194          $package->generateContents();
 195  
 196          $e = $package->writePackageFile();
 197  
 198          if (PEAR::isError($e)) {
 199              throw new BuildException("Unable to write package file.", new Exception($e->getMessage()));
 200          }
 201  
 202      }
 203  
 204      /**
 205       * Used by the PEAR_PackageFileManager_PhingFileSet lister.
 206       * @return array FileSet[]
 207       */
 208      public function getFileSets() {
 209          return $this->filesets;
 210      }
 211  
 212      // -------------------------------
 213      // Set properties from XML
 214      // -------------------------------
 215  
 216      /**
 217       * Nested creator, creates a FileSet for this task
 218       *
 219       * @return FileSet The created fileset object
 220       */
 221      function createFileSet() {
 222          $num = array_push($this->filesets, new FileSet());
 223          return $this->filesets[$num-1];
 224      }
 225  
 226      /**
 227       * Set the version we are building.
 228       * @param string $v
 229       * @return void
 230       */
 231  	public function setVersion($v){
 232          $this->version = $v;
 233      }
 234  
 235      /**
 236       * Set the state we are building.
 237       * @param string $v
 238       * @return void
 239       */
 240  	public function setState($v) {
 241          $this->state = $v;
 242      }
 243  
 244      /**
 245       * Sets release notes field.
 246       * @param string $v
 247       * @return void
 248       */
 249  	public function setNotes($v) {
 250          $this->notes = $v;
 251      }
 252      /**
 253       * Sets "dir" property from XML.
 254       * @param PhingFile $f
 255       * @return void
 256       */
 257      public function setDir(PhingFile $f) {
 258          $this->dir = $f;
 259      }
 260  
 261      /**
 262       * Sets the file to use for generated package.xml
 263       */
 264      public function setDestFile(PhingFile $f) {
 265          $this->packageFile = $f;
 266      }
 267  
 268  }
 269  
 270  


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7