1
+ <?xml version =" 1.0" ?>
2
+ <project name =" PHPExcel" default =" release-standard" basedir =" ." >
3
+ <taskdef classname =" phing.tasks.ext.d51PearPkg2Task" name =" d51pearpkg2" />
4
+
5
+ <propertyprompt propertyName =" packageVersion" defaultValue =" 1.0.0"
6
+ promptText=" Enter PHPExcel version number" />
7
+ <propertyprompt propertyName =" releaseDate" defaultValue =" 2010-01-01"
8
+ promptText=" Enter PHPExcel release date" />
9
+
10
+ <adhoc-task name =" phpzip" >
11
+ <![CDATA[
12
+ class PhpZipTask extends Task {
13
+ private $destinationFile;
14
+ private $filesets = array();
15
+
16
+ function setDestfile(PhingFile $f) {
17
+ $this->destinationFile = $f;
18
+ }
19
+
20
+ function createFileSet() {
21
+ $num = array_push($this->filesets, new FileSet());
22
+ return $this->filesets[$num-1];
23
+ }
24
+
25
+ function main() {
26
+ if ($this->destinationFile === null || empty($this->filesets)) {
27
+ throw new BuildException("You must specify a file or fileset(s) for the <phpzip> task.");
28
+ }
29
+
30
+ // compile a list of all files to add to the file, both file attrib and fileset elements
31
+ // can be used.
32
+ $files = array();
33
+ if (!empty($this->filesets)) {
34
+ $filenames = array();
35
+ foreach($this->filesets as $fs) {
36
+ try {
37
+ $ds = $fs->getDirectoryScanner($this->project);
38
+ $filenames = $ds->getIncludedFiles(); // get included filenames
39
+ $dir = $fs->getDir($this->project);
40
+ foreach ($filenames as $fname) {
41
+ $files[] = new PhingFile($dir, $fname);
42
+ }
43
+ } catch (BuildException $be) {
44
+ $this->log($be->getMessage(), Project::MSG_WARN);
45
+ }
46
+ }
47
+ }
48
+
49
+ $objZip = new ZipArchive();
50
+ if ($objZip->open($this->destinationFile, ZIPARCHIVE::OVERWRITE) !== true) {
51
+ throw new Exeption("Could not open " . $strResultingFile . " for writing!");
52
+ }
53
+
54
+ $this->log("Creating ZIP archive of " . count($files) . " files...");
55
+
56
+ foreach($files as $file) {
57
+ $this->log("Processing file " . $this->_cleanFileName($file) . " ...");
58
+ $contents = file_get_contents($file);
59
+ $objZip->addFromString( $this->_cleanFileName($file), $contents );
60
+ }
61
+
62
+ $objZip->close();
63
+
64
+ $this->log("Created ZIP archive " . $this->destinationFile . '.');
65
+ }
66
+
67
+ /**
68
+ * Cleanup a filename
69
+ *
70
+ * @param string $strFile Filename
71
+ * @return string Filename
72
+ */
73
+ protected function _cleanFileName($strFile) {
74
+ $strFile = str_replace('../', '', $strFile);
75
+ $strFile = str_replace('.\\build\\', '', $strFile);
76
+ $strFile = str_replace('WINDOWS', '', $strFile);
77
+
78
+ while (preg_match('/\/\//i', $strFile)) {
79
+ $strFile = str_replace('//', '/', $strFile);
80
+ }
81
+
82
+ return $strFile;
83
+ }
84
+ }
85
+ ]]>
86
+ </adhoc-task >
87
+
88
+ <target name =" prepare" >
89
+ <echo msg =" Creating build directory: ./build" />
90
+ <mkdir dir =" ./build" />
91
+ </target >
92
+
93
+ <target name =" build" depends =" prepare" >
94
+ <echo msg =" Copying source files to build directory..." />
95
+
96
+ <copy todir =" ./build/Classes" overwrite =" true" >
97
+ <fileset dir =" ../Classes" >
98
+ <include name =" **/*" />
99
+ <exclude name =" **/.svn" />
100
+ </fileset >
101
+ </copy >
102
+
103
+ <copy todir =" ./build/Documentation" overwrite =" true" >
104
+ <fileset dir =" ../Documentation" >
105
+ <include name =" *.*" />
106
+ <exclude name =" **/.svn" />
107
+ </fileset >
108
+ </copy >
109
+ <mkdir dir =" ./build/Documentation/API" />
110
+
111
+ <copy todir =" ./build/Documentation/Examples" overwrite =" true" >
112
+ <fileset dir =" ../Documentation/Examples" >
113
+ <include name =" **/*" />
114
+ <exclude name =" assets" />
115
+ <exclude name =" **/.svn" />
116
+ </fileset >
117
+ </copy >
118
+
119
+ <copy todir =" ./build/Tests" overwrite =" true" >
120
+ <fileset dir =" ../Tests" >
121
+ <include name =" **/*" />
122
+ <exclude name =" **/.svn" />
123
+ </fileset >
124
+ </copy >
125
+
126
+ <copy file =" ../changelog.txt" tofile =" ./build/changelog.txt" overwrite =" true" />
127
+ <copy file =" ../license.txt" tofile =" ./build/license.txt" overwrite =" true" />
128
+ <copy file =" ../install.txt" tofile =" ./build/install.txt" overwrite =" true" />
129
+ </target >
130
+
131
+ <target name =" versionNumber" depends =" build" >
132
+ <reflexive >
133
+ <fileset dir =" ./build" >
134
+ <include pattern =" **/*" />
135
+ </fileset >
136
+ <filterchain >
137
+ <replaceregexp >
138
+ <regexp pattern =" ##VERSION##" replace =" ${ packageVersion } " />
139
+ <regexp pattern =" ##DATE##" replace =" ${ releaseDate } " />
140
+ </replaceregexp >
141
+ </filterchain >
142
+ </reflexive >
143
+
144
+ <reflexive >
145
+ <fileset dir =" ./build" >
146
+ <include pattern =" **/changelog.txt" />
147
+ </fileset >
148
+ <filterchain >
149
+ <replaceregexp >
150
+ <regexp pattern =" Fixed in SVN" replace =" ${ releaseDate } (v${ packageVersion } )" />
151
+ </replaceregexp >
152
+ </filterchain >
153
+ </reflexive >
154
+ </target >
155
+
156
+ <target name =" apidocs" depends =" versionNumber" >
157
+ <echo msg =" Generating API documentation..." />
158
+ <phpdoc title =" PHPExcel classes"
159
+ destdir =" ./build/Documentation/API"
160
+ sourcecode =" true"
161
+ output =" HTML:Smarty:PHP"
162
+ defaultcategoryname =" PHPExcel"
163
+ defaultpackagename =" PHPExcel"
164
+ pear =" true" >
165
+ <fileset dir =" ./build/Classes" >
166
+ <include name =" **/*.php" />
167
+ </fileset >
168
+ </phpdoc >
169
+ </target >
170
+
171
+ <target name =" release-standard" depends =" apidocs" >
172
+ <mkdir dir =" ./release" />
173
+
174
+ <echo msg =" Creating release package (v${ packageVersion } )..." />
175
+ <phpzip destfile =" ./release/${ packageVersion } .zip" >
176
+ <fileset dir =" ./build" >
177
+ <include name =" **/*" />
178
+ </fileset >
179
+ </phpzip >
180
+
181
+ <echo msg =" Cleaning build directory: ./build" />
182
+ <delete dir =" ./build" />
183
+ </target >
184
+
185
+ <target name =" release-pear" depends =" versionNumber" >
186
+ <mkdir dir =" ./release" />
187
+
188
+ <echo msg =" Creating PEAR release package (v${ packageVersion } )..." />
189
+
190
+ <d51pearpkg2 dir =" ./build/Classes" baseinstalldir =" PHPExcel" >
191
+ <name >PHPExcel</name >
192
+ <summary >PHP Excel classes</summary >
193
+ <channel >pear.pearplex.net</channel >
194
+ <description >Project providing a set of classes for the PHP programming language, which allow you to write to Excel 2007 files and read from Excel 2007 files.</description >
195
+ <notes >This package ONLY contains the class files, not the documentation and example code. Please refer to http://www.codeplex.com/PHPExcel for those files.</notes >
196
+ <
lead user =
" maartenba" name =
" Maarten Balliauw" email =
" [email protected] " />
197
+ <license uri =" http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt" >LGPL</license >
198
+ <version release =" ${ packageVersion } " api =" ${ packageVersion } " />
199
+ <stability release =" stable" api =" stable" />
200
+ <dependencies >
201
+ <php minimum_version =" 5.2.0" />
202
+ <pear minimum_version =" 1.4.0" />
203
+ <extension name =" zip" minimum_version =" 1.8.0" />
204
+ </dependencies >
205
+ <dirroles key =" PHPExcel/Shared/PDF/fonts" >data</dirroles >
206
+ </d51pearpkg2 >
207
+
208
+ <exec command =" pear package ./build/Classes/package.xml" />
209
+ <move file =" PHPExcel-${ packageVersion } .tgz" tofile =" release/PHPExcel-${ packageVersion } .tgz" overwrite =" true" />
210
+
211
+ <echo msg =" Cleaning build directory: ./build" />
212
+ <delete dir =" ./build" />
213
+ </target >
214
+
215
+ <target name =" release-documentation" >
216
+ <mkdir dir =" ./release" />
217
+
218
+ <echo msg =" Creating documentation release (v${ packageVersion } )..." />
219
+ <copy todir =" ./release" overwrite =" true" >
220
+ <fileset dir =" ../Documentation" >
221
+ <include name =" *.*" />
222
+ <exclude name =" **/.svn" />
223
+ </fileset >
224
+ </copy >
225
+ <copy todir =" ./release/Examples" overwrite =" true" >
226
+ <fileset dir =" ../Documentation/Examples" >
227
+ <include name =" **.*" />
228
+ <exclude name =" **/.svn" />
229
+ </fileset >
230
+ </copy >
231
+
232
+ </target >
233
+ </project >
0 commit comments