Skip to content
This repository
tag: 1.1.6RC2
Fetching contributors…

Cannot retrieve contributors at this time

file 1356 lines (1204 sloc) 57.743 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
<?xml version="1.0" encoding="UTF-8"?>

<project basedir="." default="jar" name="JRuby">
  <description>JRuby is a pure Java implementation of a Ruby interpreter.</description>

  <property name="base.dir" location="${basedir}"/>

  <!-- First try to load machine-specific properties. -->
  <property file="build.properties"/>
  <!-- Load revision number for the ruby specs, in a known good state.
There should be no spec failures with such revision. -->
  <property file="rubyspecs.revision"/>

  <!-- And then load the defaults. It seems backwards to set defaults AFTER
setting local overrides, but that's how Ant works. -->
  <property file="default.build.properties"/>

  <path id="build.classpath">
    <fileset dir="${build.lib.dir}" includes="*.jar"/>
    <fileset dir="${lib.dir}" includes="bsf.jar"/>
  </path>

  <!-- directory that contains emma.jar and emma_ant.jar: -->
  <property name="emma.dir" value="${build.lib.dir}" />

  <path id="emma.classpath">
    <pathelement location="${emma.dir}/emma.jar" />
    <pathelement location="${emma.dir}/emma_ant.jar" />
  </path>

  <patternset id="java.src.pattern">
    <include name="**/*.java"/>
    <exclude unless="bsf.present" name="org/jruby/javasupport/bsf/**/*.java"/>
    <exclude unless="jdk1.4+" name="**/XmlAstMarshal.java"/>
    <exclude unless="jdk1.4+" name="**/AstPersistenceDelegates.java"/>
    <exclude unless="sun-misc-signal" name="**/SunSignalFacade.java"/>
  </patternset>

  <patternset id="ruby.src.pattern">
    <include name="**/*.rb"/>
  </patternset>
  
  <patternset id="other.src.pattern">
    <include name="**/*.properties"/>
  </patternset>
  
  <taskdef name="retro" classname="net.sourceforge.retroweaver.ant.RetroWeaverTask" classpathref="build.classpath"/>
  
  <import file="netbeans-ant.xml" optional="true"/>

  <!-- Initializes the build -->
  <target name="init">
    <xmlproperty file="build-config.xml" keepRoot="false" collapseAttributes="true"/>
    <tstamp><format property="build.date" pattern="yyyy-MM-dd"/></tstamp>
    <property environment="env"/>
    <property name="version.ruby" value="${version.ruby.major}.${version.ruby.minor}"/>
    <!-- if ruby.home is not set, use env var -->
    <condition property="ruby.home" value="${env.RUBY_HOME}">
      <not><isset property="ruby.home"/></not>
    </condition>
    <property name="rdoc.archive" value="docs/rdocs.tar.gz"/>
    <uptodate property="docsNotNeeded" srcfile="${rdoc.archive}" targetfile="${basedir}/share/ri/1.8/system/created.rid"/>
  </target>
  
  <target name="extract-rdocs" depends="init" unless="docsNotNeeded">
      <untar src="${rdoc.archive}" dest="${basedir}" compression="gzip"/>
      <touch file="${basedir}/share/ri/1.8/system/created.rid"/>
  </target>

  <!-- Creates the directories needed for building -->
  <target name="prepare" depends="extract-rdocs">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${classes.dir}"/>
    <mkdir dir="${jruby.classes.dir}"/>
    <mkdir dir="${test.classes.dir}"/>
    <mkdir dir="${test.results.dir}"/>
    <mkdir dir="${html.test.results.dir}"/>
    <mkdir dir="${docs.dir}"/>
    <mkdir dir="${api.docs.dir}"/>
  </target>

  <!-- Checks if specific libs and versions are avaiable -->
  <target name="check-for-optional-java4-packages"
          depends="init">
    <available property="jdk1.4+" classname="java.lang.CharSequence"/>
    <available property="jdk1.5+" classname="java.lang.StringBuilder"/>
    <available property="bsf.present" classname="org.apache.bsf.BSFManager"
               classpathref="build.classpath"/>
    <available property="junit.present" classname="junit.framework.TestCase"
               classpathref="build.classpath"/>
    <available property="cglib.present"
               classname="net.sf.cglib.reflect.FastClass"
               classpathref="build.classpath"/>
  </target>

  <!-- Checks if specific libs and versions are avaiable -->
  <target name="check-for-optional-packages" if="jdk1.5+"
          depends="check-for-optional-java4-packages">
    <available property="sun-misc-signal"
               classname="sun.misc.Signal"/>
  </target>

  <!-- Builds the Ant tasks that we need later on in the build -->
  <target name="compile-tasks" depends="prepare">
    <copy todir="${jruby.classes.dir}">
        <fileset dir="${src.dir}">
            <include name="**/*.rb"/>
        </fileset>
    </copy>
    <copy todir="${jruby.classes.dir}/builtin">
        <fileset dir="${lib.dir}/ruby/site_ruby/1.8/builtin">
            <include name="**/*.rb"/>
        </fileset>
    </copy>
    
    <tstamp>
        <format property="build.date" pattern="yyyy-MM-dd"/>
    </tstamp>
    
    <copy todir="${jruby.classes.dir}" overwrite="true">
        <fileset dir="${src.dir}">
            <include name="**/*.properties"/>
        </fileset>
        <filterset>
            <filter token="os.arch" value="${os.arch}"/>
            <filter token="java.specification.version" value="${java.specification.version}"/>
            <filter token="javac.version" value="${javac.version}"/>
            <filter token="build.date" value="${build.date}"/>
        </filterset>
    </copy>
  </target>

  <target name="compile-annotation-binder">
    <mkdir dir="${basedir}/src_gen"/>
        
    <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">
        <include name="org/jruby/anno/FrameField.java"/>
        <include name="org/jruby/anno/AnnotationBinder.java"/>
        <include name="org/jruby/anno/JRubyMethod.java"/>
        <include name="org/jruby/anno/FrameField.java"/>
        <include name="org/jruby/CompatVersion.java"/>
        <include name="org/jruby/runtime/Visibility.java"/>
        <include name="org/jruby/util/CodegenUtils.java"/>
    </javac>
  </target>

  <target name="compile-jruby" depends="compile-tasks, compile-annotation-binder, check-for-optional-packages">
    <!-- Generate binding logic ahead of time -->
    <apt factory="org.jruby.anno.AnnotationBinder" destdir="${jruby.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" deprecation="true" encoding="UTF-8">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <src path="${src.dir}"/>
      <patternset refid="java.src.pattern"/>
      <compilerarg line="-XDignore.symbol.file=true"/>
      <compilerarg line="-J-Xmx512M"/>
    </apt>
  </target>

  <target name="compile" depends="compile-jruby"
          description="Compile the source files for the project.">
  </target>

  <target name="generate-method-classes" depends="compile">
    <available file="src_gen/annotated_classes.txt" property="annotations.changed"/>
    <antcall target="_gmc_internal_"/>
  </target>
  
  <target name="_gmc_internal_" if="annotations.changed">
    <echo message="Generating invokers..."/>
    <java classname="org.jruby.anno.InvokerGenerator" fork="true" failonerror="true">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <!-- uncomment this line when building on a JVM with invokedynamic
