|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | | -<project name="phpcpd" default="build"> |
3 | | - <target name="build" depends="prepare,lint"/> |
4 | | - |
5 | | - <target name="clean" description="Cleanup build artifacts"> |
6 | | - <delete dir="${basedir}/bin"/> |
7 | | - <delete dir="${basedir}/vendor"/> |
8 | | - <delete file="${basedir}/composer.lock"/> |
9 | | - <delete dir="${basedir}/build/phar"/> |
10 | | - <delete> |
11 | | - <fileset dir="${basedir}/build"> |
12 | | - <include name="**/*.phar" /> |
13 | | - <include name="**/*.phar.asc" /> |
14 | | - </fileset> |
15 | | - </delete> |
16 | | - </target> |
17 | | - |
18 | | - <target name="composer" description="Install dependencies with Composer"> |
19 | | - <tstamp> |
20 | | - <format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/> |
21 | | - </tstamp> |
22 | | - <delete> |
23 | | - <fileset dir="${basedir}"> |
24 | | - <include name="composer.phar" /> |
25 | | - <date datetime="${thirty.days.ago}" when="before"/> |
26 | | - </fileset> |
27 | | - </delete> |
28 | | - |
29 | | - <get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/> |
30 | | - |
31 | | - <exec executable="php"> |
32 | | - <arg value="composer.phar"/> |
33 | | - <arg value="install"/> |
34 | | - </exec> |
35 | | - </target> |
36 | | - |
37 | | - <target name="prepare" depends="clean,composer" description="Prepare for build"> |
38 | | - </target> |
39 | | - |
40 | | - <target name="lint"> |
41 | | - <apply executable="php" failonerror="true"> |
42 | | - <arg value="-l" /> |
43 | | - |
44 | | - <fileset dir="${basedir}/src"> |
45 | | - <include name="**/*.php" /> |
46 | | - <modified /> |
47 | | - </fileset> |
48 | | - |
49 | | - <fileset dir="${basedir}/tests"> |
50 | | - <include name="**/*.php" /> |
51 | | - <modified /> |
52 | | - </fileset> |
53 | | - </apply> |
54 | | - </target> |
55 | | - |
56 | | - <target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer"> |
57 | | - <exec executable="phpcs"> |
58 | | - <arg value="--standard=PSR2" /> |
59 | | - <arg value="--extensions=php" /> |
60 | | - <arg path="${basedir}/src" /> |
61 | | - </exec> |
62 | | - </target> |
63 | | - |
64 | | - <target name="phpunit" depends="prepare,lint" description="Run unit tests with PHPUnit"> |
65 | | - <exec executable="${basedir}/vendor/bin/phpunit" failonerror="true"> |
66 | | - <arg value="--configuration" /> |
67 | | - <arg path="${basedir}/build/phpunit.xml" /> |
68 | | - </exec> |
69 | | - </target> |
70 | | - |
71 | | - <target name="signed-phar" |
72 | | - description="Create signed PHAR archive of PHPCPD and all its dependencies (release)" |
73 | | - depends="phar"> |
74 | | - <exec executable="bash" outputproperty="version"> |
75 | | - <arg value="-c" /> |
76 | | - <arg value="${basedir}/phpcpd --version | awk 'BEGIN { ORS = ""; } {print $2}'" /> |
77 | | - </exec> |
78 | | - |
79 | | - <exec executable="gpg" failonerror="true"> |
80 | | - <arg value="--armor" /> |
81 | | - <arg value="--detach-sign" /> |
82 | | - <arg path="${basedir}/build/phpcpd-${version}.phar" /> |
83 | | - </exec> |
84 | | - </target> |
85 | | - |
86 | | - <target name="phar" |
87 | | - description="Create PHAR archive of phpcpd and all its dependencies" |
88 | | - depends="clean,composer,phar-build"> |
89 | | - <mkdir dir="${basedir}/build/phar"/> |
90 | | - </target> |
91 | | - |
92 | | - <target name="phar-build"> |
93 | | - <exec executable="bash" outputproperty="version"> |
94 | | - <arg value="-c" /> |
95 | | - <arg value="${basedir}/phpcpd --version | awk 'BEGIN { ORS = ""; } {print $2}'" /> |
96 | | - </exec> |
97 | | - |
98 | | - <copy todir="${basedir}/build/phar/src"> |
99 | | - <fileset dir="${basedir}/src"> |
100 | | - <include name="**/*.php" /> |
101 | | - </fileset> |
102 | | - </copy> |
103 | | - |
104 | | - <copy todir="${basedir}/build/phar/finder-facade"> |
105 | | - <fileset dir="${basedir}/vendor/sebastian/finder-facade/src"> |
106 | | - <include name="**/*.php" /> |
107 | | - <exclude name="**/autoload.php" /> |
108 | | - </fileset> |
109 | | - </copy> |
110 | | - |
111 | | - <copy todir="${basedir}/build/phar/version"> |
112 | | - <fileset dir="${basedir}/vendor/sebastian/version/src"> |
113 | | - <include name="**/*.php" /> |
114 | | - <exclude name="**/autoload.php" /> |
115 | | - </fileset> |
116 | | - </copy> |
117 | | - |
118 | | - <copy todir="${basedir}/build/phar/php-timer"> |
119 | | - <fileset dir="${basedir}/vendor/phpunit/php-timer/src"> |
120 | | - <include name="**/*.php" /> |
121 | | - </fileset> |
122 | | - </copy> |
123 | | - |
124 | | - <copy todir="${basedir}/build/phar/symfony"> |
125 | | - <fileset dir="${basedir}/vendor/symfony"> |
126 | | - <include name="**/*.php" /> |
127 | | - <exclude name="**/Tests/**" /> |
128 | | - </fileset> |
129 | | - </copy> |
130 | | - |
131 | | - <copy todir="${basedir}/build/phar/fdomdocument"> |
132 | | - <fileset dir="${basedir}/vendor/theseer/fdomdocument/src"/> |
133 | | - </copy> |
134 | | - |
135 | | - <exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt"/> |
136 | | - |
137 | | - <exec executable="phpab"> |
138 | | - <arg value="--all" /> |
139 | | - <arg value="--phar" /> |
140 | | - <arg value="--output" /> |
141 | | - <arg path="${basedir}/build/phpcpd-${version}.phar" /> |
142 | | - <arg value="--template" /> |
143 | | - <arg path="${basedir}/build/phar-autoload.php.in" /> |
144 | | - <arg value="--indent" /> |
145 | | - <arg value=" " /> |
146 | | - <arg path="${basedir}/build/phar" /> |
147 | | - </exec> |
148 | | - |
149 | | - <chmod file="${basedir}/build/phpcpd-${version}.phar" perm="ugo+rx"/> |
150 | | - </target> |
| 2 | +<project name="phpcpd" default="setup"> |
| 3 | + <target name="setup" depends="clean,install-dependencies"/> |
| 4 | + |
| 5 | + <target name="clean" description="Cleanup build artifacts"> |
| 6 | + <delete dir="${basedir}/vendor"/> |
| 7 | + <delete file="${basedir}/composer.lock"/> |
| 8 | + </target> |
| 9 | + |
| 10 | + <target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed" description="Install dependencies with Composer"> |
| 11 | + <exec executable="composer" taskname="composer"> |
| 12 | + <arg value="update"/> |
| 13 | + <arg value="--no-interaction"/> |
| 14 | + <arg value="--no-progress"/> |
| 15 | + <arg value="--no-ansi"/> |
| 16 | + <arg value="--no-suggest"/> |
| 17 | + <arg value="--optimize-autoloader"/> |
| 18 | + <arg value="--prefer-stable"/> |
| 19 | + </exec> |
| 20 | + </target> |
| 21 | + |
| 22 | + <target name="install-tools" unless="tools-installed" depends="-tools-installed" description="Install tools using phive"> |
| 23 | + <exec executable="phive" taskname="phive"> |
| 24 | + <arg value="install"/> |
| 25 | + </exec> |
| 26 | + </target> |
| 27 | + |
| 28 | + <target name="test" depends="install-dependencies,install-tools" description="Run tests with PHPUnit"> |
| 29 | + <exec executable="${basedir}/tools/phpunit" failonerror="true"/> |
| 30 | + </target> |
| 31 | + |
| 32 | + <target name="signed-phar" description="Create signed PHAR archive of PHPCPD and all its dependencies (release)" depends="phar"> |
| 33 | + <exec executable="bash" outputproperty="version"> |
| 34 | + <arg value="-c" /> |
| 35 | + <arg value="${basedir}/phpcpd --version | awk 'BEGIN { ORS = ""; } {print $2}'" /> |
| 36 | + </exec> |
| 37 | + |
| 38 | + <exec executable="gpg" failonerror="true"> |
| 39 | + <arg value="--armor" /> |
| 40 | + <arg value="--detach-sign" /> |
| 41 | + <arg path="${basedir}/build/phpcpd-${version}.phar" /> |
| 42 | + </exec> |
| 43 | + </target> |
| 44 | + |
| 45 | + <target name="phar" description="Create PHAR archive of phpcpd and all its dependencies" depends="setup,phar-build"> |
| 46 | + </target> |
| 47 | + |
| 48 | + <target name="phar-build"> |
| 49 | + <exec executable="bash" outputproperty="version"> |
| 50 | + <arg value="-c" /> |
| 51 | + <arg value="${basedir}/phpcpd --version | awk 'BEGIN { ORS = ""; } {print $2}'" /> |
| 52 | + </exec> |
| 53 | + |
| 54 | + <copy todir="${basedir}/build/phar/src"> |
| 55 | + <fileset dir="${basedir}/src"> |
| 56 | + <include name="**/*.php" /> |
| 57 | + </fileset> |
| 58 | + </copy> |
| 59 | + |
| 60 | + <copy todir="${basedir}/build/phar/finder-facade"> |
| 61 | + <fileset dir="${basedir}/vendor/sebastian/finder-facade/src"> |
| 62 | + <include name="**/*.php" /> |
| 63 | + <exclude name="**/autoload.php" /> |
| 64 | + </fileset> |
| 65 | + </copy> |
| 66 | + |
| 67 | + <copy todir="${basedir}/build/phar/version"> |
| 68 | + <fileset dir="${basedir}/vendor/sebastian/version/src"> |
| 69 | + <include name="**/*.php" /> |
| 70 | + <exclude name="**/autoload.php" /> |
| 71 | + </fileset> |
| 72 | + </copy> |
| 73 | + |
| 74 | + <copy todir="${basedir}/build/phar/php-timer"> |
| 75 | + <fileset dir="${basedir}/vendor/phpunit/php-timer/src"> |
| 76 | + <include name="**/*.php" /> |
| 77 | + </fileset> |
| 78 | + </copy> |
| 79 | + |
| 80 | + <copy todir="${basedir}/build/phar/symfony"> |
| 81 | + <fileset dir="${basedir}/vendor/symfony"> |
| 82 | + <include name="**/*.php" /> |
| 83 | + <exclude name="**/Tests/**" /> |
| 84 | + </fileset> |
| 85 | + </copy> |
| 86 | + |
| 87 | + <copy todir="${basedir}/build/phar/fdomdocument"> |
| 88 | + <fileset dir="${basedir}/vendor/theseer/fdomdocument/src"/> |
| 89 | + </copy> |
| 90 | + |
| 91 | + <exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt"/> |
| 92 | + |
| 93 | + <exec executable="${basedir}/tools/phpab"> |
| 94 | + <arg value="--all" /> |
| 95 | + <arg value="--phar" /> |
| 96 | + <arg value="--output" /> |
| 97 | + <arg path="${basedir}/build/phpcpd-${version}.phar" /> |
| 98 | + <arg value="--template" /> |
| 99 | + <arg path="${basedir}/build/phar-autoload.php.in" /> |
| 100 | + <arg value="--indent" /> |
| 101 | + <arg value=" " /> |
| 102 | + <arg path="${basedir}/build/phar" /> |
| 103 | + </exec> |
| 104 | + |
| 105 | + <chmod file="${basedir}/build/phpcpd-${version}.phar" perm="ugo+rx"/> |
| 106 | + |
| 107 | + <delete dir="${basedir}/build/phar"/> |
| 108 | + </target> |
| 109 | + |
| 110 | + <target name="-dependencies-installed"> |
| 111 | + <available file="${basedir}/vendor" property="dependencies-installed" type="dir"/> |
| 112 | + </target> |
| 113 | + |
| 114 | + <target name="-tools-installed"> |
| 115 | + <available file="${basedir}/tools" property="tools-installed" type="dir"/> |
| 116 | + </target> |
151 | 117 | </project> |
0 commit comments