diff options
author | knut <> | 2006-04-27 05:11:03 +0000 |
---|---|---|
committer | knut <> | 2006-04-27 05:11:03 +0000 |
commit | b387c4ae04ed2854dab5cd608468a95d3d49721c (patch) | |
tree | 899a9a2a23ae91a0594256e253323c396d1cc4ae | |
parent | cb01c9389c481ea9bf09eecbed9102b623f87d62 (diff) |
Added first test version of PEAR packaging through Phing. Run "phing dist-pear" to test it.
-rw-r--r-- | .gitattributes | 1 | ||||
-rw-r--r-- | build.xml | 36 | ||||
-rw-r--r-- | buildscripts/phing/tasks/BuildPradoPEARPackageTask.php | 201 |
3 files changed, 234 insertions, 4 deletions
diff --git a/.gitattributes b/.gitattributes index 7b1781d5..c8fb6ada 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,6 +11,7 @@ buildscripts/phing/style/log.xsl -text buildscripts/phing/style/phpunit2-frames.xsl -text buildscripts/phing/style/phpunit2-noframes.xsl -text buildscripts/phing/style/str.replace.function.xsl -text +buildscripts/phing/tasks/BuildPradoPEARPackageTask.php -text buildscripts/phing/tasks/PhpLintTask.php -text buildscripts/phing/tasks/XmlLintTask.php -text buildscripts/phing/tasks/ZendCodeAnalyzerTask.php -text @@ -15,7 +15,7 @@ <property name="state" value=""/> <property name="pear.state" value="stable"/> <property name="pkgname" value="${phing.project.name}-${version}${state}"/> - <property name="pkgname.pear" value="${pkgname}${pear.state}-pear"/> + <property name="pkgname.pear" value="${pkgname}-pear"/> <property name="src.dir" value="framework"/> <property name="doc.dir" value="docs"/> <property name="build.base.dir" value="build"/> @@ -38,10 +38,12 @@ <property name="codecoverage" value="false"/> <property name="zca" value="/usr/local/Zend/ZendStudioClient-5.1.0/bin/ZendCodeAnalyzer"/> <property name="quickstart" value="${build.base.dir}/docs/prado3_quick_start.pdf"/> + <property name="notes">This is the latest release of PRADO.</property> <taskdef name="phplint" classname="PhpLintTask" classpath="buildscripts/phing/tasks"/> <taskdef name="xmllint" classname="XmlLintTask" classpath="buildscripts/phing/tasks"/> <taskdef name="analyze" classname="ZendCodeAnalyzerTask" classpath="buildscripts/phing/tasks"/> + <taskdef name="pear-package" classname="BuildPradoPEARPackageTask" classpath="buildscripts/phing/tasks"/> <!-- PHP Source Files in framework @@ -52,7 +54,7 @@ </fileset> <!-- - Various resource files in framework + All Source Files in framework --> <fileset dir="." id="framework"> <exclude name="${src.dir}/**/.svn"/> @@ -213,7 +215,6 @@ </then> </if> </target> - <target name="build-standard-package"> <echo>Building standard package...</echo> @@ -228,8 +229,35 @@ </fileset> </copy> </target> + + <target name="build-pear-package"> + <echo>Preparing files for PEAR package...</echo> + <delete dir="${build.pear.dir}"/> + <mkdir dir="${build.pear.dir}"/> + <copy todir="${build.pear.dir}"> + <fileset refid="src"/> + <fileset dir="${build.base.dir}"> + <include name="${prado.lite}"/> + </fileset> + </copy> + + <echo>Creating package.xml...</echo> + <pear-package dir="${build.pear.dir}" destFile="${build.base.dir}/pear/package.xml" version="${version}" state="${pear.state}" notes="${notes}"> + <fileset refid="src"/> + <fileset dir="${build.base.dir}"> + <include name="${prado.lite}"/> + </fileset> + </pear-package> + </target> - <target name="build" depends="versioncheck,prepare,doc,pradolite,build-standard-package" description="Creating the main PRADO build"/> + <target name="build" depends="versioncheck,prepare,doc,quickstart,pradolite,build-standard-package,build-pear-package" description="Creating the main PRADO build"/> + + <target name="dist-pear" depends="build-pear-package" description="Create PRADO PEAR package"> + <delete file="${dist.pearfile}"/> + <mkdir dir="${dist.base.dir}"/> + <tar compression="gzip" destFile="${dist.pearfile}" basedir="${build.base.dir}/pear"/> + <exec command="pear package-validate ${dist.pearfile}" dir="." passthru="true"/> + </target> <target name="dist" depends="build" description="Create PRADO distributions"> <!--<tar compression="gzip" destFile="${dist.tarfile}" basedir="${build.base.dir}/standard"/>--> diff --git a/buildscripts/phing/tasks/BuildPradoPEARPackageTask.php b/buildscripts/phing/tasks/BuildPradoPEARPackageTask.php new file mode 100644 index 00000000..212c6f9c --- /dev/null +++ b/buildscripts/phing/tasks/BuildPradoPEARPackageTask.php @@ -0,0 +1,201 @@ +<?php +require_once 'phing/tasks/system/MatchingTask.php'; +include_once 'phing/types/FileSet.php'; +include_once 'phing/tasks/ext/pearpackage/Fileset.php'; +require_once 'PEAR/PackageFileManager.php'; +require_once 'PEAR/PackageFileManager/File.php'; + +/** + * Task for creating a PEAR package definition file package.xml to be used with + * the PEAR distribution of PRADO. + * + * @author Knut Urdalen <knut.urdalen@gmail.com> + * @package phing.tasks.ext + */ +class BuildPradoPEARPackageTask extends MatchingTask { + + /* Base directory for reading files. */ + private $dir; + + /* PRADO version */ + private $version; + + /* PRADO state */ + private $state = 'stable'; + private $notes; + private $filesets = array(); + + /* Package file */ + private $packageFile; + + /** + * Intitialize the task and throw a BuildException if something is missing. + */ + public function init() { + include_once 'PEAR/PackageFileManager2.php'; + if(!class_exists('PEAR_PackageFileManager2')) { + throw new BuildException("You must have installed PEAR_PackageFileManager2 (PEAR_PackageFileManager >= 1.6.0) in order to create a PEAR package.xml file."); + } + } + + /** + * Helper function to set PEAR package options. + * + * @param PEAR_PackageFileManager2 $pkg + */ + private function setOptions($pkg) { + $options['baseinstalldir'] = 'prado'; + $options['packagedirectory'] = $this->dir->getAbsolutePath(); + + if(empty($this->filesets)) { + throw new BuildException("You must use a <fileset> tag to specify the files to include in the package.xml"); + } + + $options['filelistgenerator'] = 'Fileset'; + + // Some Phing-specific options needed by our Fileset reader + $options['phing_project'] = $this->getProject(); + $options['phing_filesets'] = $this->filesets; + + if($this->packageFile !== null) { + // Create one with full path + $f = new PhingFile($this->packageFile->getAbsolutePath()); + $options['packagefile'] = $f->getName(); + // Must end in trailing slash + $options['outputdirectory'] = $f->getParent().DIRECTORY_SEPARATOR; + $this->log("Creating package file: ".$f->getPath(), PROJECT_MSG_INFO); + } else { + $this->log("Creating [default] package.xml file in base directory.", PROJECT_MSG_INFO); + } + $pkg->setOptions($options); + } + + /** + * Main entry point. + * @return void + */ + public function main() { + + if($this->dir === null) { + throw new BuildException("You must specify the \"dir\" attribute for PEAR package task."); + } + + if($this->version === null) { + throw new BuildException("You must specify the \"version\" attribute for PEAR package task."); + } + + $package = new PEAR_PackageFileManager2(); + $this->setOptions($package); + + // the hard-coded stuff + $package->setPackage('prado'); + $package->setSummary('PRADO is a component-based and event-driven framework for rapid Web programming in PHP 5.'); + $package->setDescription('PRADO reconceptualizes Web application development in terms of components, events and properties instead of procedures, URLs and query parameters. + +A PRADO component is a combination of a specification file (in XML), an HTML template and a PHP class. PRADO components are combined together to form larger components or complete PRADO pages. + +Developing PRADO Web applications mainly involves instantiating prebuilt and application-specific component types, configuring them by setting their properties, responding to their events by writing handler functions, and composing them into application tasks. Event-driven programming + +PRADO provides the following benefits for Web application developers: + +o Reusability - Codes following the PRADO component protocol are highly reusable. Everything in PRADO is a reusable component. +o Ease of Use - Creating and using components are extremely easy. Usually they simply involve configuring component properties. +o Robustness - PRADO frees developers from writing boring, buggy code. They code in terms of objects, methods and properties, instead of URLs and query parameters. The latest PHP5 exception mechanism is exploited that enables line-precise error reporting. +o Performance - PRADO uses a cache technique to ensure the performance of applications based on it. The performance is in fact comparable to those based on commonly used template engines. +o Team Integration - PRADO enables separation of content and presentation. Components, typically pages, have their content (logic) and presentation stored in different files.'); + $package->setChannel('pear.pradosoft.com'); + $package->setPackageType('php'); + + $package->setReleaseVersion($this->version); + $package->setAPIVersion($this->version); + + $package->setReleaseStability($this->state); + $package->setAPIStability($this->state); + + $package->setNotes($this->notes); + + $package->setLicense('BSD', 'http://www.opensource.org/licenses/bsd-license.php'); + + // Add package maintainers + $package->addMaintainer('lead', 'xue', 'Qiang Xue', 'qiang.xue@gmail.com'); + + // "core" dependencies + $package->setPhpDep('5.0.0'); + $package->setPearinstallerDep('1.4.0'); + + $package->generateContents(); + + $e = $package->writePackageFile(); + + if(PEAR::isError($e)) { + throw new BuildException("Unable to write package file.", new Exception($e->getMessage())); + } + } + + /** + * Used by the PEAR_PackageFileManager_PhingFileSet lister. + * @return array FileSet[] + */ + public function getFileSets() { + return $this->filesets; + } + + // ------------------------------- + // Set properties from XML + // ------------------------------- + + /** + * Nested creator, creates a FileSet for this task + * + * @return FileSet The created fileset object + */ + function createFileSet() { + $num = array_push($this->filesets, new FileSet()); + return $this->filesets[$num-1]; + } + + /** + * Set the version we are building. + * @param string $v + * @return void + */ + public function setVersion($v){ + $this->version = $v; + } + + /** + * Set the state we are building. + * @param string $v + * @return void + */ + public function setState($v) { + $this->state = $v; + } + + /** + * Sets release notes field. + * @param string $v + * @return void + */ + public function setNotes($v) { + $this->notes = $v; + } + /** + * Sets "dir" property from XML. + * @param PhingFile $f + * @return void + */ + public function setDir(PhingFile $f) { + $this->dir = $f; + } + + /** + * Sets the file to use for generated package.xml + */ + public function setDestFile(PhingFile $f) { + $this->packageFile = $f; + } + +} + + |