<jvmarg line="-XX:+InvokeDynamic"/>
-->
      <arg value="src_gen/annotated_classes.txt"/>
      <arg value="${jruby.classes.dir}"/>
    </java>
    
    <echo message="Compiling populators..."/>
    <javac destdir="${jruby.classes.dir}" debug="true" source="${javac.version}" target="${javac.version}" deprecation="true" encoding="UTF-8">
       <classpath refid="build.classpath"/>
       <classpath path="${jruby.classes.dir}"/>
       <src path="src_gen"/>
       <patternset refid="java.src.pattern"/>
    </javac>
    
    <delete file="src_gen/annotated_classes.txt"/>
  </target>
  
  <target name="generate-unsafe" depends="compile">
      <available file="${jruby.classes.dir}/org/jruby/util/unsafe/GeneratedUnsafe.class" property="unsafe.not.needed"/>
      <antcall target="_gu_internal_"/>
  </target>
  
  <target name="_gu_internal_" unless="unsafe.not.needed">
    <echo message="Generating Unsafe impl..."/>
    <java classname="org.jruby.util.unsafe.UnsafeGenerator" fork="true" failonerror="true">
        <classpath refid="build.classpath"/>
        <classpath path="${jruby.classes.dir}"/>
        <!-- uncomment this line when building on a JVM with invokedynamic
<jvmarg line="-XX:+InvokeDynamic"/>
-->
        <arg value="org.jruby.util.unsafe"/>
        <arg value="${jruby.classes.dir}/org/jruby/util/unsafe"/>
    </java>
  </target>
  
  <target name="jar-jruby" depends="generate-method-classes, generate-unsafe" unless="jar-up-to-date">
      <!-- TODO: Unfortunate dependency on ruby executable, and ruby might
not be present on user's side, so we ignore errors caused by that. -->
      <exec executable="ruby" dir="${basedir}" failifexecutionfails="false" resultproperty="snapshot.result" errorproperty="snapshot.error">
        <arg value="tool/snapshot.rb"/>
        <arg value="${jruby.classes.dir}/org/jruby/jruby.properties"/>
      </exec>
            
      <jar destfile="${lib.dir}/jruby.jar" compress="false">
        <fileset dir="${jruby.classes.dir}"/>
        <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/bytelist-1.0.1.jar"/>
        <zipfileset src="${build.lib.dir}/constantine.jar"/>
        <zipfileset src="${build.lib.dir}/jvyamlb-0.2.5.jar"/>
        <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
        <zipfileset src="${build.lib.dir}/jcodings.jar"/>
        <zipfileset src="${build.lib.dir}/joni.jar"/>
        <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
        <zipfileset src="${build.lib.dir}/jna.jar"/>
        <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
        <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
        <manifest>
          <attribute name="Built-By" value="${user.name}"/>
          <attribute name="Main-Class" value="org.jruby.Main"/>
        </manifest>
      </jar>
  </target>
  
  <target name="jar-jruby-dist" depends="generate-method-classes, generate-unsafe" unless="jar-up-to-date">
      <!-- TODO: Unfortunate dependency on ruby executable, and ruby might
