Sunday, February 04, 2007

Zend Framework & a PEAR channel

Zend Framework has a PEAR channel. Unfortunately, it's lagging behind in terms of available releases.

I sparked off a dead-horse-beating on the mailing list (should zend be shipped as one big pear package, or itty bitty pieces with very strict dependencies); and whinged that it was so out of date.

In particular, why aren't they using a phing task to automate creating a package.xml? They are already doing it for other things.

The response: don't whing about it, do it!


So; here it is:


<?xml version="1.0"?>
<!--

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.

@copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
@license http://framework.zend.com/license/new-bsd New BSD License

Requirements:

- PHP 5.1.4
- Phing 2.2.0
- PHPDocumentor 1.3.1
- VersionControl_SVN 0.3

Requirements for running tests (not yet implemented):
- PHPUnit 3.0.0
- Xdebug 2.0

Usage:

phing [ <options> ] [ <targets> ]

Options:

-Dtree={core|incubator}
Render documentation for core or incubator only.

-Dlang={en|ar|de|es|fr|ja|nl|pl|pt-br|ru|zh}
Render core manual for specified language only.

Targets:
pear
Stage product, and create a pear package

dist
Stage product, build docs, create tarball and zip archives.
This is the default target.

build
Stage product and build docs.

docs
Build both docbook manual and phpdoc API documentation.

manual
Build docbook manual only.
Aliases to do the same thing: docbook, build.manual

api
Build phpdoc API documentation only.
Aliases to do the same thing: apidoc, build.apidoc.

clean
Remove staged directory. Leave tarball and zip archives.

clean.all
Remove staged directory, and also tarball and zip archives.

clean.docs
Remove only rendered documentation files.

-->
<project name="ZendFramework" default="dist" basedir=".">

<path id="zf.class.path">
<pathelement dir="${project.basedir}/phing/tasks" />
</path>
<taskdef name="entitynames" classname="zend.docbook.EntityNamesTask">
<classpath refid="zf.class.path" />
</taskdef>

<property name="zf.src.default" value="${project.basedir}/.." />
<property name="zf.product.name" value="Zend Framework" />
<property name="zf.productname" value="ZendFramework" />
<property name="zf.pearname" value="Zend" />
<property name="zf.version" value="0.6.0" />
<property name="svn.url" value="http://framework.zend.com/svn" />
<property name="zf.svn.url" value="${svn.url}/framework/trunk" />
<property name="zf.svn.tag" value="HEAD" />
<property name="zf.export.dir" value="./${zf.productname}-export-${zf.svn.tag}" />
<property name="stage.home" value="${project.basedir}/stage" />
<property name="zf.stage.dir" value="${stage.home}/${zf.productname}-${zf.version}" />
<property name="zf.tarball" value="${stage.home}/${zf.productname}-${zf.version}.tar" />
<property name="zf.zipball" value="${stage.home}/${zf.productname}-${zf.version}.zip" />
<property name="zf.apidoc.output.style" value="HTML:frames:DOM/earthli" />
<property name="lang" value="en,ar,de,es,fr,ja,nl,pl,pt-br,ru,zh" />
<property name="tree" value="core,incubator" />

<target name="dist" depends="build"
description="Stage product, build docs, create tarball and zip archives. This is the default target.">
<echo message="Creating tar and zip archives..." />
<tar destfile="${zf.tarball}.gz" basedir="${zf.stage.dir}" compression="gzip" />
<zip destfile="${zf.zipball}" basedir="${zf.stage.dir}" />
</target>

<target name="build" depends="stage,pear,docs" description="Stage product and build docs.">
</target>

<target name="pear" depends="stage"
description="Create a pear package.">
<mkdir dir="${stage.home}/pear" />
<echo msg="Creating PEAR package" />
<pearpkg name="${zf.pearname}" dir="${zf.stage.dir}" destFile="${stage.home}/pear/package.xml">
<fileset dir="${zf.stage.dir}/library/">
<!--
<exclude name="**/.svn/**" />
<exclude name="build-tools/**" />
-->
</fileset>
<option name="notes">See http://framework.zend.com/changelog for full changes</option>
<option name="description">${zf.product.name}</option>

<option name="summary">Zend Framework is an open source effort aimed at producing a high-quality framework for developing modern, robust, secure web applications and web services in PHP 5.</option>
<option name="version" value="${zf.version}"/>
<option name="state" value="beta"/>
<option name="license" value="BSD"/>

<mapping name="maintainers">
<element>
<element key="handle" value="olekvi"/>
<element key="name" value="Ole Bendik Kvisberg"/>
<element key="email" value="olekvi@linpro.no"/>
<element key="role" value="lead"/>
</element>
</mapping>

<mapping name="deps">
<element>
<element key="type" value="php"/>
<element key="version" value="5.0.1"/>
<element key="rel" value="ge"/>
</element>
</mapping>

