forked from phpDocumentor/phpDocumentor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
174 lines (150 loc) · 9.25 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
<project name="phpDocumentor" default="build" basedir=".">
<property file="build.properties"/>
<target name="pre-push"
depends="build:clean,build:phpunit,build:behat,build:phpcs"
description="performs pre-push actions by validating the code"/>
<target name="build"
depends="build:clean,build:composer:install,build:phpunit,build:phpcs,build:phploc,build:phpmd,build:phpcpd,build:pdepend,build:phpdoc"
description="Builds phpDocumentor and generates all artefacts needed for Jenkins"/>
<target name="deploy"
depends="deploy:package,deploy:publish-pear-package,deploy:publish-demo,deploy:update-manual,deploy:publish-phar"
description="Builds a new version, packages and distributes it"/>
<target name="build:clean" description="Deletes and recreates the 'build' folder for Jenkins">
<!-- Clean up -->
<delete dir="${project.basedir}/build"/>
<!-- Create build directories -->
<mkdir dir="${project.basedir}/build/api"/>
<mkdir dir="${project.basedir}/build/code-browser"/>
<mkdir dir="${project.basedir}/build/coverage"/>
<mkdir dir="${project.basedir}/build/logs"/>
<mkdir dir="${project.basedir}/build/pdepend"/>
</target>
<target name="build:composer:install">
<exec executable="wget" passthru="true">
<arg value="-Ocomposer.phar" />
<arg value="http://getcomposer.org/composer.phar"/>
</exec>
<exec executable="php" passthru="true">
<arg value="composer.phar"/>
<arg value="install"/>
<arg value="--prefer-source"/>
<arg value="--dev"/>
</exec>
</target>
<!-- Generate checkstyle.xml -->
<target name="build:phpcs" description="Checks for Coding Standard violations">
<echo message="Executing phpCodeSniffer, output is in 'build/logs/checkstyle.xml'"/>
<exec command="${project.basedir}/bin/phpcs --standard=PSR2 --report=checkstyle --ignore='*/data/templates/*' --report-file=${project.basedir}/build/logs/checkstyle.xml ${project.basedir}/src" passthru="true" checkreturn="false"/>
</target>
<!-- Generate API documentation with phpDocumentor -->
<target name="build:phpdoc" description="Generates API documentation">
<exec executable="${project.basedir}/bin/phpdoc" passthru="true">
<arg line="-d ${project.basedir}/src"/>
<arg line="-t ${project.basedir}/build/api"/>
</exec>
</target>
<!-- Generate phploc.csv -->
<target name="build:phploc" description="Generates LOC statistics">
<exec executable="phploc" passthru="true">
<arg line="--log-csv ${project.basedir}/build/logs/phploc.csv" />
<arg path="${project.basedir}" />
</exec>
</target>
<!-- Generate pmd-cpd.xml -->
<target name="build:phpcpd" description="Search for duplicated code">
<exec command="phpcpd ${project.basedir}/src/phpDocumentor --log-pmd=${project.basedir}/build/logs/pmd-cpd.xml" passthru="true" checkreturn="false"/>
</target>
<!-- Generate pmd.xml -->
<target name="build:phpmd" description="Analyze the source code for suboptimal solutions">
<phpmd file="${project.basedir}/src/phpDocumentor" rulesets="codesize,design,naming,unusedcode">
<formatter type="xml" outfile="${project.basedir}/build/logs/pmd.xml"/>
</phpmd>
</target>
<!-- Generate jdepend.xml and software metrics charts -->
<target name="build:pdepend" description="Generate software metric information and charts">
<exec executable="pdepend" passthru="true">
<arg value="--jdepend-xml=${project.basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${project.basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${project.basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${project.basedir}/src/phpDocumentor"/>
</exec>
</target>
<!-- Generate phpunit results and code coverage -->
<target name="build:phpunit" description="Unit test phpDocumentor">
<exec executable="php" dir="${project.basedir}" checkreturn="true" passthru="true">
<arg line="bin/phpunit" />
</exec>
</target>
<!-- Generate behat results -->
<target name="build:behat" description="Run BDD tests for phpDocumentor">
<exec executable="php" dir="${project.basedir}" checkreturn="true" passthru="true">
<arg line="bin/behat --no-paths -f progress" />
</exec>
</target>
<!-- Generates the manual locally -->
<target name="deploy:generate-manual" description="Generates a local copy of the documentation">
<exec command="make html" dir="${project.basedir}/docs/manual" passthru="true" />
</target>
<!-- uploads the manual to the production server -->
<target name="deploy:update-manual"
depends="deploy:generate-manual"
description="Updates the online manual with a new version">
<exec command="scp -r ${project.basedir}/docs/manual/.build/html/* ${server.username}@${server.docs}:${server.docs.path}"
passthru="true" checkreturn="true"/>
</target>
<!-- Asks for the post-deployment version number -->
<target name="deploy:get-version-number" description="Ask the user for the new version">
<loadfile property="version.number" file="${project.basedir}/VERSION">
<filterchain>
<striplinebreaks />
</filterchain>
</loadfile>
</target>
<!-- Creates a PEAR package from this project -->
<target name="deploy:package"
depends="deploy:get-version-number"
description="Create a PEAR package">
<delete file="${project.basedir}/phpDocumentor-*.tgz"/>
<propertyprompt propertyName="version.stability"
promptText="Enter the stability of the new version (alpha, beta or stable)"
useExistingValue="true"/>
<exec
command="php bin/utils/package.php '${version.number}' '${version.number}' '${version.stability}' make"
passthru="true" dir="${project.basedir}" checkreturn="true"
/>
<exec
command="pear package" passthru="true" dir="${project.basedir}" checkreturn="true"
/>
</target>
<!-- publishes the PEAR package to the production environment -->
<target name="deploy:publish-pear-package"
depends="deploy:get-version-number"
description="Uploads the PEAR package to the distribution server and update pirum">
<exec command="scp ${project.basedir}/phpDocumentor-${version.number}.tgz ${server.username}@${server.pear}:${server.pear.path}" passthru="true" checkreturn="true"/>
<exec command="ssh ${server.username}@${server.pear} 'cd ${server.pear.path}; ../pirum add . phpDocumentor-${version.number}.tgz'" passthru="true" checkreturn="true"/>
<delete file="${project.basedir}/phpDocumentor-${version.number}.tgz" />
</target>
<!-- Builds a new demo and publishes it -->
<target name="deploy:publish-demo"
description="Generate a demo and upload it to the server">
<delete><fileset dir="/tmp/phpdoc-demo/responsive"><include name="*"/></fileset></delete>
<exec command="php bin/phpdoc -t /tmp/phpdoc-demo/responsive --template=responsive-twig" dir="${project.basedir}" passthru="true" checkreturn="true"/>
<exec command="scp -r /tmp/phpdoc-demo/responsive/* ${server.username}@${server.demo}:${server.demo.path}/Responsive" passthru="true" checkreturn="true"/>
<exec command="php bin/phpdoc -t /tmp/phpdoc-demo/clean --template=clean" dir="${project.basedir}" passthru="true" checkreturn="true"/>
<exec command="scp -r /tmp/phpdoc-demo/clean/* ${server.username}@${server.demo}:${server.demo.path}/Clean" passthru="true" checkreturn="true"/>
</target>
<!-- Builds a new demo and publishes it -->
<target name="deploy:publish-phar" description="Generate a phar and upload it to the server">
<exec command="php bin/compile" dir="${project.basedir}" passthru="true" checkreturn="true"/>
<exec command="scp -r ${project.basedir}/phpDocumentor.phar ${server.username}@${server.phar}:${server.phar.path}" passthru="true" checkreturn="true"/>
<exec command="scp -r ${project.basedir}/phpDocumentor.phar ${server.username}@${server.phar}:${server.phar.path}/get/phpDocumentor-${version.number}.phar" passthru="true" checkreturn="true"/>
<exec command="openssl sha1 phpDocumentor.phar" passthru="true" />
<echo msg="Update https://github.com/josegonzalez/homebrew-php/blob/master/Formula/phpdocumentor.rb with the latest version number and the SHA1 that is shown above with the path /get/phpDocumentor-${version.number}.phar" />
<delete><fileset dir="${project.basedir}"><include name="phpDocumentor.phar"/></fileset></delete>
</target>
<!-- Updates the continuous integration server to the latest phpdocumentor -->
<target name="deploy:update-ci" description="Updates the CI server with the latest version of phpDocumentor">
<exec command="ssh ${server.username}@${server.ci} -t 'sudo pear upgrade -c ${server.pear}'"
passthru="true" checkreturn="true"/>
</target>
</project>