not be present on user's side, so we ignore errors caused by that. -->
      <exec executable="ruby" dir="${basedir}" failifexecutionfails="false" >
        <arg value="tool/snapshot.rb"/>
        <arg value="${jruby.classes.dir}/org/jruby/jruby.properties"/>
      </exec>
            
      <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc8.jar"/>
      <jarjar destfile="${lib.dir}/jruby.jar" compress="true">
        <fileset dir="${jruby.classes.dir}"/>
        <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/constantine.jar"/>
        <zipfileset src="${build.lib.dir}/bytelist-1.0.1.jar"/>
        <zipfileset src="${build.lib.dir}/jvyamlb-0.2.5.jar"/>
        <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
        <zipfileset src="${build.lib.dir}/jcodings.jar"/>
        <zipfileset src="${build.lib.dir}/joni.jar"/>
        <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
        <zipfileset src="${build.lib.dir}/jna.jar"/>
        <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
        <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
        <manifest>
          <attribute name="Built-By" value="${user.name}"/>
          <attribute name="Main-Class" value="org.jruby.Main"/>
        </manifest>
        <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
      </jarjar>
      <antcall target="_osgify-jruby_" />
  </target>

  <!-- Use Bnd to wrap the JAR generated by jarjar in above task -->
  <target name="_osgify-jruby_">
    <filter token="JRUBY_VERSION" value="${version.jruby}"/>
    <copy file="${basedir}/jruby.bnd.template" tofile="${build.dir}/jruby.bnd" filtering="true"/>
    <taskdef resource="aQute/bnd/ant/taskdef.properties"
      classpath="${build.lib.dir}/bnd-0.0.249.jar"/>
    <bndwrap definitions="${build.dir}" output="${lib.dir}">
      <fileset file="${lib.dir}/jruby.jar" />
    </bndwrap>
    <move file="${lib.dir}/jruby.jar$" tofile="${lib.dir}/jruby.jar"
      overwrite="true" />
  </target>

  <path id="lib.classpath">
    <pathelement location="${build.lib.dir}/retroweaver-rt-2.0.5.jar"/>
    <pathelement location="${build.lib.dir}/backport-util-concurrent.jar"/>
    <pathelement location="/usr/java/j2sdk1.4.2_16/jre/lib/rt.jar" />
    <pathelement location="${lib.dir}/bsf.jar" />
  </path>

  <target name="jar-1.4" depends="jar-jruby">
    <copy file="${lib.dir}/jruby.jar" tofile="${lib.dir}/jruby1.5.jar"/>
    <retro inputjar="${lib.dir}/jruby1.5.jar" outputjar="${lib.dir}/jruby-weaved.jar" target="1.4" failonerror="true" verify="true">
      <classpath>
        <path refid="lib.classpath"/>
        <pathelement location="${lib.dir}/jruby-weaved.jar" />
      </classpath>
    </retro>
    
      <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc8.jar"/>
      <jarjar destfile="${lib.dir}/jruby.jar">
        <zipfileset src="${lib.dir}/jruby-weaved.jar"/>
        <zipfileset src="${build.lib.dir}/retroweaver-rt-2.0.5.jar"/>
        <zipfileset src="${build.lib.dir}/backport-util-concurrent.jar"/>
        <rule pattern="edu.emory.mathcs.backport.**" result="jruby.backport.@1"/>
        <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
      </jarjar>
    <delete file="${lib.dir}/jruby-weaved.jar"/>
    <delete file="${lib.dir}/jruby1.5.jar"/>
  </target>

  <target name="jar-complete-1.4" depends="jar-complete">
    <copy file="${lib.dir}/jruby-complete.jar" tofile="${lib.dir}/jruby-complete1.5.jar"/>
    <retro inputjar="${lib.dir}/jruby-complete1.5.jar" outputjar="${lib.dir}/jruby-complete.jar" target="1.4" failonerror="false" verify="true">
      <classpath>
        <path refid="lib.classpath"/>
        <pathelement location="${lib.dir}/jruby-complete.jar" />
      </classpath>
    </retro>
    <delete file="${lib.dir}/jruby-complete1.5.jar"/>
  </target>

    <target name="jar-complete" depends="generate-method-classes, generate-unsafe" description="Create the 'complete' JRuby jar. Pass 'mainclass' and 'filename' to adjust.">
      <property name="mainclass" value="org.jruby.Main"/>
      <property name="filename" value="jruby-complete.jar"/>
      <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc8.jar"/>
      <property name="jar-complete-home" value="${build.dir}/jar-complete/META-INF/jruby.home"/>
      <mkdir dir="${jar-complete-home}"/>
      <copy todir="${jar-complete-home}">
        <fileset dir="${basedir}">
          <patternset refid="dist.bindir.files"/>
          <patternset refid="dist.lib.files"/>
        </fileset>
      </copy>
      <copy todir="${build.dir}/jar-complete">
        <fileset dir="lib/ruby/1.8" includes="**/*"/>
      </copy>

      <java classname="${mainclass}" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
        <classpath>
          <pathelement location="${jruby.classes.dir}"/>
          <pathelement location="${build.dir}/jar-complete"/>
          <path refid="build.classpath"/>
        </classpath>
        <sysproperty key="jruby.home" value="${build.dir}/jar-complete/META-INF/jruby.home"/>
        <arg value="--command"/>
        <arg value="maybe_install_gems"/>
        <arg value="rspec"/>
        <arg value="rake"/>
        <arg value="--no-ri"/>
        <arg value="--no-rdoc"/>
        <arg value="--env-shebang"/>
      </java>
      
      <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${build.lib.dir}/jarjar-1.0rc8.jar"/>
      <jarjar destfile="${lib.dir}/${filename}">
        <fileset dir="${jruby.classes.dir}"/>
        <fileset dir="${build.dir}/jar-complete">
          <exclude name="META-INF/jruby.home/lib/ruby/1.8/**"/>
        </fileset>
        <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
        <zipfileset src="${build.lib.dir}/bytelist-1.0.1.jar"/>
        <zipfileset src="${build.lib.dir}/constantine.jar"/>
        <zipfileset src="${build.lib.dir}/jvyamlb-0.2.5.jar"/>
        <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
        <zipfileset src="${build.lib.dir}/jcodings.jar"/>
        <zipfileset src="${build.lib.dir}/joni.jar"/>
        <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
        <zipfileset src="${build.lib.dir}/jna.jar"/>
        <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
        <zipfileset src="${build.lib.dir}/dynalang-0.3.jar"/>
        <manifest>
          <attribute name="Built-By" value="${user.name}"/>
          <attribute name="Main-Class" value="${mainclass}"/>
        </manifest>
        <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
      </jarjar>
    </target>

    <target name="jar-console" depends="generate-method-classes" description="Create the jruby graphical console jar">
          <antcall target="jar-complete">
              <param name="mainclass" value="org.jruby.demo.IRBConsole"/>
              <param name="filename" value="jruby-console.jar"/>
          </antcall>
    </target>

  <target name="jar" depends="init" description="Create the jruby.jar file">
    <antcall target="jar-jruby" inheritall="true"/>
  </target>
  <target name="jar-dist" depends="init" description="Create the jruby.jar file for distribution. This version uses JarJar Links to rewrite some packages.">
    <antcall target="jar-jruby-dist" inheritall="true"/>
  </target>

  <target name="compile-test" depends="jar" description="Compile the unit tests">
    <javac destdir="${test.classes.dir}" deprecation="true" debug="true"
           source="${javac.version}">
      <classpath>
        <path refid="build.classpath"/>
        <pathelement path="${jruby.classes.dir}"/>
        <pathelement path="${lib.dir}/jruby.jar"/>
      </classpath>
      <src path="${test.dir}"/>
      <src path="${spec.dir}"/>
      <patternset refid="java.src.pattern"/>
    </javac>
  </target>

  <target name="copy-test-files" depends="compile-test"
    description="Make tests fails available as resources">
    <copy todir="${test.classes.dir}">
      <fileset dir="${test.dir}" includes="org/**/*.rb"/>
    </copy>
  </target>

  <target name="install-gems">
    <property name="jruby.home" value="${basedir}"/>
    <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="jruby.home" value="${jruby.home}"/>
      <arg value="--command"/>
      <arg value="maybe_install_gems"/>
      <arg value="rspec"/>
      <arg value="rake"/>
      <arg value="--env-shebang"/>
    </java>
  </target>

  <target name="install-build-gems" depends="install-gems">
    <property name="jruby.home" value="${basedir}"/>
    <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="jruby.home" value="${jruby.home}"/>
      <arg value="--command"/>
      <arg value="maybe_install_gems"/>
      <arg value="mocha"/>
      <arg value="--env-shebang"/>
    </java>
  </target>
  
  <target name="compile-stdlib" unless="test">
    <copy todir="${build.dir}/stdlib">
        <fileset dir="${basedir}/lib/ruby/1.8">
          <include name="**/*.rb"/>
        </fileset>
    </copy>
    <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true" dir="${build.dir}/stdlib">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="jruby.home" value="${basedir}"/>
      <sysproperty key="jruby.objectspace.enabled" value="true"/>
      <jvmarg value="-ea"/>
      
      <arg value="-I"/>
      <arg value="bin/"/>
      <arg value="-S"/>
      <arg value="jrubyc"/>
      <arg line="."/>
    </java>
  </target>

  <target name="emma" description="turns on EMMA instrumentation/reporting" >
    <available property="emma.present"
               classname="com.vladium.app.IAppVersion"
               classpathref="emma.classpath"/>
    <taskdef resource="emma_ant.properties" classpathref="emma.classpath" />
  
    <property name="emma.enabled" value="true" />

    <path id="classes_to_instrument" >
      <pathelement location="${jruby.classes.dir}" />
    </path>
  </target>

  <target name="instrument" if="emma.present">
    <emma enabled="${emma.enabled}" >
      <instr instrpathref="classes_to_instrument"
             destdir="${jruby.instrumented.classes.dir}"
             metadatafile="${test.results.dir}/metadata.emma"
         merge="false" />
    </emma>
  </target>

  <target name="coverage-report" if="emma.present">
    <emma enabled="${emma.enabled}" >
      <report sourcepath="${src.dir}" >
        <fileset dir="${test.results.dir}" >
      <include name="*.emma" />
        </fileset>
        <html outfile="${html.test.coverage.results.dir}/coverage.html" />
      </report>
    </emma>
  </target>

  <target name="test" depends="
copy-test-files,
instrument,
run-junit-compiled,
test-security-manager,
test-rake-targets,
coverage-report"
    description="Runs unit tests.">
  </target>

  <target name="test-compiled" depends="copy-test-files,run-junit-compiled,run-junit-precompiled"/>
  <target name="test-compiled-1.9" depends="copy-test-files,run-junit-compiled-1.9,run-junit-precompiled-1.9"/>
  <target name="test-interpreted" depends="copy-test-files,run-junit-interpreted,test-interpreted-1.9"/>
  <target name="test-interpreted-1.9" depends="copy-test-files,run-junit-interpreted-1.9"/>
  <target name="test-reflected" depends="copy-test-files,run-junit-reflected-compiled,run-junit-reflected-precompiled,run-junit-reflected-interpreted"/>
  <target name="test-threadpool" depends="copy-test-files,run-junit-compiled-threadpool,run-junit-precompiled-threadpool,run-junit-interpreted-threadpool"/>
  
  <target name="test-all" depends="