</pearpkg>
</target>

<target name="stage" depends="prepare,source.export"
description="">
<echo msg="Staging files from ${zf.src} to ${zf.stage.dir}" />
<copy todir="${zf.stage.dir}">
<fileset dir="${zf.src}">
<exclude name="**/.svn/**" />
<exclude name="build-tools/**" />
<exclude name="documentation/**" />
<exclude name="incubator/documentation/**" />
<exclude name="incubator/tests/TestConfiguration.php" />
<exclude name="scripts/**" />
<exclude name="tests/TestConfiguration.php" />
</fileset>
</copy>
<echo file="${zf.stage.dir}/VERSION.txt">
${zf.product.name} Preview Release ${zf.version} (build ${zf.svn.revision})
</echo>
</target>

<target name="prepare" depends="source.check">
<mkdir dir="${zf.stage.dir}" />
</target>

<target name="source.check">
<available file="${zf.src.default}/library/Zend.php" property="zf.src" value="${zf.src.default}" />
<svnlastrevision svnpath="svn"
repositoryurl="${zf.svn.url}"
workingcopy="${project.basedir}"
propertyname="zf.svn.revision" />
</target>

<target name="source.export" unless="zf.src">
<svnexport svnpath="svn"
repositoryurl="${zf.svn.url}"
todir="${zf.export.dir}" />
<property name="zf.src" value="${zf.export.dir}" />
</target>

<target name="docs" depends="build.manual,build.apidoc"
description="Build both docbook manual and phpdoc API documentation." />

<target name="manual" depends="build.manual"
description="Build docbook manual only." />
<target name="docbook" depends="build.manual" />
<target name="build.manual" depends="prepare,source.export">
<echo msg="Building manual for ${tree}..." />
<foreach list="${tree}" param="zf.tree" target="build.manual.common" />
</target>

<target name="build.manual.common">
<condition property="zf.manual.src" value="${zf.src}/documentation/manual">
<equals arg1="${zf.tree}" arg2="core" />
</condition>
<condition property="zf.manual.src" value="${zf.src}/incubator/documentation/manual">
<equals arg1="${zf.tree}" arg2="incubator" />
</condition>

<condition property="zf.manual.dest" value="${zf.stage.dir}/documentation/end-user/core">
<equals arg1="${zf.tree}" arg2="core" />
</condition>
<condition property="zf.manual.dest" value="${zf.stage.dir}/documentation/end-user/incubator">
<equals arg1="${zf.tree}" arg2="incubator" />
</condition>

<foreach list="${lang}" param="zf.lang" target="build.manual.lang.check" />
</target>

<target name="build.manual.lang.check" depends="source.export">
<available file="${zf.manual.src}/${zf.lang}/manual.xml" property="zf.lang.exists" />
<phingcall target="build.manual.lang">
<property name="zf.manual.src.dir" value="${zf.manual.src}/${zf.lang}" />
<property name="zf.manual.dest.dir" value="${zf.manual.dest}/${zf.lang}" />
</phingcall>
</target>

<target name="build.manual.lang" if="zf.lang.exists">
<echo msg="Building manual for tree: ${zf.tree}, language: ${zf.lang}..." />

<echo msg="Generating XML entities..." />
<entitynames outputfile="${zf.manual.src.dir}/entities.ent">
<filelist dir="${zf.manual.src.dir}" files="ref,module_specs" />
</entitynames>

<mkdir dir="${zf.manual.dest.dir}" />
<!-- @TODO: make xslt task work with external entities
<xslt todir="${zf.manual.dest.dir}" style="${zf.manual.src.dir}/../.build/html.xsl">
<fileset dir=".">
<include name="manual.xml" />
</fileset>
</xslt>
-->
<echo msg="done." />
</target>

<target name="api" depends="build.apidoc"
description="Build phpdoc API documentation only." />
<target name="apidoc" depends="build.apidoc" />
<target name="build.apidoc" depends="prepare,source.export">
<foreach list="${tree}" param="zf.tree" target="build.apidoc.common" />
</target>

<target name="build.apidoc.common">
<condition property="zf.apidoc.src.dir" value="${zf.src}/library">
<equals arg1="${zf.tree}" arg2="core" />
</condition>
<condition property="zf.apidoc.src.dir" value="${zf.src}/incubator/library">
<equals arg1="${zf.tree}" arg2="incubator" />
</condition>

<condition property="zf.apidoc.dest.dir" value="${zf.stage.dir}/documentation/api/core">
<equals arg1="${zf.tree}" arg2="core" />
</condition>
<condition property="zf.apidoc.dest.dir" value="${zf.stage.dir}/documentation/api/incubator">
<equals arg1="${zf.tree}" arg2="incubator" />
</condition>

