summaryrefslogtreecommitdiff
path: root/build.xml
blob: 3959a478177dfda50c5810f048f8cbb747fb34fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<?xml version="1.0" encoding="UTF-8"?>
<!--
  PRADO 3.0 build file - Copyright (C) 2006 PradoSoft

  Requirements
  ============
  xdebug >= 2.0.0beta4
-->
<project name="prado" basedir="." default="help">
  <taskdef name="prado-version-check" classname="PradoVersionTask" classpath="buildscripts/phing/tasks"/>
  <taskdef name="prado-doc" classname="PradoDocTask" classpath="buildscripts/phing/tasks"/>
  <taskdef name="prado-pear" classname="PradoPearTask" classpath="buildscripts/phing/tasks"/>
  <taskdef name="prado-quickstart-index" classname="QuickstartIndexTask" classpath="buildscripts/phing/tasks"/>
  <taskdef name="prado-api-index" classname="ManualIndexTask" classpath="buildscripts/phing/tasks"/>
  <taskdef name="prado-test" classname="PradoTestTask" classpath="buildscripts/phing/tasks"/>

  <!-- generates ${prado.version} and ${prado.revision} -->
  <prado-version-check />

  <!-- these are required external commands -->
  <property name="php" value="php" /> <!-- PHP parser -->
  <property name="hhc" value="hhc" /> <!-- compile phpdoc into CHM -->
  <property name="pdflatex" value="pdflatex" />  <!-- generates PDF from LaTex -->
  <property name="zip" value="zip" />  <!-- zip compression -->

  <property name="pkgname" value="${phing.project.name}-${prado.version}.r${prado.revision}"/>

  <property name="build.base.dir" value="build"/>
  <property name="build.dist.dir" value="${build.base.dir}/dist"/>
  <property name="build.src.dir" value="${build.base.dir}/${pkgname}"/>
  <property name="build.doc.dir" value="${build.base.dir}/docs"/>
  <property name="build.pear.dir" value="${build.base.dir}/pear"/>
  <property name="build.web.dir" value="${build.base.dir}/web"/>
  <property name="build.test.dir" value="${build.base.dir}/test-reports"/>
  <property name="build.coverage.dir" value="${build.base.dir}/code-coverage"/>
  <property name="build.snapshot.dir" value="${build.base.dir}/snapshot"/>

  <!--
      All Source Files in framework
  -->
  <fileset dir="." id="framework">
    <exclude name="**/.svn"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="framework/**/*"/>
  </fileset>

  <!--
      Surrounding files
  -->
  <fileset dir="." id="misc">
    <exclude name="**/.svn"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="COPYRIGHT"/>
    <include name="HISTORY"/>
    <include name="UPGRADE"/>
    <include name="index.html"/>
    <include name="requirements/*"/>
  </fileset>

  <!--
      Documentation
  -->
  <fileset dir="." id="docs">
    <exclude name="**/.svn"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <include name="docs/**/*"/>
  </fileset>

  <!--
      Demos
  -->
  <fileset dir="." id="demos">
    <exclude name="**/.svn"/>
    <exclude name="**/*.bak"/>
    <exclude name="**/*~"/>
    <exclude name="**/runtime/*"/>
    <exclude name="**/assets/*"/>
    <exclude name="demos/blog/protected/Data/Blog.db" />
    <include name="demos/**/*"/>
  </fileset>

  <!--
      Writable files and directories
  -->
  <fileset dir="." id="writables">
    <include name="${build.src.dir}/demos/**/runtime" />
    <include name="${build.src.dir}/demos/**/assets" />
    <include name="${build.src.dir}/demos/blog/protected/Data" />
  </fileset>

  <target name="help">
    <echo>

    Welcome to use PRADO build script!
    ----------------------------------
    You may use the following command format to build a target:

              phing   &lt;target name&gt;

    where &lt;target name&gt; can be one of the following:
    
    For all PRADO developers:
    - test    : run unit tests (results are under /build/test-reports);
    - js      : generate Javascript distribution files;
    
    For PRADO release manager:
    - dist    : create release files;
    - build   : prepare a directory for distribution;
    - clean   : clean up the build directory;
    - rebuild : clean first and then build;
    - docs    : generate documentation;
    - pear    : generate PEAR packages;
    - snapshot: generate nightly snapshot;
    </echo>
  </target>

  <target name="build" depends="js" description="Building standard PRADO package v${prado.version}.${prado.revision}">
    <echo>Building pradolite.php...</echo>
    <delete file="framework/pradolite.php"/>
    <exec command="${php} build.php" dir="buildscripts/phpbuilder" passthru="true"/>
    
    <echo>Copying files to build directory...</echo>
    <copy todir="${build.src.dir}">
      <fileset refid="demos"/>
      <fileset refid="docs"/>
      <fileset refid="framework"/>
      <fileset refid="misc"/>
    </copy>
    
    <echo>Changing file permissions...</echo>
    <chmod mode="0777">
      <fileset refid="writables" />
    </chmod>
    
    <echo>Building quickstart demo search indices...</echo>
    <prado-quickstart-index todir="${build.src.dir}/demos/quickstart/protected/index/quickstart" />
  </target>

  <target name="clean">
    <echo>Cleaning up the mess</echo>
    <delete dir="${build.base.dir}"/>
  </target>

  <target name="rebuild" depends="clean,build" />

  <target name="docs">
    <echo>Building quickstart.pdf...</echo>
    <delete>
      <fileset dir=".">
        <include name="buildscripts/texbuilder/*.aux" />
      </fileset>
    </delete>
    <exec command="${php} build.php" dir="buildscripts/texbuilder" passthru="true"/>
    <exec command="${pdflatex} quickstart.tex -interaction=nonstopmode -max-print-line=120" dir="buildscripts/texbuilder" passthru="true"/>
    <exec command="${pdflatex} quickstart.tex -interaction=nonstopmode -max-print-line=120" dir="buildscripts/texbuilder" passthru="true"/>
    <exec command="${pdflatex} quickstart.tex -interaction=nonstopmode -max-print-line=120" dir="buildscripts/texbuilder" passthru="true"/>
    <move file="buildscripts/texbuilder/quickstart.pdf" todir="${build.doc.dir}"/>

    <echo>Building API manuals...</echo>
    <delete dir="${build.doc.dir}/manual"/>
    <mkdir dir="${build.doc.dir}/manual" />
    <prado-doc phpdoc="${php} buildscripts/PhpDocumentor/phpdoc"
               title="PRADO v${prado.version} API Manual"
               destdir="${build.doc.dir}/manual"
               sourcepath="framework"
               ignorelist="*pradolite.php,*3rdParty/*,*Javascripts/*,*I18N/core/*"
               output="HTML:frames:default,CHM:default:default,HTML:Smarty:PradoSoft" />
    <!-- generate CHM file -->
    <exec command="${hhc} ${build.doc.dir}/manual/CHMdefaultConverter/phpdoc.hhp" />
    
    <echo>Indexing API manuals...</echo>
    <prado-api-index docdir="${build.doc.dir}/manual/HTMLSmartyConverter" todir="${build.doc.dir}/manual/HTMLSmartyConverter" />
    <copy file="buildscripts/index/search.php" todir="${build.doc.dir}/manual/HTMLSmartyConverter" />
  </target>

  <target name="dist" depends="rebuild,docs">
    <echo>Moving doc files to build...</echo>
    <mkdir dir="${build.dist.dir}" />
    <move file="${build.doc.dir}/quickstart.pdf" todir="${build.src.dir}/docs" />
    <move todir="${build.src.dir}/docs/manual">
      <fileset dir="${build.doc.dir}/manual/HTMLframesConverter">
        <include name="**/**" />
      </fileset>
    </move>
    <move file="${build.doc.dir}/manual/CHMdefaultConverter/documentation.chm" todir="${build.src.dir}/docs" />
    
    <!--
    <exec command="tar czvf ${pkgname}.tar.gz ${pkgname}" dir="${build.base.dir}"/>
    <move file="${build.base.dir}/${pkgname}.tar.gz" todir="${build.dist.dir}" />
    -->
    <echo>Generating compressed distribution files...</echo>
    <exec command="zip ${pkgname}.zip -r ${pkgname}" dir="${build.base.dir}" />
    <move file="${build.base.dir}/${pkgname}.zip" todir="${build.dist.dir}" />

	<echo>Generating files for pradosoft.com...</echo>    
    <echo>Compiling class docs...</echo>
    <exec command="${php} build.php" dir="buildscripts/classtree" passthru="true"/>
    <move file="buildscripts/classtree/classes.data" todir="${build.web.dir}/protected/Data" />
    
    <echo>Moving HTML docs to Web folder...</echo>
    <mkdir dir="${build.web.dir}" />
    <move todir="${build.web.dir}/docs/manual">
      <fileset dir="${build.doc.dir}/manual/HTMLSmartyConverter">
        <include name="**/**" />
      </fileset>
    </move>    
  </target>

  <target name="js" description="Compiling Javascript distribution files">
    <delete file="framework/Web/Javascripts/js/*.js" />
    <exec command="${php} build.php" dir="buildscripts/jsbuilder" passthru="true"/>
  </target>

  <target name="test" description="Running unit tests">
    <delete dir="${build.test.dir}"/>
    <mkdir dir="${build.test.dir}"/>
    <prado-test codecoverage="false" haltonfailure="false" haltonerror="false" printsummary="true">
      <batchtest>
        <fileset dir="tests/unit">
	      <include name="**/*Test.php"/>
        </fileset>
      </batchtest>
      <formatter type="xml" todir="${build.test.dir}" outfile="unit-tests.xml"/>
    </prado-test>
    <phpunit2report infile="${build.test.dir}/unit-tests.xml" format="frames" styledir="buildscripts/phing/style" todir="${build.test.dir}"/>
  </target>

  <target name="snapshot" depends="rebuild">  
    <!--
    <exec command="tar czvf ${pkgname}.tar.gz ${pkgname}" dir="${build.base.dir}"/>
    <move file="${build.base.dir}/${pkgname}.tar.gz" todir="${build.dist.dir}" />
    -->
    <echo>Generating compressed distribution files...</echo>
    <exec command="zip ${pkgname}.zip -r ${pkgname}" dir="${build.base.dir}" />
    <move file="${build.base.dir}/${pkgname}.zip" tofile="${build.snapshot.dir}/prado-latest.zip" />
    <copy file="${build.src.dir}/HISTORY" tofile="${build.snapshot.dir}/changelog-latest.txt" />
  </target>
  