copy-test-files,
instrument,
test-security-manager,
run-junit-interpreted,
run-junit-compiled,
run-junit-precompiled,
run-junit-interpreted-1.9,
run-junit-compiled-1.9,
run-junit-reflected-precompiled,
run-junit-interpreted-threadpool,
compile-stdlib,
coverage-report"
description="Runs unit tests in all modes."/>

  <target name="weave-tests" description="weave the test classes">
    <retro srcdir="${test.classes.dir}" target="1.4" failonerror="true" verify="true">
      <classpath>
        <path refid="lib.classpath"/>
        <pathelement location="${lib.dir}/jruby.jar" />
        <pathelement location="${build.lib.dir}/junit.jar" />
        <pathelement location="${build.lib.dir}/asm-3.0.jar" />
        <pathelement location="${test.classes.dir}" />
      </classpath>
    </retro>
  </target>
 
  <target name="test-1.4" depends="
copy-test-files,
jar-1.4,
weave-tests,
instrument,
run-junit-compiled,
run-junit-compiled-1.9,
coverage-report"
   description="Runs unit tests with weaved jruby classes.">
  </target>

  <target name="test-all-1.4" depends="
copy-test-files,
jar-1.4,
weave-tests,
instrument,
run-junit-interpreted,
run-junit-compiled,
run-junit-precompiled,
run-junit-interpreted-1.9,
run-junit-compiled-1.9,
run-junit-precompiled-1.9,
run-junit-reflected-precompiled,
run-junit-precompiled-threadpool,
compile-stdlib,
coverage-report"
description="Runs unit tests in all modes with weaved jruby classes."/>

  <!-- All junit permutations for 1.8 and 1.9 support -->
  <target name="run-junit-interpreted"><run-junit-1.8/></target>
  <target name="run-junit-interpreted-1.9"><run-junit-1.9/></target>
  <target name="run-junit-reflected-interpreted"><run-junit-1.8 reflection="true"/></target>
  <target name="run-junit-reflected-interpreted-1.9"><run-junit-1.9 reflection="true"/></target>
  <target name="run-junit-compiled"><run-junit-1.8 compile.mode="JIT" jit.threshold="0"/></target>
  <target name="run-junit-compiled-1.9"><run-junit-1.9 compile.mode="JIT" jit.threshold="0"/></target>
  <target name="run-junit-reflected-compiled"><run-junit-1.8 compile.mode="JIT" jit.threshold="0" reflection="true"/></target>
  <target name="run-junit-reflected-compiled-1.9"><run-junit-1.9 compile.mode="JIT" jit.threshold="0" reflection="true"/></target>
  <target name="run-junit-precompiled"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0"/></target>
  <target name="run-junit-precompiled-1.9"><run-junit-1.9 compile.mode="FORCE" jit.threshold="0"/></target>
  <target name="run-junit-reflected-precompiled"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0" reflection="true"/></target>
  <target name="run-junit-reflected-precompiled-1.9"><run-junit-1.9 compile.mode="FORCE" jit.threshold="0" reflection="true"/></target>
  <target name="run-junit-threadpool" depends="run-junit-interpreted-threadpool,run-junit-compiled-threadpool"/>
  <target name="run-junit-interpreted-threadpool"><run-junit-1.8 thread.pooling="true"/></target>
  <target name="run-junit-compiled-threadpool"><run-junit-1.8 compile.mode="JIT" jit.threshold="0" thread.pooling="true"/></target>
  <target name="run-junit-precompiled-threadpool"><run-junit-1.8 compile.mode="FORCE" jit.threshold="0" thread.pooling="true"/></target>
  
  <path id="test.class.path">
    <pathelement location="${jruby.instrumented.classes.dir}" />
    <fileset dir="${build.lib.dir}" includes="*.jar">
      <exclude name="jcodings.jar"/>
      <exclude name="joni.jar"/>
    </fileset>
    <pathelement path="${lib.dir}/bsf.jar"/>
    <pathelement path="${java.class.path}"/>
    <pathelement path="${lib.dir}/jruby.jar"/>
    <pathelement location="${test.classes.dir}"/>
    <pathelement path="${test.dir}/requireTest.jar"/>
    <pathelement location="${test.dir}"/>
  </path>

  <macrodef name="run-junit">
    <attribute name="jruby.version" default="ruby1_8"/>
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="jit.max" default="-1"/>
    <attribute name="objectspace.enabled" default="true"/>
    <attribute name="thread.pooling" default="false"/>
    <attribute name="reflection" default="false"/>
    <element name="junit-tests"/>
    <sequential>
      <echo message="compile=@{compile.mode}, jit.threshold=@{jit.threshold}, jit.max=@{jit.max}, objectspace=@{objectspace.enabled} threadpool=@{thread.pooling} reflection=@{reflection} version=@{jruby.version}"/>
      <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" classpath="${build.lib.dir}/junit.jar"/>

      <junit jvm="${jruby.test.jvm}" fork="yes" forkMode="once" haltonfailure="true" dir="${basedir}" maxmemory="${jruby.test.memory}" showoutput="true" timeout="1800000">
<classpath refid="test.class.path"/>
      
<sysproperty key="java.awt.headless" value="true"/>
<sysproperty key="jruby.home" value="${basedir}"/>
<sysproperty key="jruby.lib" value="${lib.dir}"/>
<sysproperty key="jruby.compile.mode" value="@{compile.mode}"/>
<sysproperty key="jruby.jit.threshold" value="@{jit.threshold}"/>
<sysproperty key="jruby.jit.max" value="@{jit.max}"/>
<sysproperty key="jruby.compat.version" value="@{jruby.version}"/>
<sysproperty key="jruby.objectspace.enabled" value="@{objectspace.enabled}"/>
<sysproperty key="jruby.thread.pool.enabled" value="@{thread.pooling}"/>
<sysproperty key="jruby.reflection" value="@{reflection}"/>
<sysproperty key="jruby.jit.logging.verbose" value="true"/>
<sysproperty key="jruby.compile.lazyHandles" value="true"/>
<sysproperty key="emma.coverage.out.file" value="${test.results.dir}/coverage.emma" />
<sysproperty key="emma.coverage.out.merge" value="true" />

<jvmarg value="-ea"/>
        
        <!-- force client VM to improve test run times -->
        <jvmarg value="-client"/>

        <!-- set a larger max permgen, since the tests load a lot of bytecode -->
        <jvmarg value="-XX:MaxPermSize=128M"/>

<formatter type="xml"/>
<formatter type="brief" usefile="false" />

<junit-tests/>
      </junit>

      <junitreport todir="${test.results.dir}">
<fileset dir="${test.results.dir}" includes="TEST-*.xml"/>
<report format="frames" todir="${html.test.results.dir}"/>
      </junitreport>
    </sequential>
  </macrodef>
  
  <!-- runs junit tests for 1.8 functionality -->
  <macrodef name="run-junit-1.8">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="reflection" default="false"/>
    <attribute name="thread.pooling" default="false"/>

    <sequential>
      <run-junit compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}" reflection="@{reflection}" thread.pooling="@{thread.pooling}">
