-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
184 lines (153 loc) · 6.79 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="ubar" default="package" basedir=".">
<!-- get build properties such as version number -->
<property file="build.properties"/>
<!-- provide access to environment variables -->
<property environment="env" />
<!-- reused folders -->
<property name="dist.dir" value="${basedir}/dist" />
<property name="build.dir" value="${basedir}/build" />
<property name="test.dir" value="${basedir}/test" />
<property name="lib.build.dir" value="${build.dir}/lib/ubar" />
<property name="sample.dir" value="${dist.dir}/sample" />
<property name="docs.output.dir" value="${dist.dir}/docs" />
<property name="logs.dir" value="${basedir}/logs" />
<!-- reused file names -->
<property name="package.name" value="ubar-${framework.version}.zip" />
<property name="config.name" value="ubar_config.properties" />
<property name="actiondefs.name" value="ubar.xml" />
<target name="test" description="Run all phpunit tests">
<echo>Running PHPUnit tests</echo>
<delete dir="${logs.dir}" />
<mkdir dir="${logs.dir}" />
<exec dir="${test.dir}" executable="phpunit.bat" failonerror="true">
<arg line="--log-junit ${logs.dir}/UbarAllTests.xml --verbose UbarAllTests" />
</exec>
<exec dir="${test.dir}" executable="phpunit.bat" failonerror="true">
<arg line="--coverage-html ${logs.dir}/coverage UbarAllTests" />
</exec>
</target>
<target name="build-sample" description="Build sample implementation of framework" depends="build-source">
<!-- re-init sample dist dir -->
<delete dir="${sample.dir}" />
<mkdir dir="${sample.dir}" />
<!-- copy sample content over -->
<copy todir="${sample.dir}" preservelastmodified="true">
<fileset dir="${basedir}/sample/">
<exclude name="config/"/>
</fileset>
</copy>
<!-- install framework into ignored lib folder of sample application -->
<copy todir="${sample.dir}/WEB-INF/lib/ubar" preservelastmodified="true">
<fileset dir="${lib.build.dir}">
<exclude name="install/"/>
<exclude name="ubar_config.properties"/>
<exclude name="ubar.xml"/>
</fileset>
</copy>
<!-- install elements from install directory -->
<copy todir="${sample.dir}/web/" preservelastmodified="true">
<fileset dir="${lib.build.dir}/install">
</fileset>
</copy>
<!-- copy sample config and action config -->
<copy todir="${sample.dir}/WEB-INF/lib/ubar" preservelastmodified="true">
<fileset dir="${basedir}/sample/config">
</fileset>
</copy>
</target>
<target name="test-sample" description="Smoke test for sample working as expected">
<!-- For each action, test expected output including result, page info, etc -->
</target>
<!-- NOTE: This requires that you have installed phpDocumentor using pear
and set an environment variabe PEAR_HOME to the location of your pear
directory -->
<target name="generate-docs" description="Generate documentation">
<echo>=== Generating documentation with phpDocumentor for Ubar version ${framework.version} ===</echo>
<!-- clear out old docs -->
<delete failonerror="true" dir="${docs.output.dir}" />
<mkdir dir="${docs.output.dir}" />
<!-- generate html docs for hosting -->
<exec executable="php">
<arg value="${env.PEAR_HOME}/PhpDocumentor/phpDocumentor/phpdoc.inc" />
<arg value="--target" />
<arg value="${docs.output.dir}" />
<arg value="--output" />
<arg value="HTML:frames:default" />
<arg value="--directory" />
<arg value="${basedir}" />
<arg value="--ignore" />
<arg value="${basedir}/test/core/*,${basedir}/test/data/*,${basedir}/test/sample/*,${basedir}/sample/*,${basedir}/dist/*,${basedir}/build/*,${basedir}/test/UbarAllTests.php" />
<arg value="--title" />
<arg value="Ubar PHP MVC Framework Documentation" />
<arg value="--parseprivate" />
</exec>
<!-- fix bad links -->
<echo>=== Manually fixing broken documentation internal links ===</echo>
<replaceregexp>
<regexp pattern='Located in <a class="field" href="(.+)">(.+)</a>' />
<substitution expression='Located in <a class="field" href="../\1">\2</a>' />
<fileset dir="${docs.output.dir}">
<include name="core/constants/*" />
<include name="core/containers/*" />
<include name="core/exceptions/*" />
<include name="core/test/*" />
<include name="core/utils/*" />
</fileset>
</replaceregexp>
</target>
<target name="build-source" description="Package source files">
<!-- re-init lib build dir -->
<delete dir="${lib.build.dir}" />
<mkdir dir="${lib.build.dir}" />
<!-- copy files over -->
<copy todir="${lib.build.dir}" preservelastmodified="true">
<fileset dir="${basedir}">
<exclude name="dist/"/>
<exclude name="build/"/>
<exclude name="test/"/>
<exclude name="logs/"/>
<exclude name="sample/"/>
<exclude name="build.properties"/>
<exclude name="${config.name}*"/>
<exclude name="${actiondefs.name}*"/>
<exclude name="README"/>
<exclude name="core.html"/>
<exclude name="build.xml"/>
</fileset>
</copy>
<!-- copy test files developers will want to use to test their app -->
<copy file="${test.dir}/UbarBaseActionTestCase.php" tofile="${lib.build.dir}/test/UbarBaseActionTestCase.php" preservelastmodified="true" />
<copy file="${test.dir}/UbarBaseTestCase.php" tofile="${lib.build.dir}/test/UbarBaseTestCase.php" preservelastmodified="true" />
<copy file="${test.dir}/UbarTestSuite.php" tofile="${lib.build.dir}/test/UbarTestSuite.php" preservelastmodified="true" />
<!-- copy .in files to build directory for inclusion in archive -->
<copy file="${config.name}.in" tofile="${lib.build.dir}/${config.name}" preservelastmodified="true" />
<copy file="${actiondefs.name}.in" tofile="${lib.build.dir}/${actiondefs.name}" preservelastmodified="true" />
</target>
<target name="package" description="Package project for distribution" depends="test,generate-docs,build-source,build-sample">
<!-- delete last package -->
<delete failonerror="false" file="${dist.dir}/${package.name}" />
<!-- copy README to root instead of being in lib -->
<copy file="${basedir}/README" tofile="${build.dir}/README" preservelastmodified="true" />
<!-- zip contents of build dir -->
<zip
destfile="${dist.dir}/${package.name}"
basedir="${build.dir}"
/>
<!-- copy sample application to root instead of being in lib -->
<zip
update="true"
destfile="${dist.dir}/${package.name}"
basedir="${dist.dir}"
includes="sample/**"
/>
<!-- merge in docs already in dist dir -->
<zip
update="true"
destfile="${dist.dir}/${package.name}"
basedir="${dist.dir}"
includes="docs/**"
/>
<delete dir="${build.dir}" />
</target>
</project>