<!--
  <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"/>

  <target name="pear" depends="" description="Creating PEAR package">
    <mkdir dir="${build.pear.dir}" />
    <prado-pear pkgdir="${build.pear.dir}"
                channel="pear.php.net"
                version="${prado.version}"
                state="stable"
                category="framework"
                package="prado"
                summary="PRADO is a ...."
                pkgdescription="detailed description..."
                notes="www.pradosoft.com"
                license="BSD"
                />
  </target>
  <target name="test" description="Run unit tests">
    <echo>Preparing directory structure</echo>
    <delete dir="${reports.dir}"/>
    <mkdir dir="${reports.dir}"/>
    <delete dir="${reports.unit.dir}"/>
    <delete dir="${reports.codecoverage.dir}"/>
    <mkdir dir="${reports.unit.dir}"/>

    <if>
      <equals arg1="${codecoverage}" arg2="true"/>
      <then>
	<mkdir dir="${reports.codecoverage.dir}"/>
	<echo>Preparing Code Coverage Database</echo>
	<coverage-setup database="${reports.codecoverage.dir}/coverage.db">
	  <fileset dir="${src.dir}">
	    <include name="**/*.php"/>
	    <exclude name="Web/Javascripts/js/clientscripts.php"/>
	    <exclude name="Data/TCache.php"/>
	    <exclude name="DataAccess/**/*.php"/>
	    <exclude name="I18N/core/Gettext/MO.php"/>
	    <exclude name="I18N/core/Gettext/PO.php"/>
	    <exclude name="I18N/core/util.php"/>
	    <exclude name="I18N/TGlobalization.php"/>
	    <exclude name="I18N/TGlobalizationAutoDetect.php"/>
	    <exclude name="Security/TUserManager.php"/>
	    <exclude name="Security/TMembershipManager.php"/>
	    <exclude name="core.php"/>
	    <exclude name="3rdParty/**/*.php"/>
	    <exclude name="pradolite.php"/>
	    <exclude name="prado.php"/>
	  </fileset>
	</coverage-setup>
      </then>
    </if>

    <echo>Running Unit Tests</echo>
    <phpunit2 codecoverage="${codecoverage}" haltonfailure="false" haltonerror="false" printsummary="true">
      <batchtest>
        <fileset dir="${tests.dir}">
	  <include name="**/*Test.php"/>
        </fileset>
      </batchtest>
      <formatter type="xml" todir="${reports.dir}" outfile="logfile.xml"/>
    </phpunit2>

    <echo>Creating Unit Test Report</echo>
    <phpunit2report infile="${reports.dir}/logfile.xml" format="frames" styledir="${reports.style.dir}" todir="${reports.unit.dir}"/>

    <if>
      <equals arg1="${codecoverage}" arg2="true"/>
      <then>
	<echo>Creating Code Coverage Report</echo>
	<coverage-report outfile="${reports.dir}/coverage.xml" geshipath="${reports.geshi.dir}" geshilanguagespath="${reports.geshi.dir}/geshi">
	  <report todir="${reports.codecoverage.dir}" styledir="${reports.style.dir}"/>
	</coverage-report>
      </then>
    </if>
  </target>

  <target name="lint" description="Check syntax of PHP source files">
    <phplint>
      <fileset refid="src"/>
    </phplint>
  </target>

  <target name="lint-demos" description="Check syntax of demo files and configuration files">
    <echo>Validate application configuration</echo>
    <xmllint schema="${application.xsd}">
      <fileset dir="demos">
        <exclude name="**/.svn"/>
        <include name="**/application.xml"/>
      </fileset>
    </xmllint>
    <echo>Validate page configuration</echo>
    <xmllint schema="${config.xsd}">
      <fileset dir="demos">
        <exclude name="**/.svn"/>
        <include name="**/config.xml"/>
      </fileset>
    </xmllint>
    <phplint>
      <fileset dir="demos">
        <exclude name="**/.svn"/>
        <include name="**/*.php"/>
      </fileset>
    </phplint>
  </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="framework"/>
      <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="framework"/>
      <fileset dir="${build.base.dir}">
	<include name="${prado.lite}"/>
      </fileset>
    </pear-package>
  </target>
  <target name="dist-pear" depends="build-pear-package" description="Create PRADO PEAR package">
    <delete file="${dist.pearfile}"/>
    <mkdir dir="${dist.base.dir}"/>
    <exec command="pear package" dir="${build.pear.dir}" passthru="true"/>
    <move file="${build.pear.dir}/prado3-${version}.tgz" tofile="${dist.pearfile}"/>
  </target>
  <target name="analyze" description="Analyze PHP source files with Zend Code Analyzer">
    <analyze analyzerPath="${zca}" disable="var-ref-notmodified,var-use-before-def,var-arg-unused,if-if-else">
      <fileset refid="src"/>
    </analyze>
  </target>

  <target name="install" description="Install PEAR package locally">
    <exec command="sudo pear install ${dist.pearfile}" dir="." passthru="true"/>
  </target>
  
  <target name="uninstall" description="Uninstall PEAR package locally">
    <exec command="sudo pear uninstall pear.pradosoft.com/prado3" dir="." passthru="true"/>   
  </target>
-->  
</project>