<junit-tests>
<test name="${test}" if="test"/>
<test name="org.jruby.test.ScriptTestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.BFTSTestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.JRubyTestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.MRITestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.RubiconTestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.RubyTestTestSuite" todir="${test.results.dir}" unless="test"/>
<test name="org.jruby.test.MainTestSuite" todir="${test.results.dir}" unless="test"/>
</junit-tests>
      </run-junit>
    </sequential>
  </macrodef>

  <macrodef name="run-junit-1.9">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="reflection" default="false"/>
    <attribute name="thread.pooling" default="false"/>

    <sequential>
      <run-junit objectspace.enabled="false" jruby.version="ruby1_9" compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}" reflection="@{reflection}" thread.pooling="@{thread.pooling}">
<junit-tests>
<test name="${test}" if="test"/>
<test name="org.jruby.test.Ruby1_9TestSuite" todir="${test.results.dir}" unless="test"/>
</junit-tests>
      </run-junit>
    </sequential>
  </macrodef>

  <target name="test-security-manager">
    <java classname="org.jruby.Main" fork="true" failonerror="true">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="java.security.manager" value=""/>
      <sysproperty key="java.security.policy" value="file:test/restricted.policy"/>
      <arg value="-e"/>
      <arg value="puts 'Restricted policy looks ok'"/>
    </java>
  </target>
  
  <target name="test-rake-targets" depends="install-gems">
      <run-rake rake.targets="spec:ji:quiet"/>
      <run-rake rake.targets="test:tracing" jruby.args="--debug"/>
      <run-rake rake.targets="spec:compiler"/>
      <run-rake rake.targets="spec:ffi"/>
  </target>

  <macrodef name="run-rake">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="jit.max" default="-1"/>
    <attribute name="objectspace.enabled" default="true"/>
    <attribute name="thread.pooling" default="false"/>
    <attribute name="reflection" default="false"/>
    <attribute name="inproc" default="true"/>
    <attribute name="jruby.args" default=""/>
    <attribute name="rake.targets"/>

    <sequential>
      <echo message="compile=@{compile.mode}, threshold=@{jit.threshold}, objectspace=@{objectspace.enabled} threadpool=@{thread.pooling} reflection=@{reflection}"/>

      <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true" dir="${base.dir}">
        <classpath refid="build.classpath"/>
        <classpath path="${jruby.classes.dir}"/>

        <jvmarg value="-ea"/>

        <sysproperty key="jruby.home" value="${basedir}"/>
        <sysproperty key="jruby.launch.inproc" value="false"/>

        <!-- properties tweaked for individual runs -->
        <sysproperty key="jruby.compile.mode" value="@{compile.mode}"/>
        <sysproperty key="jruby.jit.threshold" value="@{jit.threshold}"/>
        <sysproperty key="jruby.jit.max" value="@{jit.max}"/>
        <sysproperty key="jruby.objectspace.enabled" value="@{objectspace.enabled}"/>
        <sysproperty key="jruby.thread.pool.enabled" value="@{thread.pooling}"/>
        <sysproperty key="jruby.reflection" value="@{reflection}"/>
        <sysproperty key="jruby.launch.inproc" value="@{inproc}"/>

        <arg line="@{jruby.args}"/>
        <arg line="${base.dir}/bin/rake"/>
        <arg line="@{rake.targets}"/>
      </java>
    </sequential>
  </macrodef>

  <target name="detect-stable-specs-need-update">
    <property file="${spec.dir}/rubyspecs.current.revision"/>
    <condition property="stable-specs-need-update">
      <or>
        <not> <available file="${rubyspec.dir}"/> </not>
        <not> <available file="${mspec.dir}"/> </not>
        <not>
          <equals
            arg1="${rubyspecs.revision}"
            arg2="${rubyspecs.current.revision}"/>
        </not>
        <not>
          <equals
            arg1="${mspec.revision}"
            arg2="${mspec.current.revision}"/>
        </not>
      </or>
    </condition>
  </target>
  
  <target name="fetch-stable-specs" depends="prepare, detect-stable-specs-need-update" if="stable-specs-need-update">
    <echo message="Downloading stable mspec..."/>
    <exec command="wget">
        <arg value="http://github.com/rubyspec/mspec/zipball/${mspec.revision}"/>
        <arg line="-O ${build.dir}/rubyspec-mspec.zip"/>
    </exec>
    <echo message="Downloading stable rubyspecs..."/>
    <exec command="wget">
        <arg value="http://github.com/rubyspec/rubyspec/zipball/${rubyspecs.revision}"/>
        <arg line="-O ${build.dir}/rubyspec-rubyspec.zip"/>
    </exec>

    <!-- Wipe the old mspec/rubyspecs, if any, and exctract new ones -->

    <delete dir="${mspec.dir}"/>
    <mkdir dir="${mspec.dir}"/>
    <unzip src="${build.dir}/rubyspec-mspec.zip" dest="${mspec.dir}">
      <globmapper from="rubyspec-mspec-${mspec.revision}/*" to="*"/>
    </unzip>
    <chmod file="${mspec.dir}/bin/mspec" perm="755"/>

    <delete dir="${rubyspec.dir}"/>
    <mkdir dir="${rubyspec.dir}"/>
    <unzip src="${build.dir}/rubyspec-rubyspec.zip" dest="${rubyspec.dir}">
        <globmapper from="rubyspec-rubyspec-${rubyspecs.revision}/*" to="*"/>
    </unzip>

   <!-- Write down the revision of downloaded specs -->
    <propertyfile file="${spec.dir}/rubyspecs.current.revision" comment="Revision of downloaded specs.">
      <entry key="rubyspecs.current.revision" value="${rubyspecs.revision}"/>
      <entry key="mspec.current.revision" value="${mspec.revision}"/>
    </propertyfile>
  </target>

  <!-- NOTE: There are two different rubyspecs versions: stable and unstable.
Stable ones are in known good state, and all known JRuby failures are excluded.
The idea is that the stable specs runs must be clean, no failures.
Unstable specs are the very latest, and might have new failures.

Stable specs are downloaded as a snapshot of particular revision.
Unstable specs are downloaded as a git repo. -->

  <!-- stable specs -->
  <target name="spec" depends="fetch-stable-specs, run-specs"
      description="Runs known good version of rubyspecs."/>
  <target name="spec-short" depends="fetch-stable-specs, run-specs-short"
      description="Runs known good version of rubyspecs, excluding library specs."/>
  <target name="spec-ci" depends="fetch-stable-specs, run-specs-ci"
      description="Runs known good version of rubyspecs interpreted, compiled, and precompile, excluding library specs."/>
  <target name="spec-all" depends="fetch-stable-specs, run-specs-all"
      description="Runs known good version of rubyspecs without exclusions."/>
  <target name="spec-all-interpreted" depends="fetch-stable-specs, run-specs-all-interpreted"
      description="Runs known good version of rubyspecs without exclusions."/>

  <!-- latest, unstable specs -->
  <target name="spec-latest" depends="fetch-specs, run-specs"
      description="Runs the very latest rubyspecs."/>
  <target name="spec-latest-all" depends="fetch-specs, run-specs-all"