<condition property="zf.apidoc.label" value="">
<equals arg1="${zf.tree}" arg2="core" />
</condition>
<condition property="zf.apidoc.label" value="Incubator">
<equals arg1="${zf.tree}" arg2="incubator" />
</condition>

<echo msg="Building API documentation for ${zf.tree}..." />
<mkdir dir="${zf.apidoc.dest.dir}" />
<phpdoc title="${zf.product.name} ${zf.apidoc.label} API Documentation"
destdir="${zf.apidoc.dest.dir}"
sourcepath="${zf.apidoc.src.dir}"
output="${zf.apidoc.output.style}" />
<echo msg="done." />
</target>

<target name="clean.all" depends="clean"
description="Remove staged directory, tarball and zip archives, and svn export.">
<echo msg="Cleaning up archives..."/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${stage.home}" />
</delete>
<echo msg="Cleaning up svn export..."/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${zf.export.dir}" />
</delete>
</target>

<target name="clean" depends="clean.docs"
description="Remove staged directory. Leave tarball and zip archives.">
<echo msg="Cleaning up staged files..."/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${zf.stage.dir}" />
</delete>
</target>

<target name="clean.docs" depends="prepare"
description="Remove only rendered documentation files.">
<echo msg="Cleaning up docs..."/>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${zf.stage.dir}/documentation" />
</delete>
<echo msg="Cleaning up XML entities.ent files..."/>
<delete failonerror="false" verbose="true">
<fileset dir="${zf.src}/documentation/manual">
<include name="**/entities.ent" />
</fileset>
</delete>
<delete failonerror="false" verbose="true">
<fileset dir="${zf.src}/incubator/documentation/manual">
<include name="**/entities.ent" />
</fileset>
</delete>
</target>

</project>



Here's a patch (copy, save as .diff)


Index: build.xml
===================================================================
--- build.xml (revision 3164)
+++ build.xml (working copy)
@@ -40,6 +40,8 @@
Render core manual for specified language only.

Targets:
+ pear
+ Stage product, and create a pear package

dist
Stage product, build docs, create tarball and zip archives.
@@ -81,6 +83,7 @@
<property name="zf.src.default" value="${project.basedir}/.." />
<property name="zf.product.name" value="Zend Framework" />
<property name="zf.productname" value="ZendFramework" />
+ <property name="zf.pearname" value="Zend" />
<property name="zf.version" value="0.6.0" />
<property name="svn.url" value="http://framework.zend.com/svn" />
<property name="zf.svn.url" value="${svn.url}/framework/trunk" />
@@ -101,10 +104,48 @@
<zip destfile="${zf.zipball}" basedir="${zf.stage.dir}" />
</target>

- <target name="build" depends="stage,docs"
- description="Stage product and build docs.">
+ <target name="build" depends="stage,pear,docs" description="Stage product and build docs.">
</target>

+ <target name="pear" depends="stage"
+ description="Create a pear package.">
+ <mkdir dir="${stage.home}/pear" />
+ <echo msg="Creating PEAR package" />
+ <pearpkg name="${zf.pearname}" dir="${zf.stage.dir}" destFile="${stage.home}/pear/package.xml">
+ <fileset dir="${zf.stage.dir}/library/">
+ <!--
+ <exclude name="**/.svn/**" />
+ <exclude name="build-tools/**" />
+ -->
+ </fileset>
+ <option name="notes">See http://framework.zend.com/changelog for full changes</option>
+ <option name="description">${zf.product.name}</option>
+
+ <option name="summary">Zend Framework is an open source effort aimed at producing a high-quality framework for developing modern, robust, secure web applications and web services in PHP 5.</option>
+ <option name="version" value="${zf.version}"/>
+ <option name="state" value="beta"/>
+ <option name="license" value="BSD"/>
+
+ <mapping name="maintainers">
+ <element>
+ <element key="handle" value="olekvi"/>
+ <element key="name" value="Ole Bendik Kvisberg"/>
+ <element key="email" value="olekvi@linpro.no"/>
+ <element key="role" value="lead"/>
+ </element>
+ </mapping>
+
+ <mapping name="deps">
+ <element>
+ <element key="type" value="php"/>
+ <element key="version" value="5.0.1"/>
+ <element key="rel" value="ge"/>
+ </element>
+ </mapping>
+
+ </pearpkg>
+ </target>
+
<target name="stage" depends="prepare,source.export"
description="">
<echo msg="Staging files from ${zf.src} to ${zf.stage.dir}" />




Notes:
  1. The paths are all funny, and your package.xml will get put out into /stage/pear/ - you probably want to have it go elsewhere.
  2. You still need to copy it somewhere else (/stage/ZendFramework-X.Y.Z/library/)
  3. You still need to pear package it.
Post a Comment