1 <?xml version="1.0"?> |
|
2 <!-- |
|
3 ============================================================================ |
|
4 Name : macros.xml |
|
5 Part of : Helium AntLib |
|
6 |
|
7 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
8 All rights reserved. |
|
9 This component and the accompanying materials are made available |
|
10 under the terms of the License "Eclipse Public License v1.0" |
|
11 which accompanies this distribution, and is available |
|
12 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
13 |
|
14 Initial Contributors: |
|
15 Nokia Corporation - initial contribution. |
|
16 |
|
17 Contributors: |
|
18 |
|
19 Description: |
|
20 |
|
21 ============================================================================ |
|
22 --> |
|
23 <project name="build-macros" xmlns:au="org.apache.ant.antunit"> |
|
24 <description>Helium Antlib build macro.</description> |
|
25 |
|
26 <dirname property="helium.antlib.root.dir" file="${ant.file.build-macros}" /> |
|
27 <property name="build.temp.dir" location="${helium.antlib.root.dir}/../build" /> |
|
28 <property name="bin.dir" location="${basedir}/../bin" /> |
|
29 |
|
30 <path id="helium.antlib.classpath"> |
|
31 <fileset dir="${helium.antlib.root.dir}/lib" includes="*.jar" /> |
|
32 <fileset dir="${helium.antlib.root.dir}/antlibs" includes="*.jar" /> |
|
33 </path> |
|
34 |
|
35 <taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="helium.antlib.classpath"/> |
|
36 <taskdef resource="org/apache/ant/antunit/antlib.xml" uri="org.apache.ant.antunit" classpathref="helium.antlib.classpath"/> |
|
37 |
|
38 |
|
39 <presetdef name="subantPreset"> |
|
40 <subant failonerror="true"> |
|
41 <resources refid="subant.build.files"/> |
|
42 </subant> |
|
43 </presetdef> |
|
44 |
|
45 |
|
46 <macrodef name="compileModule"> |
|
47 <attribute name="name" /> |
|
48 <attribute name="dir" default="${helium.antlib.root.dir}" /> |
|
49 <sequential> |
|
50 <mkdir dir="${build.temp.dir}/@{name}/classes" /> |
|
51 <javac srcdir="${basedir}/src" destdir="${build.temp.dir}/@{name}/classes" |
|
52 debug="true" source="1.6" target="1.6"> |
|
53 <classpath refid="helium.antlib.classpath" /> |
|
54 <classpath refid="helium.@{name}.classpath" /> |
|
55 <include name="**/*.java" /> |
|
56 <compilerarg value="-Xlint:unchecked" /> |
|
57 <compilerarg value="-Xlint:deprecation" /> |
|
58 </javac> |
|
59 </sequential> |
|
60 </macrodef> |
|
61 |
|
62 |
|
63 <macrodef name="jarModule"> |
|
64 <attribute name="name" /> |
|
65 <attribute name="dir" default="${helium.antlib.root.dir}" /> |
|
66 <attribute name="bindir" default="${bin.dir}" /> |
|
67 <sequential> |
|
68 <echo>Packaging module @{name}</echo> |
|
69 <mkdir dir="@{bindir}" /> |
|
70 <jar destfile="@{bindir}/helium-@{name}.jar"> |
|
71 <fileset dir="${build.temp.dir}/@{name}/classes" /> |
|
72 <fileset dir="${basedir}/src" includes="**/*.xml" /> |
|
73 <fileset dir="${basedir}/src" includes="**/*.*ftl" /> |
|
74 <fileset dir="${basedir}/src" includes="**/*.vm" /> |
|
75 |
|
76 <manifest> |
|
77 <section name="common"> |
|
78 <attribute name="Implementation-Title" value="@{name}" /> |
|
79 <attribute name="Implementation-Vendor" value="Nokia" /> |
|
80 </section> |
|
81 </manifest> |
|
82 </jar> |
|
83 </sequential> |
|
84 </macrodef> |
|
85 |
|
86 |
|
87 <macrodef name="testModule"> |
|
88 <attribute name="name" /> |
|
89 <attribute name="dir" default="${helium.antlib.root.dir}" /> |
|
90 <attribute name="bindir" default="${bin.dir}" /> |
|
91 <sequential> |
|
92 <mkdir dir="${build.temp.dir}" /> |
|
93 <if> |
|
94 <available type="dir" file="${basedir}/tests"/> |
|
95 <then> |
|
96 <trycatch> |
|
97 <try> |
|
98 <!-- Temporarly replacing the jar file |
|
99 with an instrumented one to do the |
|
100 actual coverage measurment |
|
101 --> |
|
102 <mkdir dir="${build.temp.dir}/@{name}/backup" /> |
|
103 <delete> |
|
104 <fileset dir="${build.temp.dir}" includes="@{name}/**/*_antunit.emma" /> |
|
105 </delete> |
|
106 <copy file="@{bindir}/helium-@{name}.jar" todir="${build.temp.dir}/@{name}/backup/" /> |
|
107 <emma enabled="true"> |
|
108 <instr destdir="@{bindir}/" metadatafile="${build.temp.dir}/@{name}/metadata_antunit.emma" merge="true" mode="overwrite"> |
|
109 <instrpath> |
|
110 <fileset dir="@{bindir}" includes="helium-@{name}.jar" /> |
|
111 </instrpath> |
|
112 </instr> |
|
113 </emma> |
|
114 <exec osfamily="windows" executable="cmd" dir="${basedir}/tests"> |
|
115 <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}" /> |
|
116 <arg line="/c build.bat unittest" /> |
|
117 </exec> |
|
118 <exec osfamily="unix" executable="./bld.sh" dir="${basedir}/tests"> |
|
119 <env key="ANT_LIB_HOME" path="${helium.antlib.root.dir}" /> |
|
120 <arg line="unittest" /> |
|
121 </exec> |
|
122 <move todir="${build.temp.dir}/@{name}"> |
|
123 <fileset dir="${basedir}/tests" includes="**/coverage.ec" /> |
|
124 <chainedmapper> |
|
125 <filtermapper> |
|
126 <replacestring from="/" to="_" /> |
|
127 </filtermapper> |
|
128 <regexpmapper from="^(.*)\.ec$$" to="\1_antunit.emma" /> |
|
129 </chainedmapper> |
|
130 </move> |
|
131 <emma enabled="true"> |
|
132 <report> |
|
133 <infileset dir="${build.temp.dir}/@{name}/" includes="*_antunit.emma" /> |
|
134 <txt outfile="${build.temp.dir}/@{name}/coverage_antunit.txt" /> |
|
135 <html outfile="${build.temp.dir}/@{name}/coverage_antunit.html" /> |
|
136 <xml outfile="${build.temp.dir}/@{name}/coverage_antunit.xml" /> |
|
137 </report> |
|
138 </emma> |
|
139 <if> |
|
140 <available file="${build.temp.dir}/@{name}/coverage_antunit.txt" /> |
|
141 <then> |
|
142 <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage_antunit.txt" /> |
|
143 <echo message="${message}" /> |
|
144 </then> |
|
145 </if> |
|
146 </try> |
|
147 <finally> |
|
148 <copy file="${build.temp.dir}/@{name}/backup/helium-@{name}.jar" todir="@{bindir}" overwrite="true" /> |
|
149 </finally> |
|
150 </trycatch> |
|
151 </then> |
|
152 </if> |
|
153 </sequential> |
|
154 </macrodef> |
|
155 |
|
156 |
|
157 <path id="emma.classpath"> |
|
158 <fileset dir="${helium.antlib.root.dir}\antlibs"> |
|
159 <include name="**/*.jar" /> |
|
160 </fileset> |
|
161 </path> |
|
162 <taskdef classpathref="emma.classpath" resource="emma_ant.properties" /> |
|
163 |
|
164 |
|
165 <macrodef name="junitModule"> |
|
166 <attribute name="name" /> |
|
167 <attribute name="dir" default="${helium.antlib.root.dir}" /> |
|
168 <attribute name="bindir" default="${bin.dir}" /> |
|
169 <sequential> |
|
170 <mkdir dir="${build.temp.dir}" /> |
|
171 <if> |
|
172 <available type="dir" file="${basedir}/tests/src"/> |
|
173 <then> |
|
174 <echo>JUnit test module @{name}</echo> |
|
175 <delete dir="${build.temp.dir}/@{name}/junit_classes"/> |
|
176 <delete> |
|
177 <fileset dir="${build.temp.dir}" includes="@{name}/**/*_junit.emma" /> |
|
178 </delete> |
|
179 <mkdir dir="${build.temp.dir}/@{name}/junit_classes" /> |
|
180 <javac srcdir="${basedir}/tests/src" destdir="${build.temp.dir}/@{name}/junit_classes" debug="true" source="1.5" target="1.5"> |
|
181 <classpath refid="helium.antlib.classpath" /> |
|
182 <classpath refid="helium.@{name}.classpath" /> |
|
183 <classpath> |
|
184 <fileset dir="@{bindir}" includes="*-@{name}.jar" /> |
|
185 </classpath> |
|
186 <include name="**/*.java" /> |
|
187 </javac> |
|
188 |
|
189 <copy file="@{bindir}/helium-@{name}.jar" todir="${build.temp.dir}/@{name}/" overwrite="true"/> |
|
190 <emma enabled="true"> |
|
191 <instr destdir="${build.temp.dir}/@{name}/" metadatafile="${build.temp.dir}/@{name}/metadata_junit.emma" merge="true" mode="overwrite"> |
|
192 <instrpath> |
|
193 <fileset dir="${build.temp.dir}/@{name}/" includes="helium-@{name}.jar" /> |
|
194 </instrpath> |
|
195 </instr> |
|
196 </emma> |
|
197 |
|
198 <delete file="${build.temp.dir}/@{name}/coverage.emma" failonerror="false" /> |
|
199 <junit fork="yes" printsummary="yes" haltonfailure="yes" showoutput="yes"> |
|
200 <formatter type="brief" usefile="false"/> |
|
201 <jvmarg value="-Demma.coverage.out.file=${build.temp.dir}/@{name}/coverage_junit.emma" /> |
|
202 <jvmarg value="-Demma.coverage.out.merge=true" /> |
|
203 <jvmarg value="-Dtestdir=${basedir}" /> |
|
204 <classpath> |
|
205 <pathelement path="${build.temp.dir}/@{name}/helium-@{name}.jar"/> |
|
206 <pathelement path="${helium.antlib.root.dir}/antlibs/*.jar"/> |
|
207 <pathelement path="${build.temp.dir}/@{name}/junit_classes" /> |
|
208 </classpath> |
|
209 <classpath refid="helium.antlib.classpath" /> |
|
210 <classpath refid="helium.@{name}.classpath" /> |
|
211 <batchtest fork="yes" todir="${build.temp.dir}/@{name}/junit_test"> |
|
212 <fileset dir="${basedir}/tests/src"> |
|
213 <include name="**/*Test*.java"/> |
|
214 </fileset> |
|
215 </batchtest> |
|
216 </junit> |
|
217 <delete file="${build.temp.dir}/@{name}/helium-@{name}.jar" failonerror="false" /> |
|
218 |
|
219 <emma enabled="true" > |
|
220 <report> |
|
221 <infileset dir="${build.temp.dir}/@{name}" includes="*_junit.emma" /> |
|
222 <txt outfile="${build.temp.dir}/@{name}/coverage.txt" /> |
|
223 <html outfile="${build.temp.dir}/@{name}/coverage.html" /> |
|
224 <xml outfile="${build.temp.dir}/@{name}/coverage.xml" /> |
|
225 </report> |
|
226 </emma> |
|
227 <if> |
|
228 <available file="${build.temp.dir}/@{name}/coverage.txt" /> |
|
229 <then> |
|
230 <loadfile property="message" srcFile="${build.temp.dir}/@{name}/coverage.txt"/> |
|
231 <echo message="${message}"/> |
|
232 </then> |
|
233 </if> |
|
234 </then> |
|
235 </if> |
|
236 </sequential> |
|
237 </macrodef> |
|
238 |
|
239 |
|
240 <target name="compile"> |
|
241 <echo>Compiling ${ant.project.name}</echo> |
|
242 <compileModule name="${name}"/> |
|
243 </target> |
|
244 |
|
245 |
|
246 <target name="jar"> |
|
247 <echo>Creating jar for ${ant.project.name}</echo> |
|
248 <jarModule name="${name}"/> |
|
249 </target> |
|
250 |
|
251 |
|
252 <target name="build" depends="compile,jar"> |
|
253 <echo>${ant.project.name} is built.</echo> |
|
254 </target> |
|
255 |
|
256 |
|
257 <target name="clean"> |
|
258 <echo>Cleaning ${ant.project.name}</echo> |
|
259 <delete dir="${build.temp.dir}/${name}/classes"/> |
|
260 <delete file="${bin.dir}/helium-${name}.jar"/> |
|
261 </target> |
|
262 |
|
263 |
|
264 <target name="junit"> |
|
265 <junitModule name="${name}"/> |
|
266 </target> |
|
267 |
|
268 |
|
269 <target name="unittest"> |
|
270 <testModule name="${name}"/> |
|
271 </target> |
|
272 |
|
273 |
|
274 <target name="test" depends="junit,unittest"> |
|
275 <echo>${ant.project.name} tested.</echo> |
|
276 </target> |
|
277 </project> |
|
278 |
|
279 |
|
280 |
|