description="Runs the very latest rubyspecs without exclusions."/>
  
  <target name="fetch-specs">
      <condition property="rubyspec-repo-exists">
          <available file="${rubyspec.dir}/.git"/>
      </condition>
      
      <antcall target="do-fetch-specs"/>
      <antcall target="do-update-specs"/>
  </target>

  <target name="do-fetch-specs" unless="rubyspec-repo-exists">
      <!-- Stable specs might exist, so delete them -->
      <antcall target="clear-specs" inheritall="false"/>

      <echo message="Cloning rubyspec repo to: ${rubyspec.dir}"/>
      <exec dir="${spec.dir}" executable="git">
          <arg value="clone"/>
          <arg value="--depth"/><arg value="1"/>
          <arg value="git://github.com/rubyspec/rubyspec.git"/>
          <arg value="${rubyspec.dir}"/>
      </exec>

      <echo message="Cloning mspec repo to: ${mspec.dir}"/>
      <exec dir="${spec.dir}" executable="git">
                <arg value="clone"/>
                <arg value="--depth"/><arg value="1"/>
                <arg value="git://github.com/rubyspec/mspec.git"/>
                <arg value="${mspec.dir}"/>
      </exec>
  </target>

  <target name="do-update-specs" if="rubyspec-repo-exists">
      <echo message="Updading rubyspec repo -- ${rubyspec.dir}"/>
      <exec dir="${rubyspec.dir}" executable="git">
        <arg value="pull"/>
      </exec>
      <echo message="Updading mspec repo -- ${mspec.dir}"/>
      <exec dir="${mspec.dir}" executable="git">
        <arg value="pull"/>
      </exec>
  </target>

  <target name="clear-specs">
      <delete dir="${rubyspec.dir}"/>
      <delete dir="${mspec.dir}"/>
      <delete file="${build.dir}/rubyspec.tgz"/>
      <delete file="${build.dir}/mspec.tgz"/>
      <delete file="${spec.dir}/rubyspecs.current.revision"/>
  </target>

  <target name="run-specs" depends="run-specs-precompiled, run-specs-compiled, run-specs-interpreted, jar">
    <condition property="spec.status.combined.OK">
      <and>
        <equals arg1="${spec.status.PRECOMPILED}" arg2="0"/>
        <equals arg1="${spec.status.COMPILED}" arg2="0"/>
        <equals arg1="${spec.status.INTERPRETED}" arg2="0"/>
      </and>
    </condition>
    <fail message="RubySpecs FAILED" unless="spec.status.combined.OK"/>
  </target>

  <target name="run-specs-short" depends="run-specs-compiled-short, jar">
    <condition property="spec.status.combined.OK">
      <and>
        <equals arg1="${spec.status.COMPILED}" arg2="0"/>
      </and>
    </condition>
    <fail message="RubySpecs FAILED" unless="spec.status.combined.OK"/>
  </target>

  <target name="run-specs-ci" depends="run-specs-compiled-short, run-specs-interpreted-short, run-specs-precompiled-short, jar">
    <condition property="spec.status.combined.OK">
      <and>
        <equals arg1="${spec.status.PRECOMPILED}" arg2="0"/>
        <equals arg1="${spec.status.COMPILED}" arg2="0"/>
        <equals arg1="${spec.status.INTERPRETED}" arg2="0"/>
      </and>
    </condition>
    <fail message="RubySpecs FAILED" unless="spec.status.combined.OK"/>
  </target>

  <target name="run-specs-all" depends="jar"><antcall target="run-specs-all-precompiled"/></target>

  <target name="run-specs-compiled" depends="jar">
    <_run_specs_internal mode.name="COMPILED" compile.mode="JIT" jit.threshold="0"/>
  </target>
  <target name="run-specs-precompiled" depends="jar">
    <_run_specs_internal mode.name="PRECOMPILED" compile.mode="FORCE" jit.threshold="0"/>
  </target>
  <target name="run-specs-interpreted" depends="jar">
    <_run_specs_internal mode.name="INTERPRETED" compile.mode="OFF"/>
  </target>
  
  <target name="run-specs-compiled-short" depends="jar">
    <_run_specs_internal mode.name="COMPILED" compile.mode="JIT" jit.threshold="0" spec.config="${spec.dir}/no-library.mspec"/>
  </target>
  <target name="run-specs-precompiled-short" depends="jar">
    <_run_specs_internal mode.name="PRECOMPILED" compile.mode="FORCE" jit.threshold="0" spec.config="${spec.dir}/no-library.mspec"/>
  </target>
  <target name="run-specs-interpreted-short" depends="jar">
    <_run_specs_internal mode.name="INTERPRETED" compile.mode="OFF" spec.config="${spec.dir}/no-library.mspec"/>
  </target>

  <target name="run-specs-all-interpreted"><_run_specs_all_internal compile.mode="OFF"/></target>
  <target name="run-specs-all-precompiled"><_run_specs_all_internal compile.mode="FORCE" jit.threshold="0"/></target>

  
  <target name="update-excludes">
    <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" dir="${spec.dir}">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="jruby.home" value="${basedir}"/>
      <sysproperty key="jruby.launch.inproc" value="false"/>
      
      <arg line="${mspec.dir}/bin/mspec tag"/>
      <arg line="--add fails --fail"/>
      <arg line="-B ${spec.dir}/default.mspec"/>
    </java>
  </target>

  <target name="spec-show-excludes" depends="prepare"
    description="Prints out all currently excluded rubyspecs.">

    <available property="mspec-available"
      file="${mspec.dir}/bin/mspec"/>
    <fail unless="mspec-available"
      message="No rubyspecs found. Download them via 'ant spec'."/>

    <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" dir="${spec.dir}">
      <classpath refid="build.classpath"/>
      <classpath path="${jruby.classes.dir}"/>
      <sysproperty key="jruby.home" value="${basedir}"/>
      <sysproperty key="jruby.launch.inproc" value="false"/>
      <arg line="${mspec.dir}/bin/mspec"/>
      <arg line="-f s -g fails --dry-run"/>
      <arg line="-B ${spec.dir}/default.mspec"/>
      <arg value="${rubyspec.dir}/1.8"/>
    </java>
  </target>

  <macrodef name="run-specs">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="jit.max" default="-1"/>
    <attribute name="objectspace.enabled" default="true"/>
    <attribute name="thread.pooling" default="false"/>
    <attribute name="reflection" default="false"/>
    <attribute name="mode.name"/>
    <attribute name="spec.config"/>

    <sequential>
      <echo message="compile=@{compile.mode}, threshold=@{jit.threshold}, objectspace=@{objectspace.enabled} threadpool=@{thread.pooling} reflection=@{reflection}"/>
    
      <java classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="false" resultproperty="spec.status.@{mode.name}" dir="${base.dir}">
<classpath refid="build.classpath"/>
<classpath path="${jruby.classes.dir}"/>

<jvmarg value="-ea"/>

<sysproperty key="jruby.home" value="${basedir}"/>
<sysproperty key="jruby.launch.inproc" value="false"/>
      
