|
1 <!--**************************************************************************** |
|
2 * Configuration tool plugin build template |
|
3 * This ant pluging-build-template.xml will contain the common targets |
|
4 * to build a eclipse plugin |
|
5 ****************************************************************************--> |
|
6 |
|
7 <project name="${pluginName}" default="all"> |
|
8 <property file="../common.properties"/> |
|
9 <property file="../${common.buildproperties}"/> |
|
10 <property file="build.properties"/> |
|
11 <property file="plugin.properties"/> |
|
12 <property file="../test.properties" /> |
|
13 |
|
14 <fileset id="plugin-resources" dir="." includes="${bin.includes}"/> |
|
15 |
|
16 |
|
17 <path id="project.class.path"> |
|
18 |
|
19 <!-- add lib jars to classpath --> |
|
20 <fileset dir="${common.plugin-lib}" casesensitive="yes"> |
|
21 <include name="**/*.jar"/> |
|
22 </fileset> |
|
23 <!-- add also the generated Configuration Tool jars to classpath --> |
|
24 <fileset dir="${common.plugin-dist}" casesensitive="yes"> |
|
25 <include name="**/*.jar"/> |
|
26 </fileset> |
|
27 </path> |
|
28 |
|
29 <!-- Gets the svnversion with the svnversion command and stores the output to svnrevision. |
|
30 The target is executed only if the svnrevision has not been set. |
|
31 --> |
|
32 <target name="get-svnversion" unless="common.svnversion"> |
|
33 <echo message="plugin-build-template.xml get-svnversion" level="debug"/> |
|
34 <exec dir="." executable="svnversion" outputproperty="common.svnversion" /> |
|
35 <echo message="svnversion from svn command = ${common.svnversion}" /> |
|
36 </target> |
|
37 <!-- Sets the buildate property if it has not been set by the common property file --> |
|
38 <target name="get-builddate" unless="common.builddate"> |
|
39 <echo message="plugin-build-template.xml get-builddate" level="debug"/> |
|
40 <tstamp prefix="build"/> |
|
41 <property name="common.builddate" value="${build.DSTAMP}"/> |
|
42 </target> |
|
43 |
|
44 <!-- generate a build property file --> |
|
45 <target name="update-properties" depends="get-svnversion"> |
|
46 <echo message="plugin-build-template.xml update-properties" level="debug"/> |
|
47 <tstamp prefix="build"/> |
|
48 <echo file="${common.buildproperties}"> |
|
49 common.svnversion =${svnrevision} |
|
50 </echo> |
|
51 <!-- replace the possible : characters because the do not work in filenames--> |
|
52 <replace file="${common.buildproperties}" token=":"/> |
|
53 <property file="${common.buildproperties}"/> |
|
54 </target> |
|
55 |
|
56 |
|
57 <!-- All target will clean and then commit all the build steps--> |
|
58 <target name="all" depends="clean, build"> |
|
59 <echo message="plugin-build-template.xml all" level="debug"/> |
|
60 </target> |
|
61 |
|
62 <!-- Build target will commit all the build steps and can be used for incremental |
|
63 building, because ant recognized changed files --> |
|
64 <target name="build" depends="init, resource, compile, jar"> |
|
65 <echo message="plugin-build-template.xml build" level="debug"/> |
|
66 </target> |
|
67 |
|
68 <target name="clean"> |
|
69 <echo message="plugin-build-template.xml clean" level="debug"/> |
|
70 <delete dir="${common.plugin-target}" quiet="true" /> |
|
71 </target> |
|
72 |
|
73 <target name="info"> |
|
74 <echo message="plugin-build-template.xml info" level="debug"/> |
|
75 <echoproperties/> |
|
76 </target> |
|
77 |
|
78 <target name="init" depends="get-svnversion,get-builddate"> |
|
79 <echo message="plugin-build-template.xml init" level="debug"/> |
|
80 <mkdir dir="${common.plugin-target}/bin" /> |
|
81 <mkdir dir="${common.plugin-dist}" /> |
|
82 </target> |
|
83 |
|
84 |
|
85 <target name="init_test"> |
|
86 <echo message="plugin-build-template.xml ${pluginName} init_test" level="debug"/> |
|
87 <mkdir dir="${common.unittest.bin.dir}" /> |
|
88 <mkdir dir="${common.unittest.reports.dir}"/> |
|
89 <mkdir dir="${common.unittest.reports.emma.dir}"/> |
|
90 </target> |
|
91 |
|
92 <target name="resource" depends="init"> |
|
93 <echo message="plugin-build-template.xml resource" level="debug"/> |
|
94 <copy todir="${common.plugin-target}/bin/"> |
|
95 <fileset refid="plugin-resources" /> |
|
96 </copy> |
|
97 </target> |
|
98 |
|
99 <target name="compile" depends="resource" |
|
100 description="compile the source"> |
|
101 <echo message="plugin-build-template.xml compile" level="debug"/> |
|
102 <!-- Update manifest file with value from -Dversion=string --> |
|
103 <manifest file="${common.plugin-target}/bin/META-INF/MANIFEST.MF" mode="update"> |
|
104 <attribute name="Bundle-ReleaseVersion" value="${common.releaseversion}"/> |
|
105 <attribute name="Bundle-Date" value="${common.builddate}"/> |
|
106 <attribute name="Bundle-RepositoryVersion" value="${common.svnversion}"/> |
|
107 </manifest> |
|
108 <!-- Compile the java code from ${src} into ${build} --> |
|
109 <javac srcdir="${source..}" destdir="${common.plugin-target}/bin"> |
|
110 <classpath refid="project.class.path"/> |
|
111 </javac> |
|
112 </target> |
|
113 |
|
114 <target name="jar" depends="compile,resource"> |
|
115 <echo message="plugin-build-template.xml jar" level="debug"/> |
|
116 <jar jarfile="${common.plugin-dist}/${pluginName}_${common.plugin-version}-${common.builddate}-${common.svnversion}.jar" |
|
117 basedir="${common.plugin-target}/bin" |
|
118 manifest="${common.plugin-target}/bin/META-INF/MANIFEST.MF"> |
|
119 </jar> |
|
120 </target> |
|
121 |
|
122 <target name="test"> |
|
123 <echo message="plugin-build-template.xml test" level="debug"/> |
|
124 </target> |
|
125 |
|
126 <!-- ==== COVERAGE ==== --> |
|
127 |
|
128 <path id="tests.class.path"> |
|
129 <path refid="project.class.path"/> |
|
130 <fileset dir="../tests/lib" casesensitive="no"> |
|
131 <include name="*.jar"/> |
|
132 </fileset> |
|
133 </path> |
|
134 |
|
135 <path id="inst.class.path"> |
|
136 <fileset dir="${common.plugin-lib}" casesensitive="no"> |
|
137 <include name="**/*.jar"/> |
|
138 </fileset> |
|
139 <fileset dir="${common.plugin-dist}" casesensitive="no"> |
|
140 <include name="**/*.jar"/> |
|
141 <include name="*.jar"/> |
|
142 </fileset> |
|
143 </path> |
|
144 |
|
145 <path id="test.inst.class.path"> |
|
146 <fileset dir="${common.plugin-lib}" casesensitive="no"> |
|
147 <include name="**/*.jar"/> |
|
148 </fileset> |
|
149 <fileset dir="${common.plugin-dist}" casesensitive="no"> |
|
150 <include name="**/*.jar"/> |
|
151 <include name="*.jar"/> |
|
152 </fileset> |
|
153 <fileset dir="../tests/lib" casesensitive="no"> |
|
154 <include name="*.jar"/> |
|
155 </fileset> |
|
156 |
|
157 </path> |
|
158 |
|
159 <!-- Set emma.lib to refer to the list of EMMA jar files --> |
|
160 <path id="emma.lib" > |
|
161 <fileset dir="${test.emma.libdir}"> |
|
162 <include name="*.jar"/> |
|
163 </fileset> |
|
164 </path> |
|
165 |
|
166 <!-- Define which classes will be reported in the coverage reports --> |
|
167 <!-- (by default, we will include all classes and assume --> |
|
168 <!-- that your project's output folder is target/classes --> |
|
169 <path id="emma.coverage.classes" > |
|
170 <pathelement location="build/bin" /> |
|
171 </path> |
|
172 |
|
173 <!-- Load <emma> and <emmajava> custom tasks so that they can be used in ANT --> |
|
174 <taskdef resource="emma_ant.properties" classpathref="emma.lib"/> |
|
175 |
|
176 <target name="_inst_compile" > |
|
177 <echo message="plugin-build-template.xml ${pluginName} _inst_compile" level="debug"/> |
|
178 <antcall target="compile_inst"/> |
|
179 <antcall target="jar"/> |
|
180 </target> |
|
181 |
|
182 <target name="_test_coverage" ><!-- depends="init_test, test_compile, test_coverage_execution, test_coverage_report"--> |
|
183 <echo message="plugin-build-template.xml ${pluginName} _test_coverage" level="debug"/> |
|
184 <antcall target="init_test"/> |
|
185 <antcall target="test_compile"/> |
|
186 <antcall target="test_coverage_execution"/> |
|
187 <antcall target="test_coverage_report"/> |
|
188 </target> |
|
189 |
|
190 <target name="resource_inst" depends="init"> |
|
191 <echo message="plugin-build-template.xml ${pluginName} resource" level="debug"/> |
|
192 <copy todir="${common.plugin-target}/inst/"> |
|
193 <fileset refid="plugin-resources" /> |
|
194 </copy> |
|
195 <copy todir="${common.plugin-target}/bin/"> |
|
196 <fileset dir="${common.plugin-src.dir}" includes="**/*.properties"/> |
|
197 <fileset dir="${common.plugin-src.dir}" includes="**/*.tokens"/> |
|
198 <fileset dir="${common.plugin-src.dir}" includes="**/*.g"/> |
|
199 <fileset dir="${common.plugin-src.dir}" includes="**/*.txtjet"/> |
|
200 </copy> |
|
201 </target> |
|
202 |
|
203 <target name="compile_inst" depends="emma, resource, resource_inst" description="compile the source with instrumentation"> |
|
204 <echo message="plugin-build-template.xml ${pluginName} compile_inst" level="debug"/> |
|
205 <!-- Update manifest file with value from -Dversion=string --> |
|
206 <manifest file="${common.plugin-target}/bin/META-INF/MANIFEST.MF" mode="update"> |
|
207 <attribute name="Bundle-ReleaseVersion" value="${common.releaseversion}"/> |
|
208 <attribute name="Bundle-Date" value="${common.builddate}"/> |
|
209 <attribute name="Bundle-RepositoryVersion" value="${common.svnversion}"/> |
|
210 </manifest> |
|
211 |
|
212 <!-- Compile the java code from ${src} into ${build} --> |
|
213 <javac executable="${common.javac-exe}" |
|
214 debug="on" |
|
215 verbose="${common.javac-verbose}" |
|
216 fork="${common.javac-fork}" |
|
217 compiler="${common.javac-compiler}" |
|
218 srcdir="${common.plugin-src.dir}" |
|
219 destdir="${common.plugin-target}/bin" |
|
220 target="${common.javac-target}" |
|
221 source="${common.javac-source}"> |
|
222 <classpath refid="inst.class.path"/> |
|
223 </javac> |
|
224 |
|
225 <emma enabled="true"> |
|
226 <instr instrpathref="emma.coverage.classes" |
|
227 destdir="${common.instr.dir}" |
|
228 metadatafile="${common.unittest.reports.emma.dir}/${pluginName}-metadata.emma" |
|
229 merge="true"> |
|
230 <filter value="${emma.filter}" /> |
|
231 </instr> |
|
232 </emma> |
|
233 |
|
234 <copy todir="${common.plugin-target}/bin"> |
|
235 <fileset dir="${common.instr.dir}" > |
|
236 <include name="**/*.class" /> |
|
237 </fileset> |
|
238 </copy> |
|
239 |
|
240 </target> |
|
241 |
|
242 <target name="test_coverage_execution" > |
|
243 <echo message="plugin-build-template.xml ${pluginName} test_coverage_execution" level="debug"/> |
|
244 |
|
245 <junit printsummary="yes" haltonfailure="no" fork="true"> |
|
246 <classpath> |
|
247 <pathelement location="${common.unittest.bin.dir}"/> |
|
248 <pathelement location="${common.instr.dir}"/> |
|
249 <path refid="test.inst.class.path"/> |
|
250 <path refid="emma.lib" /> |
|
251 </classpath> |
|
252 |
|
253 <formatter type="xml"/> |
|
254 |
|
255 <batchtest todir="${common.unittest.reports.dir}"> |
|
256 <fileset dir="${common.unittest.bin.dir}"> |
|
257 <include name="**/*Test*.class"/> |
|
258 <exclude name="**/AllTests.class"/> |
|
259 </fileset> |
|
260 </batchtest> |
|
261 |
|
262 <jvmarg value="-Demma.coverage.out.file=${pluginName}/${common.unittest.reports.emma.dir}/${pluginName}-coverage.emma" /> |
|
263 <jvmarg value="-Demma.coverage.out.merge=true" /> |
|
264 </junit> |
|
265 </target> |
|
266 |
|
267 <target name="emma" description="turns on EMMA's instrumentation/reporting" > |
|
268 <echo message="plugin-build-template.xml ${pluginName} emma" level="debug"/> |
|
269 <property name="emma.enabled" value="true" /> |
|
270 |
|
271 <mkdir dir="${common.instr.dir}" /> |
|
272 |
|
273 <property name="emma.filter" value="" /> |
|
274 </target> |
|
275 |
|
276 <target name="test_coverage_report"> |
|
277 <echo message="plugin-build-template.xml ${pluginName} test_coverage_report" level="debug"/> |
|
278 |
|
279 <junitreport todir="${common.unittest.reports.dir}"> |
|
280 <fileset dir="${common.unittest.reports.dir}"> |
|
281 <include name="TEST-*.xml"/> |
|
282 </fileset> |
|
283 <report format="frames" todir="${common.unittest.reports.dir}/html"/> |
|
284 </junitreport> |
|
285 <copy todir="../tests/emma/src"> |
|
286 <fileset dir="src"> |
|
287 <include name="**/*.java"/> |
|
288 </fileset> |
|
289 </copy> |
|
290 |
|
291 <copy todir="../tests/target/test-results/"> |
|
292 <fileset dir="${common.unittest.reports.dir}"> |
|
293 <include name="TEST-*.xml"/> |
|
294 </fileset> |
|
295 </copy> |
|
296 |
|
297 <copy todir="../tests/target/emma"> |
|
298 <fileset dir="${common.unittest.reports.emma.dir}"> |
|
299 <include name="*.emma"/> |
|
300 </fileset> |
|
301 </copy> |
|
302 |
|
303 |
|
304 <!-- if enabled, generate coverage report(s): --> |
|
305 <!--<emma enabled="true"> |
|
306 <report sourcepath="${common.plugin-src.dir}" sort="+block,+name,+method,+class" metrics="method:70,block:80,line:80,class:100"> |
|
307 <fileset dir="${common.unittest.reports.emma.dir}" > |
|
308 <include name="*.emma" /> |
|
309 </fileset> |
|
310 <xml outfile="${common.unittest.reports.emma.dir}/coverage.xml" depth="package"/> |
|
311 <html outfile="${common.unittest.reports.emma.dir}/coverage.html" depth="method" columns="name,class,method,block,line"/> |
|
312 </report> |
|
313 </emma>--> |
|
314 |
|
315 </target> |
|
316 |
|
317 <target name="test_compile" > |
|
318 <echo message="plugin-build-template.xml ${pluginName} test_compile" level="debug"/> |
|
319 <javac executable="${common.javac-exe}" |
|
320 srcdir="${common.unittest.src.dir}" |
|
321 destdir="${common.unittest.bin.dir}" |
|
322 target="${common.javac-target}" |
|
323 source="${common.javac-source}" |
|
324 compiler="${common.javac-compiler}" |
|
325 fork="${common.javac-fork}" |
|
326 memoryInitialSize="256m" |
|
327 memoryMaximumSize="512m"> |
|
328 <classpath refid="test.inst.class.path"/> |
|
329 </javac> |
|
330 </target> |
|
331 |
|
332 <target name="test_execution"> |
|
333 <echo message="plugin-build-template.xml ${pluginName} test_execution" level="debug"/> |
|
334 |
|
335 <junit printsummary="yes" haltonfailure="no" fork="true"> |
|
336 <classpath> |
|
337 <pathelement location="${common.unittest.bin.dir}"/> |
|
338 <path refid="tests.class.path"/> |
|
339 </classpath> |
|
340 |
|
341 <formatter type="xml"/> |
|
342 |
|
343 <batchtest todir="${common.unittest.reports.dir}"> |
|
344 <fileset dir="${common.unittest.bin.dir}"> |
|
345 <include name="**/*Test*.class"/> |
|
346 <exclude name="**/AllTests.class"/> |
|
347 </fileset> |
|
348 </batchtest> |
|
349 |
|
350 </junit> |
|
351 </target> |
|
352 |
|
353 <target name="test_report"> |
|
354 <echo message="plugin-build-template.xml ${pluginName} test_report" level="debug"/> |
|
355 |
|
356 <junitreport todir="${common.unittest.reports.dir}"> |
|
357 <fileset dir="${common.unittest.reports.dir}"> |
|
358 <include name="TEST-*.xml"/> |
|
359 </fileset> |
|
360 <report format="frames" todir="${common.unittest.reports.dir}/html"/> |
|
361 </junitreport> |
|
362 </target> |
|
363 |
|
364 |
|
365 |
|
366 </project> |