1<!--
2 ! ASM: a very small and fast Java bytecode manipulation framework
3 ! Copyright (c) 2000-2005 INRIA, France Telecom
4 ! All rights reserved.
5 !
6 ! Redistribution and use in source and binary forms, with or without
7 ! modification, are permitted provided that the following conditions
8 ! are met:
9 ! 1. Redistributions of source code must retain the above copyright
10 !    notice, this list of conditions and the following disclaimer.
11 ! 2. Redistributions in binary form must reproduce the above copyright
12 !    notice, this list of conditions and the following disclaimer in the
13 !    documentation and/or other materials provided with the distribution.
14 ! 3. Neither the name of the copyright holders nor the names of its
15 !    contributors may be used to endorse or promote products derived from
16 !    this software without specific prior written permission.
17 !
18 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 ! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 ! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 ! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 ! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 ! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 ! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 ! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 ! THE POSSIBILITY OF SUCH DAMAGE.
29-->
30
31<project name="ASM" default="compile">
32
33  <!-- ==================================== -->
34  <!-- ======== PROPERTY DEFINITION ======= -->
35  <!-- ==================================== -->
36
37  <property file="${user.home}/asm-build.properties"/>
38  <property file="build.config"/>
39  <property file="build.properties"/>
40  <property file="${global.build.properties}"/>
41  <property file="${user.build.properties}"/>
42
43  <property name="src"                value="${basedir}/src"/>
44  <property name="test"               value="${basedir}/test"/>
45  <property name="doc"                value="${basedir}/doc"/>
46  <property name="jdoc"               value="${basedir}/jdoc"/>
47  <property name="web"                value="${basedir}/web"/>
48  <property name="examples"           value="${basedir}/examples"/>
49  <property name="examples.common"    value="${examples}/common"/>
50  <property name="config"             value="${basedir}/config"/>
51  <property name="archive"            value="${basedir}/archive"/>
52
53  <property name="out"                value="${basedir}/output"/>
54  <property name="out.build"          value="${out}/build"/>
55  <property name="out.instr"          value="${out}/instr"/>
56  <property name="out.dist"           value="${out}/dist"/>
57  <property name="out.dist.lib"       value="${out.dist}/lib"/>
58  <property name="out.dist.doc"       value="${out.dist}/doc"/>
59  <property name="out.dist.jdoc"      value="${out.dist.doc}/javadoc"/>
60  <property name="out.dist.examples"  value="${out.dist}/examples"/>
61  <property name="out.dist.externals" value="${out.dist}/externals"/>
62  <property name="out.test"           value="${out}/test"/>
63  <property name="out.tmp"            value="${out}/tmp"/>
64  <property name="out.zip"            value="${out}/zip"/>
65
66  <target name="properties">
67    <condition property="examples.exist">
68      <available file="${examples}"/>
69    </condition>
70
71    <condition property="web.exist">
72      <available file="${web}/build.xml"/>
73    </condition>
74
75    <condition property="paths.configured">
76      <and>
77        <isset property="objectweb.ant.tasks.path"/>
78      </and>
79    </condition>
80
81    <condition property="product.shrink">
82      <not><isset property="product.noshrink"/></not>
83    </condition>
84  </target>
85
86  <!-- ================================== -->
87  <!-- ========  INITIALIZATION   ======= -->
88  <!-- ================================== -->
89
90  <target name="check" unless="paths.configured">
91    <echo message="The 'build.properties' file must be configured"/>
92    <fail/>
93  </target>
94
95  <target name="init" depends="properties,check">
96
97    <path id="classpath">
98      <pathelement location="${out.build}"/>
99    </path>
100
101    <path id="cobertura.classpath">
102       <pathelement path="${cobertura.path}"/>
103    </path>
104
105    <taskdef name="multipleAnt"
106             classname="org.objectweb.util.ant.MultipleAnt"
107             classpath="${objectweb.ant.tasks.path}"/>
108
109    <taskdef name="javadocMultipleLink"
110             classname="org.objectweb.util.ant.JavadocMultipleLink"
111             classpath="${objectweb.ant.tasks.path}"/>
112
113    <taskdef name="multipleCopy"
114             classname="org.objectweb.util.ant.MultipleCopy"
115             classpath="${objectweb.ant.tasks.path}"/>
116
117    <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
118  </target>
119
120  <!-- =================================== -->
121  <!-- ==========    COMPILE    ========== -->
122  <!-- =================================== -->
123
124  <target name="compile-debug" depends="init">
125    <mkdir dir="${out.tmp}"/>
126    <javac destdir="${out.tmp}" debug="on" includeantruntime="false">
127      <classpath>
128        <pathelement location="${out.tmp}"/>
129        <pathelement path="${annotations-compiler}/dist/lib/javac.jar"/>
130      </classpath>
131      <src path="${src}"/>
132      <include name="**/*.java"/>
133    </javac>
134  </target>
135
136  <target name="shrink" depends="compile-debug" if="product.shrink">
137    <echo message="Shrinking"/>
138    <java classname="org.objectweb.asm.optimizer.Shrinker">
139      <classpath>
140        <pathelement location="${out.tmp}"/>
141      </classpath>
142      <arg value="${src}/org/objectweb/asm/optimizer/shrink.properties"/>
143      <arg value="${out.tmp}"/>
144      <arg value="${out.build}"/>
145    </java>
146  </target>
147
148  <target name="noshrink" depends="compile-debug" if="product.noshrink">
149    <copy todir="${out.build}">
150      <fileset dir="${out.tmp}"/>
151    </copy>
152  </target>
153
154  <target name="bin" depends="compile"/>
155
156  <!-- only one of shrink and noshrink will actually get executed,
157       depending on whether product.noshrink is set.
158  -->
159  <target name="compile" depends="compile-debug,shrink,noshrink">
160    <copy todir="${basedir}/bin">
161      <fileset dir="${out.build}"/>
162    </copy>
163  </target>
164
165  <!-- =================================== -->
166  <!-- ==========      TEST     ========== -->
167  <!-- =================================== -->
168
169  <target name="test" depends="compile">
170    <condition property="classes" value="${out.build}">
171      <not><isset property="debug"/></not>
172    </condition>
173    <condition property="classes" value="${out.tmp}">
174      <isset property="debug"/>
175    </condition>
176    <condition property="asm.test" value="${java.home}/lib/rt.jar,${out.test}/cases">
177      <not><isset property="asm.test"/></not>
178    </condition>
179    <ant antfile="${test}/build.xml" target="test" inheritRefs="true"/>
180  </target>
181
182  <target name="test.report">
183    <junitreport todir="${out.test}/reports">
184      <fileset dir="${out.test}/reports">
185        <include name="TEST-*.xml"/>
186      </fileset>
187      <report todir="${out.test}/reports"/>
188    </junitreport>
189  </target>
190
191  <target name="coverage" depends="compile">
192    <delete file="cobertura.ser"/>
193    <delete dir="${out.instr}"/>
194    <cobertura-instrument todir="${out.instr}">
195      <ignore regex="java.lang.Error"/>
196      <fileset dir="${out.tmp}">
197        <include name="**/*.class"/>
198        <exclude name="**/optimizer/*.class"/>
199        <exclude name="**/xml/Processor*.class"/>
200        <exclude name="**/*Test*.class" />
201      </fileset>
202    </cobertura-instrument>
203    <copy todir="${out.instr}" preservelastmodified="yes">
204      <fileset dir="${out.tmp}"/>
205    </copy>
206    <property name="coverage" value="yes"/>
207    <property name="classes" value="${out.instr}"/>
208    <property name="asm.test.class" value="pkg"/>
209    <condition property="asm.test" value="${out.test}/cases">
210      <not><isset property="asm.test"/></not>
211    </condition>
212    <condition property="test.type" value="conform">
213      <not><isset property="test.type"/></not>
214    </condition>
215    <ant antfile="${test}/build.xml" target="test" inheritRefs="true"/>
216  </target>
217
218  <target name="coverage.check" depends="init">
219    <cobertura-check branchrate="100" linerate="100">
220    </cobertura-check>
221  </target>
222
223  <target name="coverage.report" depends="init">
224    <cobertura-report destdir="${out}/coverage" srcdir="${src}" format="xml"/>
225    <cobertura-report destdir="${out}/coverage">
226      <fileset dir="${src}">
227        <include name="**/*.java"/>
228        <exclude name="**/asm/optimizer/**/*.java"/>
229      </fileset>
230    </cobertura-report>
231  </target>
232
233  <!-- =================================== -->
234  <!-- ==========      DIST     ========== -->
235  <!-- =================================== -->
236
237  <target name="dist.init">
238    <mkdir dir="${out.dist}"/>
239    <mkdir dir="${out.dist.doc}"/>
240    <mkdir dir="${out.dist.jdoc}"/>
241    <mkdir dir="${out.dist.lib}"/>
242  </target>
243
244  <target name="dist.version">
245    <tstamp>
246      <format property="product.build.time" pattern="yyyyMMdd.HHmmss"/>
247    </tstamp>
248
249    <condition property="product.artifact" value="${product.version}">
250      <not><isset property="product.snapshot"/></not>
251    </condition>
252    <condition property="product.artifact" value="${product.build.time}">
253      <isset property="product.snapshot"/>
254    </condition>
255
256    <condition property="plugin.artifact" value="${plugin.version}">
257      <not><isset property="product.snapshot"/></not>
258    </condition>
259    <condition property="plugin.artifact" value="${plugin.version}.${product.build.time}">
260      <isset property="product.snapshot"/>
261    </condition>
262  </target>
263
264  <target name="jar" depends="dist.init,dist.version,compile,shrink">
265    <multipleAnt dir="${archive}"/>
266    <java classname="org.objectweb.asm.optimizer.JarOptimizer">
267      <classpath refid="classpath"/>
268      <arg value="${out.dist.lib}"/>
269    </java>
270  </target>
271
272  <target name="jdoc" depends="init,dist.init">
273    <copy todir="${out.dist.doc}"
274          preservelastmodified="yes"
275          includeEmptyDirs="false">
276      <fileset dir="${doc}">
277        <include name="**/*"/>
278        <exclude name="**/*.fig"/>
279      </fileset>
280    </copy>
281    <multipleAnt dir="${jdoc}"/>
282  </target>
283
284  <target name="examples" depends="init,dist.init" if="examples.exist">
285    <mkdir dir="${out.dist.examples}"/>
286    <copy todir="${out.dist.examples}"
287          preservelastmodified="yes"
288          includeEmptyDirs="yes">
289      <fileset dir="${examples}">
290        <exclude name="common"/>
291        <exclude name="common/**/*"/>
292      </fileset>
293    </copy>
294
295    <multipleCopy file="${examples}/common/build.xml"
296                  toDir="${out.dist.examples}"
297                  notReplace="yes"
298                  preservelastmodified="yes">
299      <include name="*"/>
300      <exclude name="etc"/>
301      <exclude name="lib"/>
302    </multipleCopy>
303
304    <copy toDir="${out.dist.examples}" preservelastmodified="yes">
305      <fileset dir="${examples.common}">
306        <include name="**/*"/>
307        <exclude name="build.xml"/>
308      </fileset>
309    </copy>
310    <replace dir="${out.dist.examples}/etc" token="@product.version@" value="${product.version}"/>
311
312    <copy todir="${out.dist}">
313      <fileset dir=".">
314        <include name="externals/*.jar"/>
315      </fileset>
316    </copy>
317  </target>
318
319  <!--
320  <target name="eclipse.generate" depends="dist.version">
321  </target>
322
323  <target name="eclipse.plugin" depends="jar,eclipse.generate">
324    <jar zipfile="${out}/org.objectweb.asm_${plugin.artifact}.jar">
325      <zipfileset dir="${basedir}">
326        <include name="plugin.xml"/>
327        <include name="META-INF/MANIFEST.MF"/>
328        <include name="**/asm-${product.artifact}.jar"/>
329        <include name="**/asm-tree-${product.artifact}.jar"/>
330        <include name="**/asm-analysis-${product.artifact}.jar"/>
331        <include name="**/asm-util-${product.artifact}.jar"/>
332        <include name="**/asm-commons-${product.artifact}.jar"/>
333        <include name="**/asm-attrs-${product.artifact}.jar"/>
334      </zipfileset>
335      <manifest>
336        <attribute name="Bundle-ManifestVersion" value="2"/>
337        <attribute name="Bundle-Name" value="ASM Framework"/>
338        <attribute name="Bundle-SymbolicName" value="org.objectweb.asm;singleton:=true"/>
339        <attribute name="Bundle-Version" value="${plugin.artifact}"/>
340        <attribute name="Bundle-ClassPath" value="output/dist/lib/asm-${product.artifact}.jar,
341output/dist/lib/asm-tree-${product.artifact}.jar,
342output/dist/lib/asm-analysis-${product.artifact}.jar,
343output/dist/lib/asm-commons-${product.artifact}.jar,
344output/dist/lib/asm-attrs-${product.artifact}.jar,
345output/dist/lib/asm-util-${product.artifact}.jar"/>
346        <attribute name="Bundle-Vendor" value="ObjectWeb.org"/>
347        <attribute name="Bundle-Localization" value="plugin"/>
348        <attribute name="Export-Package" value="org.objectweb.asm,
349org.objectweb.asm.attrs,
350org.objectweb.asm.commons,
351org.objectweb.asm.signature,
352org.objectweb.asm.tree,
353org.objectweb.asm.tree.analysis,
354org.objectweb.asm.util,
355org.objectweb.asm.xml"/>
356        <attribute name="Eclipse-AutoStart" value="true"/>
357      </manifest>
358    </jar>
359  </target>
360
361  <target name="eclipse.feature" depends="eclipse.plugin">
362    <echo file="${out}/feature.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
363<feature id="org.objectweb.asm.feature" label="ASM Framework"
364      version="${plugin.artifact}" provider-name="ObjectWeb.org">
365
366   <description url="http://asm.objectweb.org/eclipse/asm/index.html">
367Feature contains ASM Java bytecode manipulation framework runtime.
368   </description>
369
370   <copyright>
371Copyright (c) 2000-2005 INRIA, France Telecom.
372All rights reserved.
373   </copyright>
374
375   <license>
376Copyright (c) 2000-2005 INRIA, France Telecom
377All rights reserved.
378
379Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
380
3811. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
382
3832. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
384
3853. Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
386
387THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
388   </license>
389
390   <url>
391      <update label="ASM Framework" url="http://download.forge.objectweb.org/eclipse-update/site.xml"/>
392   </url>
393
394   <plugin id="org.objectweb.asm" download-size="0" install-size="0" version="${plugin.artifact}"/>
395
396</feature>]]></echo>
397
398    <jar jarfile="${out}/org.objectweb.asm.feature_${plugin.artifact}.jar">
399      <fileset file="${out}/feature.xml"/>
400    </jar>
401  </target>
402
403  <target name="eclipse.site" depends="eclipse.feature">
404    <echo file="${out}/site.xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
405<site>
406   <description url="http://asm.objectweb.org/eclipse/asm/index.html">
407      ASM Framework
408   </description>
409
410   <feature url="features/org.objectweb.asm.feature_${plugin.artifact}.jar" id="org.objectweb.asm.feature" version="${plugin.artifact}">
411      <category name="asm"/>
412   </feature>
413
414   <category-def name="asm" label="ASM Framework"/>
415
416   <archive path="plugins/org.objectweb.asm_${plugin.artifact}.jar" url="http://download.forge.objectweb.org/asm/org.objectweb.asm_${plugin.artifact}.jar"/>
417</site>]]></echo>
418
419    <zip zipfile="${out}/org.objectweb.asm.update_${plugin.artifact}.zip">
420      <zipfileset dir="${out}" includes="site.xml"/>
421      <zipfileset dir="${out}" includes="org.objectweb.asm.feature_${plugin.artifact}.jar" prefix="features"/>
422      <zipfileset dir="${out}" includes="org.objectweb.asm_${plugin.artifact}.jar"  prefix="plugins"/>
423    </zip>
424  </target>
425  -->
426
427  <target name="dist" depends="jar,jdoc,examples">
428    <zip zipFile="${out.dist}/src.zip" basedir="${src}" excludes="**/optimizer/**/*"/>
429  </target>
430
431  <!-- =================================== -->
432  <!-- ==========    EXAMPLES   ========== -->
433  <!-- =================================== -->
434
435  <target name="example" depends="jar,examples">
436    <ant inheritAll="false"
437         dir="${out.dist.examples}/${example.name}"
438         target="execute"/>
439  </target>
440
441  <!-- =================================== -->
442  <!-- ==========     ZIP       ========== -->
443  <!-- =================================== -->
444
445  <!-- creates zip files of the different distribution (source, binaries) -->
446
447  <target name="zip" depends="dist">
448    <mkdir dir="${out.zip}"/>
449    <tar destfile="${out.zip}/${product.name}-${product.version}.tar.gz"
450         compression="gzip">
451      <tarfileset dir="${basedir}" prefix="${product.name}-${product.version}">
452        <exclude name="build.config"/>
453        <exclude name="config/**"/>
454        <exclude name="config"/>
455        <exclude name="**/externals/**"/>
456        <exclude name="**/externals"/>
457        <exclude name="**/lib/**"/>
458        <exclude name="**/lib"/>
459        <exclude name="eclipse/**"/>
460        <exclude name="eclipse"/>
461        <exclude name="web/**"/>
462        <exclude name="web"/>
463        <exclude name="**/output/**"/>
464        <exclude name="**/output"/>
465        <exclude name="CVSROOT/**"/>
466        <exclude name="CVSROOT"/>
467      </tarfileset>
468    </tar>
469    <zip zipFile="${out.zip}/${product.name}-${product.version}-bin.zip">
470      <zipfileset dir="${out.dist}" prefix="${product.name}-${product.version}"/>
471    </zip>
472  </target>
473
474  <!-- =================================== -->
475  <!-- ==========     CLEAN     ========== -->
476  <!-- =================================== -->
477
478  <!-- remove all directories -->
479
480  <target name="clean.web" if="web.exist">
481    <ant dir="${web}" target="clean"/>
482  </target>
483
484  <target name="clean" depends="properties,clean.web">
485    <delete dir="${basedir}/bin" />
486    <delete dir="${out.build}"/>
487    <delete dir="${out.dist}"/>
488    <delete dir="${out.tmp}"/>
489    <delete dir="${out.zip}"/>
490    <delete dir="${out.test}"/>
491    <delete dir="${out.instr}"/>
492  </target>
493
494  <!-- ==================================== -->
495  <!-- ==========     HELP       ========== -->
496  <!-- ==================================== -->
497
498  <target name="help">
499    <echo message="The available targets are the following:"/>
500    <echo message="  compile: compiles the product into ${out.build}"/>
501    <echo message="  dist: creates the product's distributions into ${out.dist}"/>
502    <echo message="  zip: creates the product's distributions zip files into ${out.zip}"/>
503    <echo message="  clean: removes all generated files."/>
504    <echo message="  jar: creates all jars in ${out.dist.lib}"/>
505    <echo message="  test: run all tests"/>
506    <echo message=""/>
507    <echo message="There are some options to run tests:"/>
508    <echo message="  -Dtest.group=&lt;group name&gt;  Only a group of test: The default target of"/>
509    <echo message="    the xml file is called the test.group contains the xml file name with"/>
510    <echo message="    directory ex: ant -Dtest.group=conform/toto test =&gt; calls the default"/>
511    <echo message="    target of the file ${test}/conform/toto.xml"/>
512    <echo message="  -Dtest.type=&lt;type name&gt;  Only a type of test: conform, deviance, stress,"/>
513    <echo message="    thread or perf. The test.type properties contains the directory name of"/>
514    <echo message="    the test type ex: ant -Dtest.type=conform test"/>
515    <echo message="  -Dtest.name=&lt;test name&gt;  Only a single test. The target &lt;test name&gt; is called"/>
516  </target>
517
518</project>
519