forked from PhileCMS/Phile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
210 lines (175 loc) · 6.16 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
<?xml version="1.0" encoding="utf-8"?>
<project name="PhileCMS" default="menu">
<property name="dirs.dist" value="dist"/>
<property name="dirs.build" value="${dirs.dist}/build-temp"/>
<property name="dirs.git" value="${dirs.build}/Phile"/>
<property name="git.url" value="https://github.com/PhileCMS/Phile.git"/>
<!-- ## menu ## -->
<target name="menu">
<echo msg="1) build distribution zip"/>
<echo msg="2) build phpdoc"/>
<echo msg="3) run test suite"/>
<echo msg="4) Install additional 1st party plugins"/>
<echo msg="x) exit"/>
<input message="Choose" propertyName="choice" validArgs="1,2,3,4,x"/>
<if>
<equals arg1="${choice}" arg2="1"/>
<then>
<phingcall target="dist"/>
</then>
<elseif>
<equals arg1="${choice}" arg2="2"/>
<then>
<phingcall target="phpdoc"/>
</then>
</elseif>
<elseif>
<equals arg1="${choice}" arg2="3"/>
<then>
<phingcall target="tests"/>
</then>
</elseif>
<elseif>
<equals arg1="${choice}" arg2="4"/>
<then>
<phingcall target="phile-plugins"/>
</then>
</elseif>
<elseif>
<equals arg1="${choice}" arg2="x"/>
<then>
<php expression="exit();"/>
</then>
</elseif>
</if>
</target>
<!-- ## dist ## -->
<fileset id="release-fileset" dir="${dirs.git}">
<!-- ## Files for package ## -->
<include name=".htaccess"/>
<include name="Changelog.md"/>
<include name="composer.json"/>
<include name="composer.lock"/>
<include name="index.php"/>
<include name="LICENSE"/>
<include name="README.md"/>
<!-- ## Folders for package ## -->
<include name="config/**"/>
<include name="content/**"/>
<include name="lib/**"/>
<include name="plugins/**"/>
<include name="themes/**"/>
<!-- ## Vendor excludes to thin down release package ## -->
<exclude name="lib/vendor/**/bin/**"/>
<exclude name="lib/vendor/**/docs/**"/>
<exclude name="lib/vendor/**/test/**"/>
<exclude name="lib/vendor/**/tests/**"/>
<exclude name="lib/vendor/**/Tests/**"/>
<exclude name="lib/vendor/twig/twig/doc/**"/>
<exclude name="lib/vendor/twig/twig/ext/**"/>
</fileset>
<target name="clean-build-dir">
<echo msg="Cleanup build dir"/>
<delete dir="${dirs.build}" includeemptydirs="true"/>
</target>
<target name="clean" depends="clean-build-dir">
<delete dir="${dirs.dist}" includeemptydirs="true"/>
</target>
<target name="create-dirs" depends="clean">
<echo msg="Creating build + dist directories."/>
<mkdir dir="${dirs.build}"/>
<mkdir dir="${dirs.dist}"/>
</target>
<target name="dist">
<input propertyName="git.branch" defaultValue="master"
message="Remote git branch to use?"></input>
<input propertyName="git.tag" defaultValue="head"
message="Tag to use?"></input>
<phingcall target="create-dirs"/>
<echo msg="Checkout git branch ${git.branch}"/>
<exec command="git clone -b ${git.branch} ${git.url}" dir="${dirs.build}"/>
<if>
<not>
<equals arg1="${git.tag}" arg2="head"/>
</not>
<then>
<echo msg="Switch to git tag ${git.tag}"/>
<exec command="git checkout tags/${git.tag}" dir="${dirs.git}"/>
</then>
</if>
<echo msg="Install composer packages"/>
<exec command="composer install --optimize-autoloader --no-dev"
dir="${dirs.git}"/>
<echo msg="Creating Zip"/>
<php expression="str_replace('/', '-', '${git.branch}');"
returnProperty="git.branch.clean"/>
<zip destfile="${dirs.dist}/phile-${git.branch.clean}-${git.tag}.zip"
basedir="${dirs.git}">
<fileset refid="release-fileset"/>
</zip>
<phingcall target="clean-build-dir"/>
</target>
<!-- ## phpdoc ## -->
<target name="phpdoc">
<echo msg="Create phpdoc in docs/"/>
<delete dir="docs" includeemptydirs="true"/>
<mkdir dir="docs"/>
<phpdoc2 destdir="docs" template="clean">
<fileset dir="${project.basedir}">
<include name="lib/Phile/**/*.php"/>
<include name="plugins/phile/**/*.php"/>
<exclude name="plugins/phile/phpFastCache/lib/phpfastcache/**"/>
</fileset>
</phpdoc2>
</target>
<!-- ## tests ## -->
<target name="tests">
<property name="tests.all" value="lib/vendor/bin/phpunit"/>
<echo
msg="Command run: '${tests.all}' (using phpunit.xml configuration file)"/>
<echo msg="Running PHPUnit test cases…"/>
<exec command="${tests.all}" logoutput="true"/>
<echo msg="Checking PSR-2…"/>
<property name="tests.formatting"
value="lib/vendor/bin/phpcs --standard=PSR2 -p --extensions=php --ignore=lib/vendor/ lib/ plugins/phile/ ."/>
<exec command="${tests.formatting}" logoutput="true"/>
</target>
<!-- ## Install plugins ## -->
<target name="phile-plugins">
<echo msg="Optional first party plug-ins:"/>
<echo msg="1) install"/>
<echo msg="2) uninstall"/>
<echo msg="x) exit"/>
<input message="Choose" propertyName="choice" validArgs="1,2,x"/>
<if>
<equals arg1="${choice}" arg2="1"/>
<then>
<phingcall target="phile-plugins-install"/>
</then>
<elseif>
<equals arg1="${choice}" arg2="2"/>
<then>
<phingcall target="phile-plugins-uninstall"/>
</then>
</elseif>
<elseif>
<equals arg1="${choice}" arg2="x"/>
<then>
<php expression="exit();"/>
</then>
</elseif>
</if>
</target>
<property name="phile.plugins" value="
phile/rss-feed
phile/content-variables
"/>
<target name="phile-plugins-install">
<echo msg="Installing plug-ins…"/>
<exec command="composer require ${phile.plugins}" checkreturn="true" logoutput="true" />
</target>
<target name="phile-plugins-uninstall">
<echo msg="Uninstalling plug-ins…"/>
<exec command="composer remove ${phile.plugins}" checkreturn="true" logoutput="true" />
</target>
</project>