Fix for JRUBY-2882. Handle error messages related to constructors better
[jruby.git] / build.xml
blobb74aa59a1cd8ccf92fd0b266db61358546b1e3cb
1 <?xml version="1.0" encoding="UTF-8"?>
3 <project basedir="." default="jar" name="JRuby">
4   <description>JRuby is a pure Java implementation of a Ruby interpreter.</description>
6   <property name="base.dir" location="${basedir}"/>
8   <!-- First try to load machine-specific properties. -->
9   <property file="build.properties"/>
10   <!-- Load revision number for the ruby specs, in a known good state.
11        There should be no spec failures with such revision. -->
12   <property file="rubyspecs.revision"/>
14   <!-- And then load the defaults. It seems backwards to set defaults AFTER 
15        setting local overrides, but that's how Ant works. -->
16   <property file="default.build.properties"/>
18   <path id="build.classpath">
19     <fileset dir="${build.lib.dir}" includes="*.jar"/>
20     <fileset dir="${lib.dir}" includes="bsf.jar"/>
21   </path>
23   <!-- directory that contains emma.jar and emma_ant.jar: -->
24   <property name="emma.dir" value="${build.lib.dir}" />
26   <path id="emma.classpath">
27     <pathelement location="${emma.dir}/emma.jar" />
28     <pathelement location="${emma.dir}/emma_ant.jar" />
29   </path>
31   <patternset id="java.src.pattern">
32     <include name="**/*.java"/>
33     <exclude unless="bsf.present" name="org/jruby/javasupport/bsf/**/*.java"/>
34     <exclude unless="jdk1.4+" name="**/XmlAstMarshal.java"/>
35     <exclude unless="jdk1.4+" name="**/AstPersistenceDelegates.java"/>
36     <exclude unless="sun-misc-signal" name="**/SunSignalFacade.java"/>
37   </patternset>
39   <patternset id="ruby.src.pattern">
40     <include name="**/*.rb"/>
41   </patternset>
42   
43   <patternset id="other.src.pattern">
44     <include name="**/*.properties"/>
45   </patternset>
46   
47   <taskdef name="retro" classname="net.sourceforge.retroweaver.ant.RetroWeaverTask" classpathref="build.classpath"/>
48   
49   <import file="netbeans-ant.xml" optional="true"/>
51   <!-- Initializes the build -->
52   <target name="init">
53     <xmlproperty file="build-config.xml" keepRoot="false" collapseAttributes="true"/>
54     <tstamp><format property="build.date" pattern="yyyy-MM-dd"/></tstamp>
55     <property environment="env"/>
56     <property name="version.ruby" value="${version.ruby.major}.${version.ruby.minor}"/>
57     <!-- if ruby.home is not set, use env var -->
58     <condition property="ruby.home" value="${env.RUBY_HOME}">
59       <not><isset property="ruby.home"/></not>
60     </condition>
61     <property name="rdoc.archive" value="docs/rdocs.tar.gz"/>
62     <uptodate property="docsNotNeeded" srcfile="${rdoc.archive}" targetfile="${basedir}/share/ri"/>
63   </target>
64   
65   <target name="extract-rdocs" depends="init" unless="docsNotNeeded">
66       <untar src="${rdoc.archive}" dest="${basedir}" compression="gzip"/>
67   </target>
69   <!-- Creates the directories needed for building -->
70   <target name="prepare" depends="extract-rdocs">
71     <mkdir dir="${build.dir}"/>
72     <mkdir dir="${classes.dir}"/>
73     <mkdir dir="${jruby.classes.dir}"/>
74     <mkdir dir="${test.classes.dir}"/>
75     <mkdir dir="${test.results.dir}"/>
76     <mkdir dir="${html.test.results.dir}"/>
77     <mkdir dir="${docs.dir}"/>
78     <mkdir dir="${api.docs.dir}"/>
79   </target>
81   <!-- Checks if specific libs and versions are avaiable -->
82   <target name="check-for-optional-java4-packages"
83           depends="init">
84     <available property="jdk1.4+" classname="java.lang.CharSequence"/>
85     <available property="jdk1.5+" classname="java.lang.StringBuilder"/>
86     <available property="bsf.present" classname="org.apache.bsf.BSFManager"
87                classpathref="build.classpath"/>
88     <available property="junit.present" classname="junit.framework.TestCase"
89                classpathref="build.classpath"/>
90     <available property="cglib.present" 
91                classname="net.sf.cglib.reflect.FastClass"
92                classpathref="build.classpath"/>
93   </target>
95   <!-- Checks if specific libs and versions are avaiable -->
96   <target name="check-for-optional-packages" if="jdk1.5+"
97           depends="check-for-optional-java4-packages">
98     <available property="sun-misc-signal"
99                classname="sun.misc.Signal"/>
100   </target>
102   <!-- Builds the Ant tasks that we need later on in the build -->
103   <target name="compile-tasks" depends="prepare">
104     <copy todir="${jruby.classes.dir}">
105         <fileset dir="${src.dir}">
106             <include name="**/*.rb"/>
107         </fileset>
108     </copy>
109     <copy todir="${jruby.classes.dir}/builtin">
110         <fileset dir="${lib.dir}/ruby/site_ruby/1.8/builtin">
111             <include name="**/*.rb"/>
112         </fileset>
113     </copy>
114     
115     <tstamp>
116         <format property="build.date" pattern="yyyy-MM-dd"/>
117     </tstamp>
118     
119     <copy todir="${jruby.classes.dir}" overwrite="true">
120         <fileset dir="${src.dir}">
121             <include name="**/*.properties"/>
122         </fileset>
123         <filterset>
124             <filter token="os.arch" value="${os.arch}"/>
125             <filter token="java.specification.version" value="${java.specification.version}"/>
126             <filter token="javac.version" value="${javac.version}"/>
127             <filter token="build.date" value="${build.date}"/>
128         </filterset>
129     </copy>
130   </target>
132   <target name="compile-annotation-binder">
133     <mkdir dir="${basedir}/src_gen"/>
134         
135     <javac destdir="${jruby.classes.dir}" debug="true" srcdir="${src.dir}" sourcepath="" classpathref="build.classpath" source="${javac.version}" target="${javac.version}" deprecation="true" encoding="UTF-8">
136         <include name="org/jruby/anno/FrameField.java"/>
137         <include name="org/jruby/anno/AnnotationBinder.java"/>
138         <include name="org/jruby/anno/JRubyMethod.java"/>
139         <include name="org/jruby/anno/FrameField.java"/>
140         <include name="org/jruby/CompatVersion.java"/>
141         <include name="org/jruby/runtime/Visibility.java"/>
142         <include name="org/jruby/util/CodegenUtils.java"/>
143     </javac>
144   </target>
146   <target name="compile-jruby" depends="compile-tasks, compile-annotation-binder, check-for-optional-packages">
147     <!-- Generate binding logic ahead of time -->
148     <apt factory="org.jruby.anno.AnnotationBinder" destdir="${jruby.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" deprecation="true" encoding="UTF-8">
149       <classpath refid="build.classpath"/>
150       <classpath path="${jruby.classes.dir}"/>
151       <src path="${src.dir}"/>
152       <patternset refid="java.src.pattern"/>
153       <compilerarg line="-XDignore.symbol.file=true"/>
154     </apt>
155   </target>
157   <target name="compile" depends="compile-jruby"
158           description="Compile the source files for the project.">
159   </target>
161   <target name="generate-method-classes" depends="compile">
162     <available file="src_gen/annotated_classes.txt" property="annotations.changed"/>
163     <antcall target="_gmc_internal_"/>
164   </target>
165   
166   <target name="_gmc_internal_" if="annotations.changed">
167     <echo message="Generating invokers..."/>
168     <java classname="org.jruby.anno.InvokerGenerator" fork="true" failonerror="true">
169       <classpath refid="build.classpath"/>
170       <classpath path="${jruby.classes.dir}"/>
171       <arg value="src_gen/annotated_classes.txt"/>
172       <arg value="${jruby.classes.dir}"/>
173     </java>
174     
175     <echo message="Compiling populators..."/>
176     <javac destdir="${jruby.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" deprecation="true" encoding="UTF-8">
177        <classpath refid="build.classpath"/>
178        <classpath path="${jruby.classes.dir}"/>
179        <src path="src_gen"/>
180        <patternset refid="java.src.pattern"/>
181     </javac>
182     
183     <delete file="src_gen/annotated_classes.txt"/>
184   </target>
185   
186   <target name="generate-unsafe" depends="compile">
187       <available file="${jruby.classes.dir}/org/jruby/util/unsafe/GeneratedUnsafe.class" property="unsafe.not.needed"/>
188       <antcall target="_gu_internal_"/>
189   </target>
190   
191   <target name="_gu_internal_" unless="unsafe.not.needed">
192     <echo message="Generating Unsafe impl..."/>
193     <java classname="org.jruby.util.unsafe.UnsafeGenerator" fork="true" failonerror="true">
194         <classpath refid="build.classpath"/>
195         <classpath path="${jruby.classes.dir}"/>
196         <arg value="org.jruby.util.unsafe"/>
197         <arg value="${jruby.classes.dir}/org/jruby/util/unsafe"/>
198     </java>
199   </target>
200   
201   <target name="jar-jruby" depends="generate-method-classes, generate-unsafe" unless="jar-up-to-date">  
202       <!-- TODO: Unfortunate dependency on ruby executable, and ruby might
203            not be present on user's side, so we ignore errors caused by that. -->
204       <exec executable="ruby" dir="${basedir}" failifexecutionfails="false" resultproperty="snapshot.result" errorproperty="snapshot.error">
205         <arg value="tool/snapshot.rb"/>
206         <arg value="${jruby.classes.dir}/org/jruby/jruby.properties"/>
207       </exec>
208             
209       <jar destfile="${lib.dir}/jruby.jar" compress="false">
210         <fileset dir="${jruby.classes.dir}"/>
211         <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
212         <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
213         <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
214         <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
215         <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
216         <zipfileset src="${build.lib.dir}/bytelist-0.1.jar"/>
217         <zipfileset src="${build.lib.dir}/jvyamlb-0.2.3.jar"/>
218         <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
219         <zipfileset src="${build.lib.dir}/joni.jar"/>
220         <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
221         <zipfileset src="${build.lib.dir}/jna.jar"/>
222         <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
223         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
224         <manifest>
225           <attribute name="Built-By" value="${user.name}"/>
226           <attribute name="Main-Class" value="org.jruby.Main"/>
227         </manifest>
228       </jar>
229   </target>
230   
231   <target name="jar-jruby-dist" depends="generate-method-classes, generate-unsafe" unless="jar-up-to-date">  
232       <!-- TODO: Unfortunate dependency on ruby executable, and ruby might
233            not be present on user's side, so we ignore errors caused by that. -->
234       <exec executable="ruby" dir="${basedir}" failifexecutionfails="false" >
235         <arg value="tool/snapshot.rb"/>
236         <arg value="${jruby.classes.dir}/org/jruby/jruby.properties"/>
237       </exec>
238             
239       <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc7.jar"/>
240       <jarjar destfile="${lib.dir}/jruby.jar" compress="true">
241         <fileset dir="${jruby.classes.dir}"/>
242         <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
243         <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
244         <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
245         <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
246         <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
247         <zipfileset src="${build.lib.dir}/bytelist-0.1.jar"/>
248         <zipfileset src="${build.lib.dir}/jvyamlb-0.2.3.jar"/>
249         <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
250         <zipfileset src="${build.lib.dir}/joni.jar"/>
251         <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
252         <zipfileset src="${build.lib.dir}/jna.jar"/>
253         <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
254         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
255         <manifest>
256           <attribute name="Built-By" value="${user.name}"/>
257           <attribute name="Main-Class" value="org.jruby.Main"/>
258         </manifest>
259         <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
260       </jarjar>
261       <antcall target="_osgify-jruby_" />
262   </target>
264   <!-- Use Bnd to wrap the JAR generated by jarjar in above task -->
265   <target name="_osgify-jruby_">
266     <filter token="JRUBY_VERSION" value="${version.jruby}"/>
267     <copy file="${basedir}/jruby.bnd.template" tofile="${build.dir}/jruby.bnd" filtering="true"/>
268     <taskdef resource="aQute/bnd/ant/taskdef.properties"
269       classpath="${build.lib.dir}/bnd-0.0.249.jar"/>
270     <bndwrap definitions="${build.dir}" output="${lib.dir}">
271       <fileset file="${lib.dir}/jruby.jar" />
272     </bndwrap>
273     <move file="${lib.dir}/jruby.jar$" tofile="${lib.dir}/jruby.jar" 
274       overwrite="true" />
275   </target>
277   <path id="lib.classpath">
278     <pathelement location="${build.lib.dir}/retroweaver-rt-2.0.5.jar"/>
279     <pathelement location="${build.lib.dir}/backport-util-concurrent.jar"/>
280     <pathelement location="/usr/java/j2sdk1.4.2_16/jre/lib/rt.jar" />
281     <pathelement location="${lib.dir}/bsf.jar" />
282   </path>
284   <target name="jar-1.4" depends="jar-jruby">
285     <copy file="${lib.dir}/jruby.jar" tofile="${lib.dir}/jruby1.5.jar"/>
286     <retro inputjar="${lib.dir}/jruby1.5.jar" outputjar="${lib.dir}/jruby-weaved.jar" target="1.4" failonerror="true" verify="true">
287       <classpath>
288         <path refid="lib.classpath"/>
289         <pathelement location="${lib.dir}/jruby-weaved.jar" />
290       </classpath>
291     </retro>
292     
293       <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc7.jar"/>
294       <jarjar destfile="${lib.dir}/jruby.jar">
295         <zipfileset src="${lib.dir}/jruby-weaved.jar"/>
296         <zipfileset src="${build.lib.dir}/retroweaver-rt-2.0.5.jar"/>
297         <zipfileset src="${build.lib.dir}/backport-util-concurrent.jar"/>
298         <rule pattern="edu.emory.mathcs.backport.**" result="jruby.backport.@1"/>
299         <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
300       </jarjar>
301     <delete file="${lib.dir}/jruby-weaved.jar"/>
302     <delete file="${lib.dir}/jruby1.5.jar"/>
303   </target>
305   <target name="jar-complete-1.4" depends="jar-complete">
306     <copy file="${lib.dir}/jruby-complete.jar" tofile="${lib.dir}/jruby-complete1.5.jar"/>
307     <retro inputjar="${lib.dir}/jruby-complete1.5.jar" outputjar="${lib.dir}/jruby-complete.jar" target="1.4" failonerror="false" verify="true">
308       <classpath>
309         <path refid="lib.classpath"/>
310         <pathelement location="${lib.dir}/jruby-complete.jar" />
311       </classpath>
312     </retro>
313     <delete file="${lib.dir}/jruby-complete1.5.jar"/>
314   </target>
316     <target name="jar-complete" depends="generate-method-classes, generate-unsafe" description="Create the 'complete' JRuby jar. Pass 'mainclass' and 'filename' to adjust.">
317       <property name="mainclass" value="org.jruby.Main"/>
318       <property name="filename" value="jruby-complete.jar"/>
319       <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc7.jar"/>
320       <property name="jar-complete-home" value="${build.dir}/jar-complete/META-INF/jruby.home"/>
321       <mkdir dir="${jar-complete-home}"/>
322       <copy todir="${jar-complete-home}">
323         <fileset dir="${basedir}">
324           <patternset refid="dist.bindir.files"/>
325           <patternset refid="dist.lib.files"/>
326         </fileset>
327       </copy>
328       <copy todir="${build.dir}/jar-complete">
329         <fileset dir="lib/ruby/1.8" includes="**/*"/>
330       </copy>
332       <java classname="${mainclass}" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
333         <classpath>
334           <pathelement location="${jruby.classes.dir}"/>
335           <pathelement location="${build.dir}/jar-complete"/>
336           <path refid="build.classpath"/>
337         </classpath>
338         <sysproperty key="jruby.home" value="${build.dir}/jar-complete/META-INF/jruby.home"/>
339         <arg value="--command"/>
340         <arg value="maybe_install_gems"/>
341         <arg value="rspec"/>
342         <arg value="rake"/>
343         <arg value="--no-ri"/>
344         <arg value="--no-rdoc"/>
345         <arg value="--env-shebang"/>
346       </java>
347       
348       <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc7.jar"/>
349       <jarjar destfile="${lib.dir}/${filename}">
350         <fileset dir="${jruby.classes.dir}"/>
351         <fileset dir="${build.dir}/jar-complete">
352           <exclude name="META-INF/jruby.home/lib/ruby/1.8/**"/>
353         </fileset>
354         <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
355         <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
356         <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
357         <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
358         <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
359         <zipfileset src="${build.lib.dir}/bytelist-0.1.jar"/>
360         <zipfileset src="${build.lib.dir}/jvyamlb-0.2.3.jar"/>
361         <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
362         <zipfileset src="${build.lib.dir}/joni.jar"/>
363         <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
364         <zipfileset src="${build.lib.dir}/jna.jar"/>
365         <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
366         <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
367         <manifest>
368           <attribute name="Built-By" value="${user.name}"/>
369           <attribute name="Main-Class" value="${mainclass}"/>
370         </manifest>
371         <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
372       </jarjar>
373     </target>
375     <target name="jar-console" depends="generate-method-classes" description="Create the jruby graphical console jar">
376           <antcall target="jar-complete">
377               <param name="mainclass" value="org.jruby.demo.IRBConsole"/>
378               <param name="filename" value="jruby-console.jar"/>
379           </antcall>
380     </target>
382   <target name="jar" depends="init" description="Create the jruby.jar file">
383     <antcall target="jar-jruby" inheritall="true"/>
384   </target>
385   <target name="jar-dist" depends="init" description="Create the jruby.jar file for distribution. This version uses JarJar Links to rewrite some packages.">
386     <antcall target="jar-jruby-dist" inheritall="true"/>
387   </target>
389   <target name="compile-test" depends="jar" description="Compile the unit tests">
390     <javac destdir="${test.classes.dir}" deprecation="true" debug="true" 
391            source="${javac.version}">
392       <classpath>
393         <path refid="build.classpath"/>
394         <pathelement path="${jruby.classes.dir}"/>
395         <pathelement path="${lib.dir}/jruby.jar"/>
396       </classpath>
397       <src path="${test.dir}"/>
398       <src path="${spec.dir}"/>
399       <patternset refid="java.src.pattern"/>
400     </javac>
401   </target>
403   <target name="copy-test-files" depends="compile-test" 
404     description="Make tests fails available as resources">
405     <copy todir="${test.classes.dir}">
406       <fileset dir="${test.dir}" includes="org/**/*.rb"/>
407     </copy>
408   </target>
410   <target name="install-gems">
411     <property name="jruby.home" value="${basedir}"/>
412     <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
413       <classpath refid="build.classpath"/>
414       <classpath path="${jruby.classes.dir}"/>
415       <sysproperty key="jruby.home" value="${jruby.home}"/>
416       <arg value="--command"/>
417       <arg value="maybe_install_gems"/>
418       <arg value="rspec"/>
419       <arg value="rake"/>
420       <arg value="--env-shebang"/>
421     </java>
422   </target>
423   
424   <target name="compile-stdlib" unless="test">
425     <copy todir="${build.dir}/stdlib">
426         <fileset dir="${basedir}/lib/ruby/1.8">
427           <include name="**/*.rb"/>
428         </fileset>
429     </copy>
430     <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true" dir="${build.dir}/stdlib">
431       <classpath refid="build.classpath"/>
432       <classpath path="${jruby.classes.dir}"/>
433       <sysproperty key="jruby.home" value="${basedir}"/>
434       <sysproperty key="jruby.objectspace.enabled" value="true"/>
435       <jvmarg value="-ea"/>
436       
437       <arg value="-I"/>
438       <arg value="bin/"/>
439       <arg value="-S"/>
440       <arg value="jrubyc"/>
441       <arg line="."/>
442     </java>
443   </target>
445   <target name="emma" description="turns on EMMA instrumentation/reporting" >
446     <available property="emma.present"
447                classname="com.vladium.app.IAppVersion"
448                classpathref="emma.classpath"/>
449     <taskdef resource="emma_ant.properties" classpathref="emma.classpath" />
450   
451     <property name="emma.enabled" value="true" />
453     <path id="classes_to_instrument" >
454       <pathelement location="${jruby.classes.dir}" />
455     </path>   
456   </target>
458   <target name="instrument" if="emma.present">
459     <emma enabled="${emma.enabled}" >
460       <instr instrpathref="classes_to_instrument"
461              destdir="${jruby.instrumented.classes.dir}"  
462              metadatafile="${test.results.dir}/metadata.emma"
463          merge="false" />
464     </emma>
465   </target>
467   <target name="coverage-report" if="emma.present">
468     <emma enabled="${emma.enabled}" >
469       <report sourcepath="${src.dir}" >
470         <fileset dir="${test.results.dir}" >
471       <include name="*.emma" />
472         </fileset>
473         <html outfile="${html.test.coverage.results.dir}/coverage.html" />
474       </report>
475     </emma>
476   </target>
478   <target name="test" depends="
479     copy-test-files,
480     instrument,
481     run-junit-compiled,
482     run-junit-compiled-1.9,
483     test-security-manager,
484     coverage-report"
485     description="Runs unit tests.">
486   </target>
488   <target name="test-compiled" depends="copy-test-files,run-junit-compiled,run-junit-precompiled"/>
489   <target name="test-compiled-1.9" depends="copy-test-files,run-junit-compiled-1.9,run-junit-precompiled-1.9"/>
490   <target name="test-interpreted" depends="copy-test-files,run-junit-interpreted"/>
491   <target name="test-interpreted-1.9" depends="copy-test-files,run-junit-interpreted-1.9"/>
492   <target name="test-reflected" depends="copy-test-files,run-junit-reflected-compiled,run-junit-reflected-precompiled,run-junit-reflected-interpreted"/>
493   <target name="test-threadpool" depends="copy-test-files,run-junit-compiled-threadpool,run-junit-precompiled-threadpool,run-junit-interpreted-threadpool"/>
494   
495   <target name="test-all" depends="
496       copy-test-files,
497       instrument,
498       test-security-manager,
499       run-junit-interpreted,
500       run-junit-compiled,
501       run-junit-precompiled,
502       run-junit-interpreted-1.9,
503       run-junit-compiled-1.9,
504       run-junit-precompiled-1.9,
505       run-junit-reflected-precompiled,
506       run-junit-interpreted-threadpool,
507       compile-stdlib,
508       coverage-report"
509           description="Runs unit tests in all modes."/>
511   <target name="weave-tests" description="weave the test classes">
512     <retro srcdir="${test.classes.dir}" target="1.4" failonerror="true" verify="true">
513       <classpath>
514         <path refid="lib.classpath"/>
515         <pathelement location="${lib.dir}/jruby.jar" />
516         <pathelement location="${build.lib.dir}/junit.jar" />
517         <pathelement location="${build.lib.dir}/asm-3.0.jar" />
518         <pathelement location="${test.classes.dir}" />
519       </classpath>
520     </retro>
521   </target>
523   <target name="test-1.4" depends="
524     copy-test-files,
525     jar-1.4,
526     weave-tests,
527     instrument,
528     run-junit-compiled,
529     run-junit-compiled-1.9,
530     coverage-report"
531         description="Runs unit tests with weaved jruby classes.">
532   </target>
534   <target name="test-all-1.4" depends="
535       copy-test-files,
536       jar-1.4,
537       weave-tests,
538       instrument,
539       run-junit-interpreted,
540       run-junit-compiled,
541       run-junit-precompiled,
542       run-junit-interpreted-1.9,
543       run-junit-compiled-1.9,
544       run-junit-precompiled-1.9,
545       run-junit-reflected-precompiled,
546       run-junit-precompiled-threadpool,
547       compile-stdlib,
548       coverage-report"
549           description="Runs unit tests in all modes with weaved jruby classes."/>
551   <!-- All junit permutations for 1.8 and 1.9 support -->
552   <target name="run-junit-interpreted"><run-junit-1.8/></target>
553   <target name="run-junit-interpreted-1.9"><run-junit-1.9/></target>
554   <target name="run-junit-reflected-interpreted"><run-junit-1.8 reflection="true"/></target>
555   <target name="run-junit-reflected-interpreted-1.9"><run-junit-1.9 reflection="true"/></target>
556   <target name="run-junit-compiled"><run-junit-1.8 compile.mode="JIT" jit.threshold="0"/></target>
557   <target name="run-junit-compiled-1.9"><run-junit-1.9 compile.mode="JIT" jit.threshold="0"/></target>
558   <target name="run-junit-reflected-compiled"><run-junit-1.8 compile.mode="JIT" jit.threshold="0" reflection="true"/></target>
559   <target name="run-junit-reflected-compiled-1.9"><run-junit-1.9 compile.mode="JIT" jit.threshold="0" reflection="true"/></target>
560   <target name="run-junit-precompiled"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0"/></target>
561   <target name="run-junit-precompiled-1.9"><run-junit-1.9 compile.mode="FORCE" jit.threshold="0"/></target>
562   <target name="run-junit-reflected-precompiled"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0" reflection="true"/></target>
563   <target name="run-junit-reflected-precompiled-1.9"><run-junit-1.9 compile.mode="FORCE" jit.threshold="0" reflection="true"/></target>
564   <target name="run-junit-threadpool" depends="run-junit-interpreted-threadpool,run-junit-compiled-threadpool"/>
565   <target name="run-junit-interpreted-threadpool"><run-junit-1.8 thread.pooling="true"/></target>
566   <target name="run-junit-compiled-threadpool"><run-junit-1.8 compile.mode="JIT" jit.threshold="0" thread.pooling="true"/></target>
567   <target name="run-junit-precompiled-threadpool"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0" thread.pooling="true"/></target>
568   
569   <path id="test.class.path">
570     <pathelement location="${jruby.instrumented.classes.dir}" />
571     <fileset dir="${build.lib.dir}" includes="*.jar">
572       <exclude name="joni.jar"/>
573     </fileset>
574     <pathelement path="${lib.dir}/bsf.jar"/>
575     <pathelement path="${java.class.path}"/>
576     <pathelement path="${lib.dir}/jruby.jar"/>
577     <pathelement location="${test.classes.dir}"/>
578     <pathelement path="${test.dir}/requireTest.jar"/>
579     <pathelement location="${test.dir}"/>
580   </path>
582   <macrodef name="run-junit">
583     <attribute name="jruby.version" default="ruby1_8"/>
584     <attribute name="compile.mode" default="OFF"/>
585     <attribute name="jit.threshold" default="20"/>
586     <attribute name="jit.max" default="-1"/>
587     <attribute name="objectspace.enabled" default="true"/>
588     <attribute name="thread.pooling" default="false"/>
589     <attribute name="reflection" default="false"/>
590     <element name="junit-tests"/>
591     <sequential>
592       <echo message="compile=@{compile.mode}, jit.threshold=@{jit.threshold}, jit.max=@{jit.max}, objectspace=@{objectspace.enabled} threadpool=@{thread.pooling} reflection=@{reflection} version=@{jruby.version}"/>
593       <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" classpath="${build.lib.dir}/junit.jar"/>
595       <junit jvm="${jruby.test.jvm}" fork="yes" forkMode="once" haltonfailure="true" dir="${basedir}" maxmemory="${jruby.test.memory}" showoutput="true" timeout="1800000">
596         <classpath refid="test.class.path"/>
597       
598         <sysproperty key="java.awt.headless" value="true"/>
599         <sysproperty key="jruby.home" value="${basedir}"/>
600         <sysproperty key="jruby.lib" value="${lib.dir}"/>
601         <sysproperty key="jruby.compile.mode" value="@{compile.mode}"/>
602         <sysproperty key="jruby.jit.threshold" value="@{jit.threshold}"/>
603         <sysproperty key="jruby.jit.max" value="@{jit.max}"/>
604         <sysproperty key="jruby.compat.version" value="@{jruby.version}"/>
605         <sysproperty key="jruby.objectspace.enabled" value="@{objectspace.enabled}"/>
606         <sysproperty key="jruby.thread.pool.enabled" value="@{thread.pooling}"/>
607         <sysproperty key="jruby.reflection" value="@{reflection}"/>
608         <sysproperty key="jruby.jit.logging.verbose" value="true"/>
609         <sysproperty key="jruby.compile.lazyHandles" value="true"/>
610         <sysproperty key="emma.coverage.out.file" value="${test.results.dir}/coverage.emma" />
611         <sysproperty key="emma.coverage.out.merge" value="true" />
613         <jvmarg value="-ea"/>
614         
615         <!-- force client VM to improve test run times -->
616         <jvmarg value="-client"/>
618         <!-- set a larger max permgen, since the tests load a lot of bytecode -->
619         <jvmarg value="-XX:MaxPermSize=128M"/>
621         <formatter type="xml"/>
622         <formatter type="brief" usefile="false" />
624         <junit-tests/>
625       </junit>
627       <junitreport todir="${test.results.dir}">
628         <fileset dir="${test.results.dir}" includes="TEST-*.xml"/>
629         <report format="frames" todir="${html.test.results.dir}"/>
630       </junitreport>
631     </sequential>
632   </macrodef>
633   
634   <!-- runs junit tests for 1.8 functionality -->
635   <macrodef name="run-junit-1.8">
636     <attribute name="compile.mode" default="OFF"/>
637     <attribute name="jit.threshold" default="20"/>
638     <attribute name="reflection" default="false"/>
639     <attribute name="thread.pooling" default="false"/>
641     <sequential>
642       <run-junit compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}" reflection="@{reflection}" thread.pooling="@{thread.pooling}">
643         <junit-tests>
644           <test name="${test}" if="test"/>
645           <test name="org.jruby.test.ScriptTestSuite" todir="${test.results.dir}" unless="test"/>
646           <test name="org.jruby.test.BFTSTestSuite" todir="${test.results.dir}" unless="test"/>
647           <test name="org.jruby.test.JRubyTestSuite" todir="${test.results.dir}" unless="test"/>
648           <test name="org.jruby.test.DubyTestSuite" todir="${test.results.dir}" unless="test"/>
649           <test name="org.jruby.test.MRITestSuite" todir="${test.results.dir}" unless="test"/>
650           <test name="org.jruby.test.RubiconTestSuite" todir="${test.results.dir}" unless="test"/>
651           <test name="org.jruby.test.RubyTestTestSuite" todir="${test.results.dir}" unless="test"/>
652           <test name="org.jruby.test.MainTestSuite" todir="${test.results.dir}" unless="test"/>
653         </junit-tests>
654       </run-junit>
655     </sequential>
656   </macrodef>
658   <macrodef name="run-junit-1.9">
659     <attribute name="compile.mode" default="OFF"/>
660     <attribute name="jit.threshold" default="20"/>
661     <attribute name="reflection" default="false"/>
662     <attribute name="thread.pooling" default="false"/>
664     <sequential>
665       <run-junit objectspace.enabled="false" jruby.version="ruby1_9" compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}" reflection="@{reflection}" thread.pooling="@{thread.pooling}">
666         <junit-tests>
667           <test name="${test}" if="test"/>
668           <test name="org.jruby.test.Ruby1_9TestSuite" todir="${test.results.dir}"  unless="test"/>
669         </junit-tests>
670       </run-junit>
671     </sequential>
672   </macrodef>
674   <target name="test-security-manager">
675     <java classname="org.jruby.Main" fork="true" failonerror="true">
676       <classpath refid="build.classpath"/>
677       <classpath path="${jruby.classes.dir}"/>
678       <sysproperty key="java.security.manager" value=""/>
679       <sysproperty key="java.security.policy" value="file:test/restricted.policy"/>
680       <arg value="-e"/>
681       <arg value="puts 'Restricted policy looks ok'"/>
682     </java>
683   </target>
685   <target name="detect-stable-specs-need-update">
686     <property file="${spec.dir}/rubyspecs.current.revision"/>
687     <condition property="stable-specs-need-update">
688       <or>
689         <not> <available file="${rubyspec.dir}"/> </not>
690         <not> <available file="${mspec.dir}"/> </not>
691         <not>
692           <equals
693             arg1="${rubyspecs.revision}"
694             arg2="${rubyspecs.current.revision}"/>
695         </not>
696         <not>
697           <equals
698             arg1="${mspec.revision}"
699             arg2="${mspec.current.revision}"/>
700         </not>
701       </or>
702     </condition>
703   </target>
705   <target name="fetch-stable-specs" depends="prepare, detect-stable-specs-need-update" if="stable-specs-need-update">
706     <echo message="Downlodaing stable mspec..."/>
707     <get src="http://github.com/rubyspec/mspec/tarball/${mspec.revision}" dest="${build.dir}/mspec.tgz"/>
708     <echo message="Downlodaing stable rubyspecs..."/>
709     <get src="http://github.com/rubyspec/rubyspec/tarball/${rubyspecs.revision}" dest="${build.dir}/rubyspec.tgz"/>
711     <!-- Wipe the old mspec/rubyspecs, if any, and exctract new ones -->
713     <delete dir="${mspec.dir}"/>
714     <mkdir dir="${mspec.dir}"/>
715     <!-- TODO: We use 'tar' binary since Ant doesn't understand tarballs from GitHub,
716          at least in cases when long file names are present
717     <untar src="${build.dir}/mspec.tgz" dest="${mspec.dir}" compression="gzip">
718       <globmapper from="rubyspec-mspec-${mspec.revision}/*" to="*"/>
719     </untar> -->
720     <exec executable="tar" dir="${mspec.dir}" failonerror="true">
721       <arg line="-xzf ${build.dir}/mspec.tgz --strip-components=1"/>
722     </exec>
723     <chmod file="${mspec.dir}/bin/mspec" perm="755"/>
725     <delete dir="${rubyspec.dir}"/>
726     <mkdir dir="${rubyspec.dir}"/>
727     <!-- TODO: disabled 'untar' due to problem, see comment above
728     <untar src="${build.dir}/rubyspec.tgz" dest="${rubyspec.dir}" compression="gzip">
729         <globmapper from="rubyspec-rubyspec-${rubyspecs.revision}/*" to="*"/>
730     </untar> -->
731     <exec executable="tar" dir="${rubyspec.dir}" failonerror="true">
732       <arg line="-xzf ${build.dir}/rubyspec.tgz --strip-components=1"/>
733     </exec>
735         <!-- Write down the revision of downloaded specs -->
736     <propertyfile file="${spec.dir}/rubyspecs.current.revision" comment="Revision of downloaded specs.">
737       <entry key="rubyspecs.current.revision" value="${rubyspecs.revision}"/>
738       <entry key="mspec.current.revision" value="${mspec.revision}"/>
739     </propertyfile>
740   </target>
742   <!-- NOTE: There are two different rubyspecs versions: stable and unstable.
743        Stable ones are in known good state, and all known JRuby failures are excluded.
744        The idea is that the stable specs runs must be clean, no failures.
745        Unstable specs are the very latest, and might have new failures.
747        Stable specs are downloaded as a snapshot of particular revision.
748        Unstable specs are downloaded as a git repo. -->
750   <!-- stable specs -->
751   <target name="spec" depends="fetch-stable-specs, run-specs"
752       description="Runs known good version of rubyspecs."/>
753   <target name="spec-all" depends="fetch-stable-specs, run-specs-all"
754       description="Runs known good version of rubyspecs without exclusions."/>
755   <target name="spec-all-interpreted" depends="fetch-stable-specs, run-specs-all-interpreted"
756       description="Runs known good version of rubyspecs without exclusions."/>
758   <!-- latest, unstable specs -->
759   <target name="spec-latest" depends="fetch-specs, run-specs"
760       description="Runs the very latest rubyspecs."/>
761   <target name="spec-latest-all" depends="fetch-specs, run-specs-all"
762           description="Runs the very latest rubyspecs without exclusions."/>
763   
764   <target name="fetch-specs">
765       <condition property="rubyspec-repo-exists">
766           <available file="${rubyspec.dir}/.git"/>
767       </condition>
768       
769       <antcall target="do-fetch-specs"/>
770       <antcall target="do-update-specs"/>
771   </target>
773   <target name="do-fetch-specs" unless="rubyspec-repo-exists">
774       <!-- Stable specs might exist, so delete them -->
775       <antcall target="clear-specs" inheritall="false"/>
777       <echo message="Cloning rubyspec repo to: ${rubyspec.dir}"/>
778       <exec dir="${spec.dir}" executable="git">
779           <arg value="clone"/>
780           <arg value="--depth"/><arg value="1"/>
781           <arg value="git://github.com/rubyspec/rubyspec.git"/>
782           <arg value="${rubyspec.dir}"/>
783       </exec>
785       <echo message="Cloning mspec repo to: ${mspec.dir}"/>
786       <exec dir="${spec.dir}" executable="git">
787                 <arg value="clone"/>
788                 <arg value="--depth"/><arg value="1"/>
789                 <arg value="git://github.com/rubyspec/mspec.git"/>
790                 <arg value="${mspec.dir}"/>
791       </exec>
792   </target>
794   <target name="do-update-specs" if="rubyspec-repo-exists">
795       <echo message="Updading rubyspec repo -- ${rubyspec.dir}"/>
796       <exec dir="${rubyspec.dir}" executable="git">
797         <arg value="pull"/>
798       </exec>
799       <echo message="Updading mspec repo -- ${mspec.dir}"/>
800       <exec dir="${mspec.dir}" executable="git">
801         <arg value="pull"/>
802       </exec>
803   </target>
805   <target name="clear-specs">
806       <delete dir="${rubyspec.dir}"/>
807       <delete dir="${mspec.dir}"/>
808       <delete file="${build.dir}/rubyspec.tgz"/>
809       <delete file="${build.dir}/mspec.tgz"/>
810       <delete file="${spec.dir}/rubyspecs.current.revision"/>
811   </target>
813   <target name="run-specs" depends="run-specs-precompiled, run-specs-compiled, run-specs-interpreted, jar">
814     <condition property="spec.status.combined.OK">
815       <and>
816         <equals arg1="${spec.status.PRECOMPILED}" arg2="0"/>
817         <equals arg1="${spec.status.COMPILED}"    arg2="0"/>
818         <equals arg1="${spec.status.INTERPRETED}" arg2="0"/>
819       </and>
820     </condition>
821     <fail message="RubySpecs FAILED" unless="spec.status.combined.OK"/>
822   </target>
824   <target name="run-specs-all" depends="jar"><antcall target="run-specs-all-precompiled"/></target>
826   <target name="run-specs-compiled" depends="jar">
827     <_run_specs_internal mode.name="COMPILED" compile.mode="JIT" jit.threshold="0"/>
828   </target>
829   <target name="run-specs-precompiled" depends="jar">
830     <_run_specs_internal mode.name="PRECOMPILED" compile.mode="FORCE" jit.threshold="0"/>
831   </target>
832   <target name="run-specs-interpreted" depends="jar">
833     <_run_specs_internal mode.name="INTERPRETED" compile.mode="OFF"/>
834   </target>
836   <target name="run-specs-all-interpreted"><_run_specs_all_internal compile.mode="OFF"/></target>
837   <target name="run-specs-all-precompiled"><_run_specs_all_internal compile.mode="FORCE" jit.threshold="0"/></target>
839   
840   <target name="update-excludes">
841     <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" dir="${spec.dir}">
842       <classpath refid="build.classpath"/>
843       <classpath path="${jruby.classes.dir}"/>
844       <sysproperty key="jruby.home" value="${basedir}"/>
845       <sysproperty key="jruby.launch.inproc" value="false"/>
846       
847       <arg line="${mspec.dir}/bin/mspec tag"/>
848       <arg line="--add fails --fail"/>
849       <arg line="-B ${spec.dir}/default.mspec"/>
850     </java>
851   </target>
853   <target name="spec-show-excludes" depends="prepare"
854     description="Prints out all currently excluded rubyspecs.">
856     <available property="mspec-available"
857       file="${mspec.dir}/bin/mspec"/>
858     <fail unless="mspec-available"
859       message="No rubyspecs found. Download them via 'ant spec'."/>
861     <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" dir="${spec.dir}">
862       <classpath refid="build.classpath"/>
863       <classpath path="${jruby.classes.dir}"/>
864       <sysproperty key="jruby.home" value="${basedir}"/>
865       <sysproperty key="jruby.launch.inproc" value="false"/>
866       <arg line="${mspec.dir}/bin/mspec"/>
867       <arg line="-f s -g fails --dry-run"/>
868       <arg line="-B ${spec.dir}/default.mspec"/>
869       <arg value="${rubyspec.dir}/1.8"/>
870     </java>
871   </target>
873   <macrodef name="run-specs">
874     <attribute name="compile.mode" default="OFF"/>
875     <attribute name="jit.threshold" default="20"/>
876     <attribute name="jit.max" default="-1"/>
877     <attribute name="objectspace.enabled" default="true"/>
878     <attribute name="thread.pooling" default="false"/>
879     <attribute name="reflection" default="false"/>
880     <attribute name="mode.name"/>
881     <element name="extra-args" optional="true"/>
883     <sequential>
884       <echo message="compile=@{compile.mode}, threshold=@{jit.threshold}, objectspace=@{objectspace.enabled} threadpool=@{thread.pooling} reflection=@{reflection}"/>
885     
886       <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" resultproperty="spec.status.@{mode.name}" dir="${base.dir}">
887         <classpath refid="build.classpath"/>
888         <classpath path="${jruby.classes.dir}"/>
890         <jvmarg value="-ea"/>
892         <sysproperty key="jruby.home" value="${basedir}"/>
893         <sysproperty key="jruby.launch.inproc" value="false"/>
894       
895         <!-- properties tweaked for individual runs -->
896         <sysproperty key="jruby.compile.mode" value="@{compile.mode}"/>
897         <sysproperty key="jruby.jit.threshold" value="@{jit.threshold}"/>
898         <sysproperty key="jruby.jit.max" value="@{jit.max}"/>
899         <sysproperty key="jruby.objectspace.enabled" value="@{objectspace.enabled}"/>
900         <sysproperty key="jruby.thread.pool.enabled" value="@{thread.pooling}"/>
901         <sysproperty key="jruby.reflection" value="@{reflection}"/>
903         <arg line="${mspec.dir}/bin/mspec ci"/>
904         <arg line="-T -J-ea"/>
905         <arg line="-T -J-Djruby.launch.inproc=false"/>
906         <arg line="-T -J-Djruby.compile.mode=@{compile.mode}"/>
907         <arg line="-T -J-Djruby.jit.threshold=@{jit.threshold}"/>
908         <arg line="-T -J-Djruby.jit.max=@{jit.max}"/>
909         <arg line="-T -J-Djruby.objectspace.enabled=@{objectspace.enabled}"/>
910         <arg line="-T -J-Djruby.thread.pool.enabled=@{thread.pooling}"/>
911         <arg line="-T -J-Djruby.reflection=@{reflection}"/>
912         <arg line="-f m"/>
913         <extra-args/>
914         <arg line="-B ${spec.dir}/default.mspec"/>
915       </java>
916     </sequential>
917   </macrodef>
919   <macrodef name="_run_specs_internal">
920     <attribute name="compile.mode" default="OFF"/>
921     <attribute name="jit.threshold" default="20"/>
922     <attribute name="mode.name"/>
924     <sequential>
925       <echo message="Excludes: ${spec.tags.dir}"/>
926       <run-specs mode.name="@{mode.name}"
927         compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}"/>
928     </sequential>
929   </macrodef>
931   <macrodef name="_run_specs_all_internal">
932     <attribute name="compile.mode" default="OFF"/>
933     <attribute name="jit.threshold" default="20"/>
935     <sequential>
936       <run-specs compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}"/>
937     </sequential>
938   </macrodef>
940   <macrodef name="fixEOLs">
941     <sequential>
942       <fixcrlf srcdir="dist/bin" excludes="*.bat" eol="lf"/>
943       <fixcrlf srcdir="dist/bin" includes="*.bat" eol="crlf"/>
944     </sequential>
945   </macrodef>
947   <target name="create-apidocs" depends="prepare" 
948           description="Creates the Java API docs">
949     <javadoc destdir="${api.docs.dir}" author="true" version="true" use="true" 
950              windowtitle="JRuby API" source="${javac.version}" useexternalfile="true">
951       <fileset dir="${src.dir}">
952         <include name="**/*.java"/>
953       </fileset>
954       <fileset dir="${test.dir}">
955     <include name="**/*.java"/>
956       </fileset>
957       <doctitle><![CDATA[<h1>JRuby</h1>]]></doctitle>
958       <bottom><![CDATA[<i>Copyright &#169; 2002-2007 JRuby Team. All Rights Reserved.</i>]]></bottom>
959     </javadoc>
960   </target>
962   <patternset id="dist.bindir.files">
963     <include name="bin/*jruby*"/>
964     <include name="bin/*gem*"/>
965     <include name="bin/*ri*"/>
966     <include name="bin/*rdoc*"/>
967     <include name="bin/*jirb*"/>
968     <include name="bin/generate_yaml_index.rb"/>
969     <include name="bin/testrb"/>
970   </patternset>
972   <patternset id="dist.lib.files">
973     <include name="lib/ruby/1.8/**"/>
974     <include name="lib/ruby/site_ruby/1.8/**"/>
975     <include name="lib/ruby/gems/1.8/specifications/sources-0.0.1.gemspec"/>
976     <include name="lib/ruby/gems/1.8/gems/sources-0.0.1/**"/>
977   </patternset>
979   <patternset id="dist.files">
980     <include name="lib/*"/>
981     <include name="samples/**"/>
982     <include name="docs/**"/>
983     <include name="COPYING*"/>
984     <include name="README"/>
985     <exclude name="lib/ruby/**"/>
986   </patternset>
988   <patternset id="dist.bin.files">
989     <patternset refid="dist.files"/>
990     <exclude name="lib/emma.jar"/>
991     <exclude name="lib/emma_ant.jar"/>
992     <exclude name="lib/junit.jar"/>
993     <exclude name="lib/jarjar-1.0rc7.jar"/>
994     <exclude name="docs/rdocs.tar.gz"/>
995     <exclude name="bench/**"/>
996     <include name="share/**"/>
997   </patternset>
999   <patternset id="dist.src.files">
1000     <patternset refid="dist.files"/>
1001     <exclude name="share/**"/>
1002     <include name="bench/**"/>
1003     <include name="src/**"/>
1004     <include name="test/**"/>
1005     <include name="spec/**"/>
1006     <include name="tool/**"/>
1007     <include name="build_lib/**"/>
1008     <include name="Rakefile"/>
1009     <include name="build.xml"/>
1010     <include name="build-config.xml"/>
1011     <include name="nbproject/*"/>
1012     <include name=".project"/>
1013     <include name=".classpath"/>
1014     <include name="default.build.properties"/>
1015     <exclude name="lib/jruby.jar"/>
1016   </patternset>
1018   <target name="dist-bin" depends="jar-dist">
1019     <mkdir dir="dist"/>
1020     <copy todir="dist">
1021       <fileset dir="${basedir}">
1022         <patternset refid="dist.bindir.files"/>
1023         <patternset refid="dist.lib.files"/>
1024       </fileset>
1025     </copy>
1026     <fixEOLs/>
1027     <antcall target="install-gems">
1028       <param name="jruby.home" value="dist"/>
1029     </antcall>
1030     <tar destfile="jruby-bin-${version.jruby}.tar.gz" compression="gzip">
1031       <tarfileset dir="dist" mode="755" prefix="jruby-${version.jruby}">
1032         <include name="bin/**"/>
1033       </tarfileset>
1034       <tarfileset dir="dist" prefix="jruby-${version.jruby}">
1035         <include name="lib/**"/>
1036       </tarfileset>
1037       <tarfileset dir="${basedir}" prefix="jruby-${version.jruby}">
1038         <patternset refid="dist.bin.files"/>
1039       </tarfileset>
1040     </tar>
1041     <zip destfile="jruby-bin-${version.jruby}.zip">
1042       <zipfileset dir="dist" filemode="755" prefix="jruby-${version.jruby}">
1043         <include name="bin/**"/>
1044       </zipfileset>
1045       <zipfileset dir="dist" prefix="jruby-${version.jruby}">
1046         <include name="lib/**"/>
1047       </zipfileset>
1048       <zipfileset dir="${basedir}" prefix="jruby-${version.jruby}">
1049         <patternset refid="dist.bin.files"/>
1050       </zipfileset>
1051     </zip>
1052   </target>
1054   <target name="dist-src" depends="jar">
1055     <mkdir dir="dist"/>
1056     <copy todir="dist">
1057       <fileset dir="${basedir}">
1058         <patternset refid="dist.bindir.files"/>
1059         <patternset refid="dist.lib.files"/>
1060       </fileset>
1061     </copy>
1062     <antcall target="install-gems">
1063       <param name="jruby.home" value="dist"/>
1064     </antcall>
1065     <fixEOLs/>
1066     <tar destfile="jruby-src-${version.jruby}.tar.gz" compression="gzip">
1067       <tarfileset dir="dist" mode="755" prefix="jruby-${version.jruby}">
1068         <include name="bin/**"/>
1069       </tarfileset>
1070       <tarfileset dir="dist" prefix="jruby-${version.jruby}">
1071         <include name="lib/**"/>
1072       </tarfileset>
1073       <tarfileset dir="${basedir}" prefix="jruby-${version.jruby}">
1074         <patternset refid="dist.src.files"/>
1075       </tarfileset>
1076     </tar>
1077     <zip destfile="jruby-src-${version.jruby}.zip">
1078       <zipfileset dir="dist" filemode="755" prefix="jruby-${version.jruby}">
1079         <include name="bin/**"/>
1080       </zipfileset>
1081       <zipfileset dir="dist" prefix="jruby-${version.jruby}">
1082         <include name="lib/**"/>
1083       </zipfileset>
1084       <zipfileset dir="${basedir}" prefix="jruby-${version.jruby}">
1085         <patternset refid="dist.src.files"/>
1086       </zipfileset>
1087     </zip>
1088   </target>
1090   <target name="dist-snapshot" depends="jar">
1091     <jar destfile="${lib.dir}/jruby.jar" update="true">
1092       <fileset dir="${jruby.classes.dir}">
1093         <include name="org/jruby/jruby.properties"/>
1094       </fileset>
1095     </jar>
1096     <property name="jar-up-to-date" value="true"/>
1097     <antcall target="dist-bin">
1098       <param file="${jruby.classes.dir}/org/jruby/jruby.properties"/>
1099     </antcall>
1100   </target>
1102   <target name="dist-snapshot-install-stuff">
1103     <unzip dest="${snapshot.install.dir}" src="jruby-bin-${version.jruby}.zip"/>
1104     <chmod perm="755" file="${snapshot.install.dir}/jruby-${version.jruby}/bin/jruby"/>
1105     <exec executable="${snapshot.install.dir}/jruby-${version.jruby}/bin/jruby"
1106       dir="${snapshot.install.dir}/jruby-${version.jruby}">
1107       <arg value="-v"/>
1108       <arg value="-e"/>
1109       <arg value="system('rm -f ${snapshot.install.dir}/current &amp;&amp; ln -s ${snapshot.install.dir}/jruby-${version.jruby} ${snapshot.install.dir}/current'); puts 'Successfully installed snapshot'"/>
1110     </exec>
1111   </target>
1113   <target name="dist-snapshot-install" depends="dist-snapshot" if="snapshot.install.dir">
1114     <antcall target="dist-snapshot-install-stuff">
1115       <param file="${jruby.classes.dir}/org/jruby/jruby.properties"/>
1116     </antcall>
1117   </target>
1119   <target name="dist" depends="dist-bin,dist-src"/>
1121   <target name="dist-clean">
1122     <delete includeEmptyDirs="true" quiet="true">
1123       <fileset dir=".">
1124         <include name="jruby-*.tar.gz"/>
1125         <include name="jruby-*.zip"/>
1126       </fileset>
1127       <fileset dir="dist" includes="**/*"/>
1128     </delete>
1129   </target>
1131   <target name="clean" depends="init" description="Cleans almost everything, leaves downloaded specs">
1132     <delete dir="${build.dir}"/>
1133     <delete dir="${dist.dir}"/>
1134     <delete quiet="false">
1135         <fileset dir="${lib.dir}" includes="jruby*.jar"/>
1136     </delete>
1137     <delete dir="${api.docs.dir}"/>
1138     <delete dir="src_gen"/>
1139   </target>
1141   <target name="clean-all" depends="clean, clear-specs" description="Cleans everything, including downloaded specs">
1142   </target>
1144   <property name="nailgun.home" value="${basedir}/tool/nailgun"/>
1146   <target name="need-ng">
1147     <condition property="should.build.ng">
1148       <and>
1149         <os family="unix"/>
1150         <not><available file="${nailgun.home}/ng"/></not>
1151       </and>
1152     </condition>
1153   </target>
1155   <target name="build-ng" depends="need-ng" if="should.build.ng">
1156     <exec executable="make" dir="${nailgun.home}"/>
1157   </target>
1159   <target name="jruby-nailgun" depends="generate-method-classes,build-ng"
1160     description="Set up JRuby to be run with Nailgun (jruby-ng, jruby-ng-server)">
1161     <mkdir dir="${build.dir}/nailmain"/>
1162     <javac srcdir="${nailgun.home}/src/java" destdir="${build.dir}/nailmain"
1163       classpath="${nailgun.home}/nailgun-0.7.1.jar:${jruby.classes.dir}" debug="true"
1164       source="${javac.version}" target="${javac.version}"
1165       deprecation="true" encoding="UTF-8" />
1166     <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
1167       classpath="${build.lib.dir}/jarjar-1.0rc7.jar"/>
1168     <jarjar destfile="${nailgun.home}/jruby-nailgun.jar">
1169       <fileset dir="${jruby.classes.dir}">
1170         <exclude name="org/jruby/util/ant/**/*.class"/>
1171       </fileset>
1172       <fileset dir="${build.dir}/nailmain"/>
1173       <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
1174       <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
1175       <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
1176       <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
1177       <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
1178       <zipfileset src="${build.lib.dir}/bytelist-0.1.jar"/>
1179       <zipfileset src="${build.lib.dir}/jvyamlb-0.2.3.jar"/>
1180       <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
1181       <zipfileset src="${build.lib.dir}/joni.jar"/>
1182       <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
1183       <zipfileset src="${build.lib.dir}/jna.jar"/>
1184       <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
1185       <zipfileset src="${nailgun.home}/nailgun-0.7.1.jar"/>
1186       <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
1187       <manifest>
1188         <attribute name="Built-By" value="${user.name}"/>
1189         <attribute name="Main-Class" value="org.jruby.Main"/>
1190       </manifest>
1191     </jarjar>
1192   </target>
1193 </project>