<!-- properties tweaked for individual runs -->
<sysproperty key="jruby.compile.mode" value="@{compile.mode}"/>
<sysproperty key="jruby.jit.threshold" value="@{jit.threshold}"/>
<sysproperty key="jruby.jit.max" value="@{jit.max}"/>
<sysproperty key="jruby.objectspace.enabled" value="@{objectspace.enabled}"/>
<sysproperty key="jruby.thread.pool.enabled" value="@{thread.pooling}"/>
<sysproperty key="jruby.reflection" value="@{reflection}"/>

<arg line="${mspec.dir}/bin/mspec ci"/>
<arg line="-T -J-ea"/>
<arg line="-T -J-Djruby.launch.inproc=false"/>
<arg line="-T -J-Djruby.compile.mode=@{compile.mode}"/>
<arg line="-T -J-Djruby.jit.threshold=@{jit.threshold}"/>
<arg line="-T -J-Djruby.jit.max=@{jit.max}"/>
<arg line="-T -J-Djruby.objectspace.enabled=@{objectspace.enabled}"/>
<arg line="-T -J-Djruby.thread.pool.enabled=@{thread.pooling}"/>
<arg line="-T -J-Djruby.reflection=@{reflection}"/>
<arg line="-f m"/>
<arg line="-B @{spec.config}"/>
      </java>
    </sequential>
  </macrodef>

  <macrodef name="_run_specs_internal">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>
    <attribute name="mode.name"/>
    <attribute name="spec.config" default="${spec.dir}/default.mspec"/>

    <sequential>
      <echo message="Excludes: ${spec.tags.dir}"/>
      <run-specs mode.name="@{mode.name}"
        compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}"
        spec.config="@{spec.config}"/>
    </sequential>
  </macrodef>

  <macrodef name="_run_specs_all_internal">
    <attribute name="compile.mode" default="OFF"/>
    <attribute name="jit.threshold" default="20"/>

    <sequential>
      <run-specs compile.mode="@{compile.mode}" jit.threshold="@{jit.threshold}"/>
    </sequential>
  </macrodef>

  <macrodef name="fixEOLs">
    <sequential>
      <fixcrlf srcdir="dist/bin" excludes="*.bat" eol="lf"/>
      <fixcrlf srcdir="dist/bin" includes="*.bat" eol="crlf"/>
    </sequential>
  </macrodef>

  <target name="create-apidocs" depends="prepare"
          description="Creates the Java API docs">
    <javadoc destdir="${api.docs.dir}" author="true" version="true" use="true"
             windowtitle="JRuby API" source="${javac.version}" useexternalfile="true">
      <fileset dir="${src.dir}">
        <include name="**/*.java"/>
      </fileset>
      <fileset dir="${test.dir}">
    <include name="**/*.java"/>
      </fileset>
      <doctitle><![CDATA[<h1>JRuby</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2002-2007 JRuby Team. All Rights Reserved.</i>]]></bottom>
    </javadoc>
  </target>

  <patternset id="dist.bindir.files">
    <include name="bin/*jruby*"/>
    <include name="bin/*gem*"/>
    <include name="bin/*ri*"/>
    <include name="bin/*rdoc*"/>
    <include name="bin/*jirb*"/>
    <include name="bin/generate_yaml_index.rb"/>
    <include name="bin/testrb"/>
  </patternset>

  <patternset id="dist.lib.files">
    <include name="lib/ruby/1.8/**"/>
    <include name="lib/ruby/site_ruby/1.8/**"/>
    <include name="lib/ruby/gems/1.8/specifications/sources-0.0.1.gemspec"/>
    <include name="lib/ruby/gems/1.8/gems/sources-0.0.1/**"/>
  </patternset>

  <patternset id="dist.files">
    <include name="lib/*"/>
    <include name="samples/**"/>
    <include name="docs/**"/>
    <include name="COPYING*"/>
    <include name="README"/>
    <exclude name="lib/ruby/**"/>
  </patternset>

  <patternset id="dist.bin.files">
    <patternset refid="dist.files"/>
    <exclude name="lib/emma.jar"/>
    <exclude name="lib/emma_ant.jar"/>
    <exclude name="lib/junit.jar"/>
    <exclude name="lib/jarjar-1.0rc8.jar"/>
    <exclude name="docs/rdocs.tar.gz"/>
    <exclude name="bench/**"/>
    <include name="share/**"/>
  </patternset>

  <patternset id="dist.src.files">
    <patternset refid="dist.files"/>
    <exclude name="share/**"/>
    <include name="bench/**"/>
    <include name="src/**"/>
    <include name="test/**"/>
    <include name="spec/**"/>
    <include name="tool/**"/>
    <include name="build_lib/**"/>
    <include name="Rakefile"/>
    <include name="build.xml"/>
    <include name="build-config.xml"/>
    <include name="nbproject/*"/>
    <include name=".project"/>
    <include name=".classpath"/>
    <include name="default.build.properties"/>
    <include name="jruby.bnd.template"/>
    <exclude name="lib/jruby.jar"/>
  </patternset>
  <target name="dist-bin" depends="jar-dist">
    <mkdir dir="dist"/>
    <copy todir="dist">
      <fileset dir="${basedir}">
        <patternset refid="dist.bindir.files"/>
        <patternset refid="dist.lib.files"/>
      </fileset>
    </copy>
    <mkdir dir="dist/lib/native"/>
    <unzip src="build_lib/jna.jar" dest="dist/lib/native">
        <patternset>
            <include name="**/libjnidispatch.*"/>
        </patternset>
        <mapper>
            <filtermapper>
                <replacestring from="com/sun/jna" to="."/>
            </filtermapper>
        </mapper>
    </unzip>
    <fixEOLs/>
    <antcall target="install-gems">
      <param name="jruby.home" value="dist"/>
    </antcall>
    <tar destfile="jruby-bin-${version.jruby}.tar.gz" compression="gzip">
      <tarfileset dir="dist" mode="755" prefix="jruby-${version.jruby}">
        <include name="bin/**"/>
      </tarfileset>
      <tarfileset dir="dist" prefix="jruby-${version.jruby}">
        <include name="lib/**"/>
      </tarfileset>
      <tarfileset dir="${basedir}" prefix="jruby-${version.jruby}">
        <patternset refid="dist.bin.files"/>
      </tarfileset>
    </tar>
    <zip destfile="jruby-bin-${version.jruby}.zip">
      <zipfileset dir="dist" filemode="755" prefix="jruby-${version.jruby}">
        <include name="bin/**"/>
      </zipfileset>
      <zipfileset dir="dist" prefix="jruby-${version.jruby}">
        <include name="lib/**"/>
      </zipfileset>
      <zipfileset dir="${basedir}" prefix="jruby-${version.jruby}">
        <patternset refid="dist.bin.files"/>
      </zipfileset>
    </zip>
  </target>

  <target name="dist-src" depends="jar">
    <mkdir dir="dist"/>
    <copy todir="dist">
      <fileset dir="${basedir}">
        <patternset refid="dist.bindir.files"/>
        <patternset refid="dist.lib.files"/>
      </fileset>
    </copy>
    <antcall target="install-gems">
      <param name="jruby.home" value="dist"/>
    </antcall>
    <fixEOLs/>
    <tar destfile="jruby-src-${version.jruby}.tar.gz" compression="gzip">
      <tarfileset dir="dist" mode="755" prefix="jruby-${version.jruby}">
        <include name="bin/**"/>
      </tarfileset>
      <tarfileset dir="dist" prefix="jruby-${version.jruby}">
        <include name="lib/**"/>
      </tarfileset>
      <tarfileset dir="${basedir}" prefix="jruby-${version.jruby}">
        <patternset refid="dist.src.files"/>
      </tarfileset>
    </tar>
    <zip destfile="jruby-src-${version.jruby}.zip">
      <zipfileset dir="dist" filemode="755" prefix="jruby-${version.jruby}">
        <include name="bin/**"/>
      </zipfileset>
      <zipfileset dir="dist" prefix="jruby-${version.jruby}">
        <include name="lib/**"/>
      </zipfileset>
      <zipfileset dir="${basedir}" prefix="jruby-${version.jruby}">
        <patternset refid="dist.src.files"/>
      </zipfileset>
    </zip>
  </target>

  <target name="dist-snapshot" depends="jar">
    <jar destfile="${lib.dir}/jruby.jar" update="true">
      <fileset dir="${jruby.classes.dir}">
        <include name="org/jruby/jruby.properties"/>
      </fileset>
    </jar>
    <property name="jar-up-to-date" value="true"/>
    <antcall target="dist-bin">
      <param file="${jruby.classes.dir}/org/jruby/jruby.properties"/>
    </antcall>
  </target>

  <target name="dist-snapshot-install-stuff">
    <unzip dest="${snapshot.install.dir}" src="jruby-bin-${version.jruby}.zip"/>
    <chmod perm="755" file="${snapshot.install.dir}/jruby-${version.jruby}/bin/jruby"/>
    <exec executable="${snapshot.install.dir}/jruby-${version.jruby}/bin/jruby"
      dir="${snapshot.install.dir}/jruby-${version.jruby}">
      <arg value="-v"/>
      <arg value="-e"/>
      <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'"/>
    </exec>
  </target>

  <target name="dist-snapshot-install" depends="dist-snapshot" if="snapshot.install.dir">
    <antcall target="dist-snapshot-install-stuff">
      <param file="${jruby.classes.dir}/org/jruby/jruby.properties"/>
    </antcall>
  </target>

  <target name="dist" depends="dist-bin,dist-src"/>

  <target name="dist-clean">
    <delete includeEmptyDirs="true" quiet="true">
      <fileset dir=".">
        <include name="jruby-*.tar.gz"/>
        <include name="jruby-*.zip"/>
      </fileset>
      <fileset dir="dist" includes="**/*"/>
    </delete>
  </target>

  <target name="clean" depends="init" description="Cleans almost everything, leaves downloaded specs">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.dir}"/>
    <delete quiet="false">
        <fileset dir="${lib.dir}" includes="jruby*.jar"/>
    </delete>
    <delete dir="${api.docs.dir}"/>
    <delete dir="src_gen"/>
  </target>

  <target name="clean-all" depends="clean, clear-specs" description="Cleans everything, including downloaded specs">
  </target>

  <property name="nailgun.home" value="${basedir}/tool/nailgun"/>

  <target name="need-ng">
    <condition property="should.build.ng">
      <and>
        <os family="unix"/>
        <not><available file="${nailgun.home}/ng"/></not>
      </and>
    </condition>
  </target>

  <target name="build-ng" depends="need-ng" if="should.build.ng">
    <exec executable="make" dir="${nailgun.home}"/>
  </target>

  <target name="jruby-nailgun" depends="generate-method-classes,build-ng"
    description="Set up JRuby to be run with Nailgun (jruby-ng, jruby-ng-server)">
    <mkdir dir="${build.dir}/nailmain"/>
    <javac srcdir="${nailgun.home}/src/java" destdir="${build.dir}/nailmain"
      classpath="${nailgun.home}/nailgun-0.7.1.jar:${jruby.classes.dir}" debug="true"
      source="${javac.version}" target="${javac.version}"
      deprecation="true" encoding="UTF-8" />
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
      classpath="${build.lib.dir}/jarjar-1.0rc8.jar"/>
    <jarjar destfile="${nailgun.home}/jruby-nailgun.jar">
      <fileset dir="${jruby.classes.dir}">
        <exclude name="org/jruby/util/ant/**/*.class"/>
      </fileset>
      <fileset dir="${build.dir}/nailmain"/>
      <zipfileset src="${build.lib.dir}/asm-3.0.jar"/>
      <zipfileset src="${build.lib.dir}/asm-commons-3.0.jar"/>
      <zipfileset src="${build.lib.dir}/asm-util-3.0.jar"/>
      <zipfileset src="${build.lib.dir}/asm-analysis-3.0.jar"/>
      <zipfileset src="${build.lib.dir}/asm-tree-3.0.jar"/>
      <zipfileset src="${build.lib.dir}/bytelist-1.0.1.jar"/>
      <zipfileset src="${build.lib.dir}/constantine.jar"/>
      <zipfileset src="${build.lib.dir}/jvyamlb-0.2.5.jar"/>
      <zipfileset src="${build.lib.dir}/jline-0.9.93.jar"/>
      <zipfileset src="${build.lib.dir}/jcodings.jar"/>
      <zipfileset src="${build.lib.dir}/joni.jar"/>
      <zipfileset src="${build.lib.dir}/jna-posix.jar"/>
      <zipfileset src="${build.lib.dir}/jna.jar"/>
      <zipfileset src="${build.lib.dir}/joda-time-1.5.1.jar"/>
      <zipfileset src="${nailgun.home}/nailgun-0.7.1.jar"/>
      <rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
        <attribute name="Main-Class" value="org.jruby.Main"/>
      </manifest>
    </jarjar>
  </target>
  
  <target name="fetch-rails">
      <condition property="rails-repo-exists">
          <available file="${rails.dir}/.git"/>
      </condition>
      
      <antcall target="do-fetch-rails"/>
      <antcall target="do-update-rails"/>
  </target>

  <target name="do-fetch-rails" unless="rails-repo-exists">
      <!-- Rails repo might already have been pulled, so delete it -->
      <antcall target="clear-rails" inheritall="false"/>

      <echo message="Cloning rails repo to: ${rails.dir}"/>
      <exec executable="git">
          <arg value="clone"/>
          <arg value="--depth"/><arg value="1"/>
          <arg value="git://github.com/rails/rails.git"/>
          <arg value="${rails.dir}"/>
      </exec>
  </target>

  <target name="do-update-rails" if="rails-repo-exists">
      <echo message="Updading rubyspec repo -- ${rails.dir}"/>
      <exec dir="${rails.dir}" executable="git">
        <arg value="pull"/>
      </exec>
  </target>

  <target name="clear-rails">
      <delete dir="${rails.dir}"/>
  </target>

  <target name="test-rails" depends="jar,install-build-gems,fetch-rails">
      <java dir="${rails.dir}" classname="org.jruby.Main" fork="true" maxmemory="${jruby.launch.memory}" failonerror="true">
        <classpath>
          <pathelement location="${jruby.classes.dir}"/>
          <pathelement location="${build.dir}/jar-complete"/>
          <path refid="build.classpath"/>
        </classpath>
        <sysproperty key="jruby.home" value="${base.dir}"/>
        <arg value="${base.dir}/bin/rake"/>
        <arg value="test"/>
      </java>
  </target>
</project>
Something went wrong with that request. Please try again.