多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# C.66 PearPackage2Task With the PearPackage2Task, you can create a `version 2` package.xml which can be installed using the PEAR installer. Use this in conjunction with the [TarTask](#TarTask) to completely script the building of a PEAR package. This task uses the PEAR\_PackageFileManager2 class. In order to be maximally flexible, the majority of options are set generically (using `<option>` tag) and are set using PEAR\_PackageFileManager::setOptions(). Use the `<mapping>` tag to represent complex values. Note that Travis Swicegood has created a more complete implementation of this functionality which can be found here: [pear.domain51.com](http://domain51.github.io/pear.domain51.com/). Table C.80:聽Attributes NameTypeDescriptionDefaultRequired`name``String`The name of the PEAR package.n/aYes`dir``String`The base directory of files to add to package.n/aYes C.66.1 Example ``` <pearpkg2 name="phing" dir="${build.src.dir}"> <option name="outputdirectory" value="./build"/> <option name="packagefile" value="package2.xml"/> <option name="packagedirectory" value="./${build.dist.dir}"/> <option name="baseinstalldir" value="${pkg.prefix}"/> <option name="channel" value="my.pear-channel.com"/> <option name="summary" value="${pkg.summary}"/> <option name="description" value="${pkg.description}"/> <option name="apiversion" value="${pkg.version}"/> <option name="apistability" value="beta"/> <option name="releaseversion" value="${pkg.version}"/> <option name="releasestability" value="beta"/> <option name="license" value="none"/> <option name="phpdep" value="5.0.0"/> <option name="pearinstallerdep" value="1.4.6"/> <option name="packagetype" value="php"/> <option name="notes" value="${pkg.relnotes}"/> <mapping name="maintainers"> <element> <element key="handle" value="hlellelid"/> <element key="name" value="Hans"/> <element key="email" value="hans@xmpl.org"/> <element key="role" value="lead"/> </element> </mapping> </pearpkg2> ``` C.66.2 Supported Nested Tags - `fileset` - `option` Table C.81:聽Available options NameTypeDescriptionDefaultRequired`summary``String`聽n/aYes`description``String`聽n/aYes`license``String`聽n/aYes`channel``String`Channel name (not alias!). Must be registered (`pear channel-discover channel`) on the machine, where the build will be.n/aYes`apiversion``String`聽n/aYes`releaseversion``String`聽n/aYes`releasestability``String`One from: snapshot, devel, alpha, beta or stable.n/aYes`apistability``String`One from: devel, alpha, beta or stable.n/aYes`note``String`聽n/aYes`packagetype``String`聽n/aYes`phpdep``String`聽n/aYes`pearinstallerdep``String`聽n/aYes - `mapping` The `<mapping>` tag represents a complex data type. You can use nested `<mapping>` (and nested `<element>` with `<element>` tags) to represent the full complexity of the structure. Bear in mind that what you are creating will be mapped to an associative array that will be passed in via `PEAR_PackageFileMaintainer::setOptions()` . ``` <mapping name="option_name"> <element key="key_name" value="key_val"/> <element key="key_name" value="key_val"/> </mapping> ``` Available mappings and they structures: - `deps` (optional) see [PEAR\_PackageFileManager::addDependency()](http://pear.php.net/manual/en/package.pear.pear-packagefilemanager.pear-packagefilemanager.adddependency.php) for more info Table C.82:聽Parameters NameTypeDescriptionDefaultRequired`channel``String`Channel name, from package is.n/aYes`name``String`Package name in channel.n/aYes`version``String`Minimal version.n/aYes`max``String`Maximum version.Same as version.No`recommended``String`Recommended version.Same as version.No - `extdeps` (optional) see [PEAR\_PackageFileManager::addDependency()](http://pear.php.net/manual/en/package.pear.pear-packagefilemanager.pear-packagefilemanager.adddependency.php) for more info Table C.83:聽Parameters NameTypeDescriptionDefaultRequired`name``String`Package name.n/aYes`version``String`Minimal version.n/aYes`max``String`Maximum version.Same as version.No`recommended``String`Recommended version.Same as version.No - `maintainers` (required at least one) see [PEAR\_PackageFileManager::addMaintainer()](http://pear.php.net/manual/en/package.pear.pear-packagefilemanager.pear-packagefilemanager.addmaintainer.php) for more info Table C.84:聽Parameters NameTypeDescriptionDefaultRequired`handle``String`User identifier in channel.n/aYes`name``String`Real name.n/aYes`email``String`聽n/aYes`role``String`One from: lead, developer, contributor or helper.n/aYes - `replacements` (optional) see [PEAR\_PackageFileManager::addReplacement()](http://pear.php.net/manual/en/package.pear.pear-packagefilemanager.pear-packagefilemanager.addreplacement.php) for more info Table C.85:聽Parameters NameTypeDescriptionDefaultRequired`path``String`Relative path of file.n/aYes`type``String`Variable type, either php-const, pear-config or package-info.n/aYes`from``String`Text to replace in the source file.n/aYes`to``String`Variable name to use for replacement.n/aYes - `role` See [PEAR\_PackageFileManager::addRole](http://pear.php.net/manual/en/package.pear.pear-packagefilemanager.pear-packagefilemanager.addrole.php) for more information. Available options: Table C.86:聽Parameters NameTypeDescriptionDefaultRequired`extension``String`The file extensionn/aYes`role``String`The file extensionn/aYes