-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
222 lines (203 loc) · 9.17 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="PHPDraft" default="setup">
<target name="setup" depends="clean"/>
<property name="min-php-version" value="8.1.0"/>
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${project.basedir}/build/coverage"/>
<delete dir="${project.basedir}/build/phar"/>
<delete dir="${project.basedir}/build/out"/>
<delete dir="${project.basedir}/build/tmp"/>
<delete>
<fileset dir="${project.basedir}/build">
<include name="**/phpdraft*.phar"/>
<include name="**/phpdraft*.phar.asc"/>
</fileset>
</delete>
<mkdir dir="${project.basedir}/build/coverage"/>
<mkdir dir="${project.basedir}/build/phar"/>
<mkdir dir="${project.basedir}/build/out"/>
<mkdir dir="${project.basedir}/build/tmp"/>
<property name="clean.done" value="true"/>
</target>
<target name="phar" depends="-phar-prepare"
description="Create PHAR archive of PHPDraft and all its dependencies">
<phingcall target="-phar-build">
<param name="type" value="release"/>
</phingcall>
</target>
<target name="phar-nightly" depends="-phar-prepare"
description="Create PHAR archive of PHPDraft and all its dependencies (nightly)">
<phingcall target="-phar-build">
<param name="type" value="nightly"/>
</phingcall>
</target>
<target name="-phar-prepare" depends="clean">
<mkdir dir="${project.basedir}/build/phar"/>
<mkdir dir="${project.basedir}/build/out"/>
<copy file="${project.basedir}/LICENSE" tofile="${project.basedir}/build/phar/LICENSE"/>
<exec executable="${project.basedir}/build/phar-manifest.php" output="${project.basedir}/build/phar/manifest.txt"/>
</target>
<target name="-phar-build" depends="-phar-determine-version">
<fail unless="version" message="No version defined!" />
<copy todir="${project.basedir}/build/phar/phpdraft/src">
<fileset dir="${project.basedir}/src/">
<exclude name="**/*Test.php*"/>
<exclude name="**/*TestBase.php*"/>
<include name="**/*.php"/>
<include name="**/*.twig"/>
<include name="**/*.phtml"/>
<include name="**/*.js*"/>
<include name="**/*.css*"/>
</fileset>
<fileset dir="vendor/michelf/php-markdown/Michelf/">
<include name="**/*.php"/>
<exclude name="**/Readme.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Rize">
<fileset dir="vendor/rize/uri-template/src">
<include name="**/*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Lukasoppermann/Httpstatus">
<fileset dir="vendor/lukasoppermann/http-status/src">
<include name="**/*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Garden/Cli">
<fileset dir="vendor/vanilla/garden-cli/src">
<include name="**/*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Twig">
<fileset dir="vendor/twig/twig/src">
<include name="**/*.php"/>
<exclude name="Test/**"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Twig/Extra/Markdown">
<fileset dir="vendor/twig/markdown-extra">
<include name="*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/MatthiasMullie/Minify">
<fileset dir="vendor/matthiasmullie/minify/src">
<include name="**/*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/MatthiasMullie/data">
<fileset dir="vendor/matthiasmullie/minify/data">
<include name="**/*.txt"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/MatthiasMullie/PathConverter">
<fileset dir="vendor/matthiasmullie/path-converter/src">
<include name="**/*.php"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft/src/Psr/Log">
<fileset dir="vendor/psr/log/src">
<include name="**/*.php"/>
<exclude name="**/*Test.php*"/>
</fileset>
</copy>
<copy todir="${project.basedir}/build/phar/phpdraft">
<fileset dir="${project.basedir}">
<include name="**/phpdraft"/>
<exclude name="vendor/**"/>
</fileset>
</copy>
<exec executable="perl">
<arg value="-pi"/>
<arg value="-e"/>
<arg value="s/\'vendor\/autoload.php/__DIR__\ .\ \'\/src\/PHPDraft\/Core\/Autoloader.php/g"/>
<arg value="${project.basedir}/build/phar/phpdraft/phpdraft"/>
</exec>
<exec executable="php" outputProperty="_version">
<arg file="${project.basedir}/build/phar-version.php"/>
<arg value="${version}"/>
<arg value="${type}"/>
</exec>
<echo message="Building version: ${version}, type: ${type}, output: ${_version}"/>
<fail unless="_version" message="Could not construct version parameter!" />
<exec executable="php" outputProperty="_pharReadonly">
<arg value="-r"/>
<arg value="echo ini_get('phar.readonly');"/>
</exec>
<echo message="Phar: ${_pharReadonly}"/>
<fail message="No PHAR creation allowed">
<condition>
<or>
<equals arg1="${_pharReadonly}" arg2="1"/>
<equals arg1="${_pharReadonly}" arg2="true"/>
<equals arg1="${_pharReadonly}" arg2="On"/>
</or>
</condition>
</fail>
<exec executable="${project.basedir}/vendor/bin/phpab" taskname="phpab">
<arg value="--all"/>
<arg value="--static"/>
<arg value="--once"/>
<arg value="--phar"/>
<arg value="--hash"/>
<arg value="SHA-512"/>
<arg value="--output"/>
<arg path="${project.basedir}/build/out/phpdraft-library-${_version}.phar"/>
<arg value="--template"/>
<arg path="${project.basedir}/build/library-phar-autoload.php.in"/>
<arg path="${project.basedir}/build/phar"/>
</exec>
<exec executable="${project.basedir}/vendor/bin/phpab" taskname="phpab">
<arg value="--all"/>
<arg value="--nolower"/>
<arg value="--static"/>
<arg value="--phar"/>
<arg value="--once"/>
<arg value="--var"/>
<arg value="PHPMINVER=${min-php-version}"/>
<arg value="--hash"/>
<arg value="SHA-512"/>
<arg value="--output"/>
<arg path="${project.basedir}/build/out/phpdraft-${_version}.phar"/>
<arg value="--template"/>
<arg path="${project.basedir}/build/binary-phar-autoload.php.in"/>
<arg path="${project.basedir}/build/phar"/>
</exec>
<chmod file="${project.basedir}/build/out/phpdraft-${_version}.phar" mode="0555"/>
</target>
<target name="-dependencies-installed">
<available file="${project.basedir}/composer.lock" property="dependencies-installed"/>
</target>
<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
<exec executable="composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
<arg value="--no-suggest"/>
<arg value="--optimize-autoloader"/>
<arg value="--prefer-stable"/>
</exec>
</target>
<target name="validate-composer-json" unless="validate-composer-json.done" description="Validate composer.json">
<exec executable="composer" checkreturn="true" taskname="composer">
<arg value="validate"/>
<arg value="--no-check-lock"/>
<arg value="--strict"/>
<arg value="${project.basedir}/composer.json"/>
</exec>
<property name="validate-composer-json.done" value="true"/>
</target>
<target name="-phar-determine-version">
<exec executable="php" outputProperty="preVersion">
<arg path="${project.basedir}/phpdraft"/>
<arg value="--version"/>
</exec>
<echo message="${preVersion}"/>
<propertyregex property="version"
subject="${preVersion}"
pattern="([0-9]{1,}\.)+[0-9]{1,}-?(rc|beta)?[0-9]?"
match="$0"/>
<echo message="${version}"/>
</target>
</project>