-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.xml
248 lines (224 loc) · 9.4 KB
/
build.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Pfw" default="help">
<property name="build_source" value="."/>
<property name="build_dest" value="."/>
<fileset id="php_sources" dir=".">
<include name="*.php"/>
<include name="classes/*.php"/>
<include name="config/*.php"/>
<include name="languages/*.php"/>
</fileset>
<fileset id="view_templates" dir="views">
<include name="*.php"/>
</fileset>
<patternset id="js_sources">
<include name="*.js"/>
<exclude name="*.min.js"/>
</patternset>
<fileset id="unit_tests" dir="tests/unit">
<include name="*Test.php"/>
</fileset>
<fileset id="attack_tests" dir="tests/attack">
<include name="*Test.php"/>
</fileset>
<target name="help" description="lists available targets">
<exec command="phing -l" outputProperty="help"/>
<echo>${help}</echo>
</target>
<target name="uml" description="generates UML class diagram">
<fail unless="env.PLANT_UML_JAR"
message="The environment variable PLANT_UML_JAR is not defined!"/>
<exec command="umlwriter diagram:render --reflector=reflect --processor=plantuml classes | java -jar ${env.PLANT_UML_JAR} -p -tsvg > classes.svg"
logoutput="true"/>
</target>
<target name="sniff" description="checks adherence to coding standards">
<phpcodesniffer standard="PSR2" haltonerror="true">
<fileset refid="php_sources"/>
<fileset refid="unit_tests"/>
</phpcodesniffer>
</target>
<target name="templint" description="lints all templates">
<apply executable="php" passthru="true" checkreturn="true">
<arg file="../pfw/sdk/pfw.php"/>
<arg value="templint"/>
<fileset refid="view_templates"/>
</apply>
</target>
<target name="mess" description="detects code flaws">
<phpmd rulesets="codesize,unusedcode">
<fileset refid="php_sources"/>
<fileset refid="unit_tests"/>
</phpmd>
</target>
<target name="compat" description="checks PHP requirements">
<available file="phpcompatinfo.json" property="has_phpcompatinfo_json"/>
<if>
<not><isset property="has_phpcompatinfo_json"/></not>
<then>
<copy file="../pfw/phpcompatinfo.json" todir="."/>
</then>
</if>
<exec command="phpcompatinfo analyser:run --alias current" logoutput="true"/>
<if>
<not><isset property="has_phpcompatinfo_json"/></not>
<then>
<delete file="phpcompatinfo.json"/>
</then>
</if>
</target>
<target name="unit_tests" description="runs all unit tests">
<phpunit bootstrap="tests/unit/bootstrap.php" haltonerror="true" haltonfailure="true">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset refid="unit_tests"/>
</batchtest>
</phpunit>
</target>
<target name="attack_tests" description="runs all attack tests">
<fail unless="env.CMSIMPLE_URL"
message="The environment variable CMSIMPLE_URL is not defined!"/>
<phpunit bootstrap="../pfw/classes/required_classes.php" haltonerror="true" haltonfailure="true">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset refid="attack_tests"/>
</batchtest>
</phpunit>
</target>
<target name="coverage" description="generates coverage report">
<exec executable="phpdbg" logoutput="true">
<arg value="-qrr"/>
<arg file="../pfw/vendor/phpunit/phpunit/phpunit"/>
<arg value="--bootstrap"/>
<arg file="./tests/unit/bootstrap.php"/>
<arg value="--coverage-html"/>
<arg file="./tests/coverage/"/>
<arg value="--whitelist"/>
<arg file="./classes/"/>
<arg file="./tests/unit/"/>
</exec>
</target>
<target name="doc" description="generates API documentation">
<exec command="doxygen" passthru="true"/>
</target>
<target name="readme" description="convert README.md to README.htm">
<tempfile property="temp_file" destdir="${build_source}"/>
<copy file="README.md" tofile="${temp_file}">
<filterchain>
<replaceregexp>
<regexp pattern="\(https:\/\/htmlpreview\.github\.io\/\?.*?(help/help(_[a-z]{2})?.htm)\)"
replace="(\1)"/>
</replaceregexp>
</filterchain>
</copy>
<exec executable="pandoc">
<arg file="${temp_file}"/>
<arg value="-f"/>
<arg value="markdown"/>
<arg value="-t"/>
<arg value="html"/>
<arg value="-s"/>
<arg value="-M"/>
<arg value="pagetitle=${phing.project.name}_XH"/>
<arg value="-o"/>
<arg file="${build_dest}/README.htm"/>
</exec>
<delete file="${temp_file}"/>
</target>
<target name="minify" description="minifies JS resources">
<fail unless="env.CLOSURE_COMPILER_JAR"
message="The environment variable CLOSURE_COMPILER_JAR is not defined!"/>
<copy todir="${build_dest}">
<fileset dir="${build_source}">
<patternset refid="js_sources"/>
</fileset>
<mapper type="glob" from="*.js" to="*.min.js"/>
</copy>
<apply executable="java">
<arg value="-jar"/>
<arg file="${env.CLOSURE_COMPILER_JAR}"/>
<srcfile/>
<arg value="--js_output_file"/>
<srcfile/>
<fileset dir="${build_dest}">
<include name="*.min.js"/>
</fileset>
</apply>
</target>
<target name="build">
<fail unless="version" message="version is not defined!"/>
<exec command="git archive -o export.zip HEAD" checkreturn="true"/>
<unzip file="export.zip" todir="export"/>
<delete file="export.zip"/>
<phingcall target="readme">
<property name="build_source" value="export"/>
<property name="build_dest" value="dist"/>
</phingcall>
<phingcall target="minify">
<property name="build_source" value="export"/>
<property name="build_dest" value="dist"/>
</phingcall>
<move todir="dist">
<fileset dir="export">
<exclude name="build.xml"/>
<exclude name="composer.*"/>
<exclude name="docs/**"/>
<exclude name="Doxyfile"/>
<exclude name="pax_global_header"/>
<exclude name="phpcompatinfo.json"/>
<exclude name="README.md"/>
<exclude name="sdk/**"/>
<exclude name="tests/**"/>
</fileset>
</move>
<delete dir="export"/>
<copy file="dist/config/config.php" tofile="dist/config/defaultconfig.php" haltonerror="false"/>
<copy file="dist/languages/en.php" tofile="dist/languages/default.php"/>
<php function="strtolower" returnProperty="prefix">
<param value="${phing.project.name}"/>
</php>
<zip destfile="${phing.project.name}_XH-${version}.zip" basedir="dist"
prefix="${prefix}/"/>
<delete dir="dist"/>
</target>
<target name="build_patch" description="builds a distributable update package">
<fail unless="patchee" message="patchee is not defined!"/>
<fail unless="version" message="version is not defined!"/>
<php function="strtolower" returnProperty="prefix">
<param value="${phing.project.name}"/>
</php>
<unzip file="${phing.project.name}_XH-${version}.zip" todir="current"/>
<unzip file="${patchee}" todir="patchee"/>
<copy todir="dist">
<fileset dir="current">
<different targetdir="patchee" ignoreFileTimes="true"/>
</fileset>
</copy>
<delete>
<fileset dir="dist/${prefix}">
<include name="config/config.php"/>
<include name="languages/??.php"/>
<include name="css/stylesheet.css"/>
</fileset>
</delete>
<zip destfile="${phing.project.name}_XH-${version}-PATCH.zip" basedir="dist" includeemptydirs="false"/>
<delete dir="patchee" quiet="true"/>
<delete dir="current" quiet="true"/>
<delete dir="dist" quiet="true"/>
</target>
<target name="build_sdk" depends="doc">
<fail unless="version" message="version is not defined!"/>
<mkdir dir="dist"/>
<copy todir="dist/doc">
<fileset dir="doc"/>
</copy>
<copy todir="dist">
<fileset dir="sdk"/>
</copy>
<copy file="LICENSE" tofile="dist/LICENSE"/>
<zip destfile="Pfw_XH-SDK-${version}.zip" basedir="dist"
prefix="pfw/sdk/"/>
<delete dir="dist"/>
</target>
<target name="build_all" depends="build, build_sdk"
description="builds the distributable ZIP archives"/>
</project>