jython / build.xml

  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
<!-- Copyright 2000 Dj Walker-Morgan -->
<project name="jython" default="developer-build" basedir=".">
    <target name="usage" description="prints usage hints">
        <echo>
Use case 1: developer build (in your local jython copy)
-------------------------------------------------------
  - call target 'developer-build' (which is the default for this build.xml)
This build will create directories /build and /dist below basedir.


Use case 2: full build for a release (using svn checkout)
---------------------------------------------------------
  - make sure you have access to the jython subversion repository (https://jython.svn.sourceforge.net/svnroot/jython/trunk)
  - override svn.main.dir in ant.properties (if necessary)
  - call target 'full-build'
This build will create a working directory named full_build/${svn.main.dir} at the same
level as your local directories jython, sandbox and installer.
It will contain a big jython_installer-${jython.version}.jar file suitable for installation.

Please be aware:
To build older releases, it may be necessary to use an older build.xml, too (with the corresponding tag).
For example it is not possible to build Release_2_2alpha1 with this version of build.xml.

Note on targets
---------------
The following targets are designed for direct invocation:
  - usage
  - developer-build
  - full-build
  - clean (uses developer-build settings if called directly)
Following an ant convention, the callable targets have a description attribute.
All other targets may give unpredicted results if called directly.


Where ant.properties are searched
---------------------------------
  1. in user.home
  2. in the same directory as this build.xml file
The first setting of a property wins, further settings are ignored.


Actions for a release
---------------------
See http://wiki.python.org/jython/JythonDeveloperGuide/HowToReleaseJython

        	
An example ant.properties file:
-------------------------------

# - define the home of the corresponding CPython version
python.home=c:/Programme/Python/Python23

# - zxJDBC
oracle.jar=C:/workspace/HEAD/for_development/bisdevsrv28/jboss/server/infra/lib/ojdbc14.jar
#informix.jar=${basedir}/../externals/external-jars/ifxjdbc.jar

# - option for javac (build.compiler=modern is a global option to use standard jdk 1.3/1.4/1.5)
#build.compiler=modern
#jdk.target.version=1.5
#debug=false
#optimize=off
#deprecation=off

# - the svn main directory to build from; only needed for full-build
# This e.g. could be one of:
#   trunk
#   branches/Release_2_2maint
#   tags/Release_2_2rc3
# meaning any directory just above the two directories:
#   /installer
#   /jython
# svn.main.dir defaults to trunk
#svn.main.dir=trunk

# - the revision; only needed for a snapshot full-build
# To create a snapshot build: uncomment and indicate the correct revision (it has to be a number)
# For 'normal' builds, this defaults to the latest revision on svn.main.dir (HEAD)
#snapshot.revision=3444

# - the directory containing libsvnjavahl-1.dll (on windows) and svnjavahl.jar; only needed for full-build
# how to get these (for windows):
#   - goto http://subversion.tigris.org/servlets/ProjectDocumentList
#   - open the Releases folder
#   - click on the Windows folder
#   - download svn-win32-1.4.6_javahl.zip (or newer)
#   - unzip the .dll and .jar into javahl.dir
javahl.dir=C:/Programme/Subversion/javahl

# - the directory containing the svnant related .jar files; only needed for full-build
# the following .jar files (probably) are needed:
#   - commons-lang-2.0.jar
#   - jakarta-regexp-1.3.jar
#   - svnant.jar
#   - svnClientAdapter.jar
#   - svnjavahl.jar
# how to get these:
#   - goto http://subclipse.tigris.org/servlets/ProjectDocumentList
#   - click on the the svnant folder
#   - download svnant-1.0.0.zip (or newer)
#   - unzip the jar files from the /lib folder to svnant.jar.dir
svnant.jar.dir=${basedir}/../externals/svnant-jars
        </echo>
    </target>

    <target name="jarless" depends="compile, copy-lib"/>

    <target name="developer-build" depends="prepare-output, jar, copy-lib" description="a local build for developers" />

    <target name="full-build" depends="full-check, install" description="a full build with svn checkout" />

    <target name="needed-check" unless="full-build">
        <uptodate property="jarjar.notneeded" targetfile="${output.dir}/jarjar.jar">
            <srcfiles dir="extlibs" includes="*" />
            <srcfiles dir="grammar" includes="*.g" />
        </uptodate>
        <uptodate property="antlr.notneeded" targetfile="${dist.dir}/jython.jar">
            <srcfiles dir="grammar" includes="*.g" />
        </uptodate>
    </target>

    <target name="init" depends="version-init">
        <property name="build.compiler" value="modern" />
        <property name="jdk.target.version" value="1.5" />
        <property name="jdk.source.version" value="1.5" />
        <property name="deprecation" value="off" />
        <property name="debug" value="true" />
        <property name="nowarn" value="false" />

        <!-- properties work.dir and jython.base.dir are also defined in full-preinit -->
        <property name="work.dir" value="${basedir}" />
        <property name="jython.base.dir" value="${work.dir}" />

        <property name="source.dir" value="${jython.base.dir}/src" />
        <property name="test.source.dir" value="${jython.base.dir}/tests/java" />
        <property name="test.shell.dir" value="${jython.base.dir}/tests/shell" />
        <property name="templates.dir" value="${source.dir}/templates" />
        <property name="python.lib" value="${jython.base.dir}/CPythonLib" />
        <property name="bugtests.dir" value="${jython.base.dir}/bugtests" />
        <property name="templates.lazy" value="true" />
        <property name="extlibs.dir" value="${jython.base.dir}/extlibs" />
        <property name="output.dir" value="${work.dir}/build" />
        <property name="compile.dir" value="${output.dir}/classes" />
        <property name="jarjar.dir" value="${output.dir}/jarjar" />
        <property name="exposed.dir" value="${output.dir}/exposed" />
        <property name="gensrc.dir" value="${output.dir}/gensrc" />
        <property name="dist.dir" value="${work.dir}/dist" />
        <property name="apidoc.dir" value="${dist.dir}/Doc/javadoc" />

        <!-- classpaths -->
        <path id="main.classpath">
            <pathelement path="${jarjar.dir}" />
            <pathelement path="${extlibs.dir}/libreadline-java-0.8.jar" />
            <pathelement path="${extlibs.dir}/jline-0.9.94.jar" />
            <pathelement path="${extlibs.dir}/servlet-api-2.5.jar" />
            <pathelement path="${informix.jar}" />
            <pathelement path="${oracle.jar}" />
            <pathelement path="${extlibs.dir}/mysql-connector-java-5.1.6.jar" />
            <pathelement path="${extlibs.dir}/postgresql-8.3-603.jdbc4.jar" />
            <pathelement path="${extlibs.dir}/antlr-2.7.7.jar" />
            <pathelement path="${extlibs.dir}/antlr-3.1.jar" />
            <pathelement path="${extlibs.dir}/stringtemplate-3.2.jar" />
        </path>

        <available property="informix.present" classname="com.informix.jdbc.IfxDriver" classpath="${informix.jar}" />
        <available property="oracle.present" classname="oracle.jdbc.driver.OracleDriver" classpath="${oracle.jar}" />

        <path id="test.classpath">
            <path refid="main.classpath"/>
            <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" />
            <pathelement path="${extlibs.dir}/junit-3.8.2.jar" />
            <pathelement path="${exposed.dir}" />
            <pathelement path="${compile.dir}" />
        </path>
        <!-- 64 bit Java 6 needs about 96m for regrtest on most platforms, but Apple's needs
         144m -->
        <property name="regrtest.Xmx" value="-Xmx144m" />
    </target>

    <target name="version-init">
        <property file="${user.home}/ant.properties" />
        <property file="${basedir}/ant.properties" />

        <property name="PY_RELEASE_LEVEL_ALPHA" value="10"/> <!-- 0xA -->
        <property name="PY_RELEASE_LEVEL_BETA" value="11"/> <!-- 0xB -->
        <property name="PY_RELEASE_LEVEL_GAMMA" value="12"/> <!-- 0xC -->
        <property name="PY_RELEASE_LEVEL_FINAL" value="15"/> <!-- 0xF -->
        <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> <!-- 0xAA -->

        <!-- The current version info -->
        <property name="jython.version" value="2.5b0+"/>
        <property name="jython.version.noplus" value="2.5b0"/>
        <property name="jython.major_version" value="2"/>
        <property name="jython.minor_version" value="5"/>
        <property name="jython.micro_version" value="0"/>
        <property name="jython.release_level" value="${PY_RELEASE_LEVEL_BETA}"/>
        <property name="jython.release_serial" value="0"/>

        <condition property="do.snapshot.build">
            <isset property="snapshot.revision" />
        </condition>
        <!-- Switch to a snapshot release_level when appropriate -->
        <condition property="jython.real_release_level" value="${PY_RELEASE_LEVEL_SNAPSHOT}" else="${jython.release_level}">
            <isset property="do.snapshot.build" />
        </condition>
        <condition property="os.family.unix">
            <os family="unix"/>
        </condition>
        <condition property="os.family.windows">
            <os family="windows"/>
        </condition>
    </target>

    <target name="full-preinit">
        <property file="${user.home}/ant.properties" />
        <property file="${basedir}/ant.properties" />

        <property name="svnant.jar.dir" value="${basedir}/extlibs/svnant-jars" />

        <!-- use this property to distinguish a full-build from a developer-build -->
        <property name="full-build" value="true" />

        <!-- predefined main directory for checkout -->
        <property name="svn.main.dir" value="trunk" />
        <property name="svn.code.dir" value="jython" />
        <property name="svn.installer.dir" value="installer" />

        <!-- properties work.dir and jython.base.dir are also definied in init, 
             so full-preinit must run first to work -->
        <property name="work.dir" value="${basedir}/../full_build/work" />
        <property name="svn.checkout.dir" value="${work.dir}/checkout" />
        <property name="jython.base.dir" value="${svn.checkout.dir}/${svn.code.dir}" />
        <property name="python.exe" value="${python.home}/python" />
    	<!-- set has.repositories.connection to false in ant.properties if you want to skip checkout -->
        <property name="has.repositories.connection" value="true" />
        <condition property="do.checkout" value="true">
            <istrue value="${has.repositories.connection}" />
        </condition>

        <!-- classpath for svn ant task -->
        <path id="svn.classpath">
            <pathelement path="${java.class.path}" />
            <fileset dir="${svnant.jar.dir}">
              <include name="*.jar"/>
            </fileset>
        </path>
    	<!-- taskdef for svn ant task -->
    	<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="svn.classpath" />
    </target>
    <target name="full-check" depends="full-preinit, init, dump-env">
        <!-- Require all of the optional jars for a full build -->
        <fail unless="informix.present" message="informix jar not present" />
        <fail unless="oracle.present" message="oracle jar not present" />
    </target>
    <target name="dump-env" depends="init">
        <echo>.</echo>
        <echo>Build environment for ${ant.project.name}</echo>
        <echo>(Note: if ${propertyname} is displayed, then the property is not set)</echo>
        <echo>--- optional libraries ---</echo>
        <echo>oracle             = '${oracle.present}'</echo>
        <echo>informix           = '${informix.present}'</echo>
        <echo>--- properties ---</echo>
        <echo>work.dir           = '${work.dir}'</echo>
        <echo>jython.base.dir    = '${jython.base.dir}'</echo>
        <echo>source.dir         = '${source.dir}'</echo>
        <echo>output.dir         = '${output.dir}'</echo>
        <echo>compile.dir        = '${compile.dir}'</echo>
        <echo>exposed.dir        = '${exposed.dir}'</echo>
        <echo>dist.dir           = '${dist.dir}'</echo>
        <echo>apidoc.dir         = '${apidoc.dir}'</echo>
        <echo>templates.dir      = '${templates.dir}'</echo>
        <echo>templates.lazy     = '${templates.lazy}'</echo>
        <echo>python.lib         = '${python.lib}'</echo>
        <echo>build.compiler     = '${build.compiler}'</echo>
        <echo>jdk.target.version = '${jdk.target.version}'</echo>
        <echo>jdk.source.version = '${jdk.source.version}'</echo>
        <echo>deprecation        = '${deprecation}'</echo>
        <echo>debug              = '${debug}'</echo>
        <echo>nowarn             = '${nowarn}'</echo>
        <echo>--- properties (used for full-build only) ---</echo>
        <echo>python.exe         = '${python.exe}'</echo>
        <echo>svn.main.dir       = '${svn.main.dir}'</echo>
        <echo>svn.revision       = '${svn.revision}'</echo>
        <echo>svn.checkout.dir   = '${svn.checkout.dir}'</echo>
        <echo>javahl.dir         = '${javahl.dir}'</echo>
        <echo>svnant.jar.dir     = '${svnant.jar.dir}'</echo>
        <echo>do.snapshot.build  = '${do.snapshot.build}'</echo>
        <echo>snapshot.revision  = '${snapshot.revision}'</echo>
        <echo>do.checkout        = '${do.checkout}'</echo>
    </target>

    <!-- delete what's necessary. should correspond to the directories created in prepare  -->
    <!-- if called directly, we use settings as in developer-build -->
    <!-- (at the moment all properties will already be set if we do a full build) -->
    <target name="clean" depends="init, clean-checkout-dir" description="clean up build working directories">
        <!-- do not hard delete ${work.dir}, since it could be ${basedir} -->
        <!-- deletes all files and subdirectories of ${output.dir}, without ${output.dir} itself. -->
        <delete includeemptydirs="true" failonerror="false">
            <fileset dir="${output.dir}" includes="**/*" />
        </delete>
        <!-- deletes all files and subdirectories of ${dist.dir}, without ${dist.dir} itself. -->
        <delete includeemptydirs="true" failonerror="false">
            <fileset dir="${dist.dir}" includes="**/*" />
        </delete>
        <!-- delete the installation .jar file from ${work.dir}, but no other files -->
        <delete failonerror="false">
            <fileset dir="${work.dir}" includes="jython*.jar" />
        </delete>
    </target>

    <!-- clean svn.checkout.dir if we really checkout -->
    <target name="clean-checkout-dir" if="do.checkout">
        <delete includeemptydirs="true" failonerror="false">
            <fileset dir="${svn.checkout.dir}" includes="**/*" defaultexcludes="no" />
        </delete>
    </target>

    <target name="clean-if-antlr-needed" unless="antlr.notneeded">
        <!-- this seems to be the only way I could get a clean when there has been a
             change to grammar files.  If you are working on the grammars you might
             want to comment this out, as a clean is really only needed if you change
             the tokens defined in Python.g (and cleans make the build slow) -->
        <antcall target="clean"/>
    </target>
    
    <!-- create output directories -->
    <target name ="prepare-output" depends="init,needed-check,clean-if-antlr-needed">
        <mkdir dir="${compile.dir}" />
        <mkdir dir="${jarjar.dir}" />
        <mkdir dir="${gensrc.dir}/org/python/antlr" />
        <mkdir dir="${exposed.dir}" />
        <mkdir dir="${dist.dir}" />
    </target>

    <!-- create necessary directories -->
    <target name="prepare" depends="prepare-full, prepare-checkout, prepare-output"/>

    <!-- create directories needed only in full-build -->
    <target name="prepare-full" depends="clean" if="full-build">
        <mkdir dir="${work.dir}" />
        <mkdir dir="${dist.dir}/Doc" />
        <mkdir dir="${apidoc.dir}" />
    </target>

    <!-- create checkout directory if necessary -->
    <target name="prepare-checkout" if="do.checkout">
        <mkdir dir="${svn.checkout.dir}" />
    </target>

    <target name="checkout" depends="prepare" if="do.checkout">
        <svn javahl="${javahl.dir}" >
            <checkout url="https://jython.svn.sourceforge.net/svnroot/jython/${svn.main.dir}/${svn.installer.dir}" revision="${svn.revision}" destPath="${svn.checkout.dir}/${svn.installer.dir}" />
            <checkout url="https://jython.svn.sourceforge.net/svnroot/jython/${svn.main.dir}/${svn.code.dir}" revision="${svn.revision}" destPath="${svn.checkout.dir}/${svn.code.dir}" />
        </svn> 

        <!-- checkout cpython license from the correct python maintenance branch -->
        <svn javahl="${javahl.dir}" >
               <checkout url="http://svn.python.org/projects/python/branches/release25-maint/" destPath="${svn.checkout.dir}/python" recurse="false" />
        </svn> 
    </target>

    <!-- XXX: could attempt to utilize subwcrev.exe to get the revision on Windows  -->
    <target name="svnversion" if="os.family.unix">
        <exec executable="svnversion" failifexecutionfails="false" outputproperty="build.svn.revision"/>
    </target>

    <target name="brand-version" depends="version-init, svnversion">
        <condition property="build.svn.revision" value="">
            <not>
                <isset property="build.svn.revision"/>
            </not>
        </condition>
        <tstamp>
            <format property="build.date" pattern="MMM d yyyy" offset="0"/>
            <format property="build.time" pattern="HH:mm:ss" offset="0"/>
        </tstamp>
        <mkdir dir="${compile.dir}/org/python"/>
        <echo file="${compile.dir}/org/python/version.properties"># Jython version information
jython.version=${jython.version}
jython.major_version=${jython.major_version}
jython.minor_version=${jython.minor_version}
jython.micro_version=${jython.micro_version}
jython.release_level=${jython.release_level}
jython.release_serial=${jython.release_serial}
jython.build.date=${build.date}
jython.build.time=${build.time}
jython.build.svn_revision=${build.svn.revision}</echo>
    </target>

    <target name="brand-readme-version" depends="checkout" if="do.snapshot.build">
        <!-- change README.txt version string, if so defined: used for
        snapshot builds. XXX: a bit broken for now-->
        <replace file="${jython.base.dir}/README.txt" token='2.5a3+'
        value='2.5a${svn.revision}' />
        <replace file="${jython.base.dir}/README.txt">
            <replacetoken>=======================</replacetoken>
            <replacevalue>--------------------------

This is a snapshot build.
It reflects the current development status.
				
The readme text for the next release will be like:

            </replacevalue>
        </replace>
    </target>

    <target name="template-init" depends="prepare">
        <javac srcdir="${source.dir}/"
                destdir="${compile.dir}"
                target="${jdk.target.version}"
                source="${jdk.source.version}"
                debug="${debug}"
                optimize="${optimize}"
                deprecation="${deprecation}"
                nowarn="${nowarn}">
            <include name="org/python/util/TemplateAntTask.java" />
        </javac>
    </target>

    <target name="template" depends="checkout, template-init">
        <taskdef name="gentempl" classname="org.python.util.TemplateAntTask"
            classpath="${compile.dir}" />
        <gentempl srcdir="${templates.dir}" verbose="true"
		  lazy="${templates.lazy}"/>
    </target>

    <target name="antlr_gen" depends="prepare-output" unless="antlr.notneeded">
        <java classname="org.antlr.Tool" failonerror="true" fork="true" dir="${jython.base.dir}">
            <arg value="-fo"/>
            <arg path="${work.dir}/build/gensrc/org/python/antlr"/>
            <arg value="-lib"/>
            <arg path="${work.dir}/build/gensrc/org/python/antlr"/>
            <arg file="${jython.base.dir}/grammar/Python.g"/>
            <arg file="${jython.base.dir}/grammar/PythonPartial.g"/>
            <classpath refid="main.classpath"/>
        </java>
        
        <!-- copy the .tokens to /grammar, for usage in ANTLRWorks -->
        <!--
        <copy todir="grammar" preservelastmodified="true">
            <fileset dir="build/gensrc/org/python/antlr">
                <include name="Python.tokens" />
            </fileset>
        </copy>
        -->

    </target>
 
    <target name="compile" depends="init,antlr_gen,jarjar,brand-version">
        <javac destdir="${compile.dir}"
               target="${jdk.target.version}"
               source="${jdk.source.version}"
               debug="${debug}"
               deprecation="${deprecation}"
               nowarn="${nowarn}">
            <src path="${source.dir}"/>
            <src path="${gensrc.dir}"/>

            <exclude name="**/handler/InformixDataHandler.java" unless="informix.present" />
            <exclude name="**/handler/OracleDataHandler.java" unless="oracle.present" />
            <classpath refid="main.classpath" />
        </javac>

        <javac srcdir="${jython.base.dir}/Lib"
               includes="jxxload_help/**"
               destdir="${compile.dir}"
               target="${jdk.target.version}"
               source="${jdk.source.version}"
               debug="${debug}"
               optimize="${optimize}"
               deprecation="${deprecation}"
               nowarn="${nowarn}"/>

        <!-- java files used by tests -->
        <javac srcdir="${test.source.dir}"
               destdir="${compile.dir}"
               target="${jdk.target.version}"
               source="${jdk.source.version}"
               debug="${debug}"
               optimize="${optimize}"
               deprecation="${deprecation}"
               nowarn="${nowarn}"> 
            <classpath refid="test.classpath" />
        </javac>

        <copy file="${source.dir}/org/python/modules/ucnhash.dat"
              todir="${compile.dir}/org/python/modules"
              preservelastmodified="true" />

        <copy todir="${compile.dir}/com" preservelastmodified="true">
            <fileset dir="${source.dir}/com">
                <include name="**/*.properties" />
            </fileset>
        </copy>
    </target>

    <target name="expose" depends="init">
        <taskdef name="expose" classname="org.python.expose.generate.ExposeTask">
            <classpath>
                <path refid="main.classpath" />
                <pathelement path="${compile.dir}" />
            </classpath>
        </taskdef>
        <expose srcdir="${compile.dir}"
            destdir="${exposed.dir}" 
            includesfile="${jython.base.dir}/CoreExposed.includes"/>
    </target>

    <target name="jarjar" depends="init,needed-check" unless="jarjar.notneeded">
        <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-0.7.jar"/>
        <jarjar destfile="${output.dir}/jarjar.jar">
            <zipfileset src="extlibs/antlr-runtime-3.1.jar"/>
            <zipfileset src="extlibs/asm-3.1.jar"/>
            <zipfileset src="extlibs/asm-commons-3.1.jar"/>
            <zipfileset src="extlibs/asm-util-3.1.jar"/>
            <rule pattern="org.objectweb.asm.**" result="org.python.objectweb.asm.@1"/>
            <zipfileset src="extlibs/jna.jar"/>
            <zipfileset src="extlibs/jna-posix.jar"/>
            <!-- <rule pattern="com.sun.jna.**" result="org.python.jna.@1"/> -->
            <rule pattern="org.jruby.ext.posix.**" result="org.python.posix.@1"/>
        </jarjar>
        <unjar src="${output.dir}/jarjar.jar" dest="${jarjar.dir}">
            <patternset>
                <exclude name="META-INF/**"/>
            </patternset>
        </unjar>
    </target>

    <target name="jar-complete" depends="compile,expose,jarjar">
       <jar destfile="${dist.dir}/jython-complete.jar" duplicate="preserve">
          <fileset dir="${exposed.dir}"/>
          <fileset dir="${compile.dir}"/>   
          <fileset dir="${jarjar.dir}">
          </fileset>
          <manifest>
              <attribute name="Main-Class" value="org.python.util.jython" />
              <attribute name="Built-By" value="${user.name}" />
              <!-- info section. ATTN: no blanks, no '.' in the names -->
              <section name="Build-Info">
                  <attribute name="version" value="${jython.version}" />
                  <attribute name="svn-build" value="${do.checkout}" />
                  <attribute name="oracle" value="${oracle.present}" />
                  <attribute name="informix" value="${informix.present}" />
                  <attribute name="build-compiler" value="${build.compiler}" />
                  <attribute name="jdk-target-version" value="${jdk.target.version}" />
                  <attribute name="debug" value="${debug}" />
                  <attribute name="optimize" value="${optimize}" />
              </section>
          </manifest>
        </jar>
    </target>

    <target name="jar" depends="compile,expose,jarjar">
       <typedef name="nameunion" classname="org.python.util.NameUnionAntType">
           <classpath>
               <path refid="main.classpath" />
               <pathelement path="${compile.dir}" />
           </classpath>
       </typedef>
       <jar destfile="${dist.dir}/jython.jar" duplicate="fail">
          <nameunion>
             <fileset dir="${exposed.dir}"/>
             <fileset dir="${compile.dir}" excludes="org/python/expose/generate/**"/>   
          </nameunion>
          <fileset dir="${jarjar.dir}">
              <include name="org/python/objectweb/asm/ClassReader.class" />
          </fileset>
          <manifest>
              <attribute name="Main-Class" value="org.python.util.jython" />
              <attribute name="Built-By" value="${user.name}" />
              <!-- info section. ATTN: no blanks, no '.' in the names -->
              <section name="Build-Info">
                  <attribute name="version" value="${jython.version}" />
                  <attribute name="svn-build" value="${do.checkout}" />
                  <attribute name="oracle" value="${oracle.present}" />
                  <attribute name="informix" value="${informix.present}" />
                  <attribute name="build-compiler" value="${build.compiler}" />
                  <attribute name="jdk-target-version" value="${jdk.target.version}" />
                  <attribute name="debug" value="${debug}" />
                  <attribute name="optimize" value="${optimize}" />
              </section>
          </manifest>
        </jar>
    </target>

    <target name="javadoc" depends="compile">
        <path id="javadoc.classpath">
            <pathelement path="${java.class.path}" />
            <path refid="main.classpath" />
        </path> 
        <javadoc sourcepath="${source.dir}" 
                 destdir="${apidoc.dir}"
                 source="${jdk.source.version}"
                 public="true"
                 breakiterator="yes"
                 packagenames="org.python.core, org.python.util, com.ziclix.python.sql"
                 windowtitle="Jython API documentation"
                 bottom="&lt;a href='http://www.jython.org' target='_top'>Jython homepage&lt;/a>"
        >
            <classpath refid="javadoc.classpath" />
        </javadoc>
    </target>

    <target name="copy-license" if="do.checkout">
        <echo>copy CPython LICENSE from ${svn.checkout.dir}/python</echo>
        <copy file="${svn.checkout.dir}/python/LICENSE" tofile="${dist.dir}/LICENSE_CPython.txt" preservelastmodified="true" />
    </target>

    <target name="copy-full" depends="copy-lib, copy-license" if="full-build">
        <echo>copy misc files from ${jython.base.dir}</echo>
        <copy todir="${dist.dir}" preservelastmodified="true">
            <fileset dir="${jython.base.dir}"
                     includes="ACKNOWLEDGMENTS, build.xml, build.Lib.include.properties, NEWS, LICENSE.txt, README.txt, registry"
            />
        </copy>

        <!-- sources: todir has to correspond with installer/**/JarInstaller.java -->
        <echo>copy sources from ${jython.base.dir}</echo>
        <copy todir="${dist.dir}" preservelastmodified="true">
            <fileset dir="${jython.base.dir}">
              <include name="src/**/*.java" />
              <include name="src/com/**/*.properties" />
              <include name="src/shell/*" />
              <include name="src/templates/*" />
              <include name="Lib/jxxload_help/*.java" />
              <include name="src/org/**/ucnhash.dat" />
              <include name="grammar/*.g" />
              <include name="extlibs/**/*.jar" />
              <include name="extlibs/**/*.zip" />
              <include name="tests/java/**/*.java" />
              <include name="CoreExposed.includes" />
            </fileset>
        </copy>

        <echo>copy the demo files from ${jython.base.dir}/Demo</echo>
        <copy todir="${dist.dir}/Demo" preservelastmodified="true">
            <fileset dir="${jython.base.dir}/Demo">
              <include name="**/*.java" />
              <include name="**/*.html" />
              <include name="**/*.py" />
              <include name="**/*.txt" />
              <include name="**/*.xml**" />
              <include name="**/jreload/example.jar" />
              <include name="**/jreload/_xample/Version.class" />
              <exclude name="**/jpywork/**" />
            </fileset>
        </copy>
    </target>

    <target name="copy-lib" depends="init, copy-javalib, copy-cpythonlib">
        <!-- XXX untested and most likely broken in 2.5
        <copy todir="${dist.dir}" preservelastmodified="true">
            <fileset dir="${jython.base.dir}" includes="Tools/**/*.py" />
        </copy>
        -->

        <copy todir="${dist.dir}/Lib">
            <fileset dir="${jython.base.dir}/Lib">
                <exclude name="**/*.class"/>
            </fileset>
        </copy>

        <copy todir="${dist.dir}/bin">
            <fileset dir="${source.dir}/shell"/>
        </copy>

        <chmod perm="ugo+rx">
            <fileset dir="${dist.dir}/bin" />
        </chmod>

    </target>

    <target name="copy-cpythonlib">
        <copy todir="${dist.dir}/Lib">
            <fileset dir="${python.lib}" excludes="**/*.pyc, **/*.pyo" includesfile="${jython.base.dir}/CPythonLib.includes">
                <!-- The include file gets all of CPythonLib's test directory, but we only want the ones from Jython's Lib.   -->
                <present present="srconly" targetdir="${jython.base.dir}/Lib"/>
            </fileset>
        </copy>
    </target>

    <target name="copy-javalib" unless="full-build">
        <copy todir="${dist.dir}/javalib">
            <fileset dir="${jython.base.dir}/extlibs">
                <exclude name="profile.properties"/>
            </fileset>
            <fileset dir="${work.dir}/build">
                <include name="*.jar"/>
                <include name="*.properties"/>
            </fileset>
        </copy>
    </target>

    <!-- if install called by itself, make sure all the dependent targets run;
         otherwise, redundant with full-check -->
    <target name="install-init">
        <property name="full-build" value="true" />
    </target>

    <!-- wrap the build into the installer -->
    <target name="install" depends="brand-readme-version, install-init, jar-complete, javadoc, copy-full">
        <property name="install.src.dir" value="${jython.base.dir}/../installer/src/java" />
        <echo>compiling installer from ${install.src.dir}</echo>
        <javac srcdir="${install.src.dir}"
               includes="org/**"
               destdir="${compile.dir}"
               target="${jdk.target.version}"
               source="${jdk.source.version}"
               debug="${debug}"
               optimize="${optimize}"
               deprecation="${deprecation}"
               nowarn="${nowarn}"
        />
        <echo>copy installer classes to ${dist.dir}</echo>
        <copy todir="${dist.dir}" preservelastmodified="true">
            <fileset dir="${compile.dir}">
            	<include name="org/python/util/install/**/*.class" />
            	<include name="org/apache/commons/cli/*.class" />
            </fileset>
        </copy>
        <copy file="${install.src.dir}/org/apache/LICENSE.txt" tofile="${dist.dir}/LICENSE_Apache.txt" preservelastmodified="true" />
        <echo>copy installer icon to ${dist.dir}</echo>
        <copy todir="${dist.dir}" preservelastmodified="true">
            <!-- check no /bin directory -->
            <fileset dir="${install.src.dir}" includes="**/*.png" excludes="bin/**" />
        </copy>
        <echo>building installer .jar file</echo>
        <jar destfile="${work.dir}/jython_installer-${jython.version.noplus}.jar" basedir="${dist.dir}" update="true">
            <manifest>
                <attribute name="Main-Class" value="org.python.util.install.Installation" />
                <attribute name="Built-By" value="${user.name}" />
                <!-- section for the install program -->
                <section name="Jython">
                    <attribute name="version" value="${jython.version}" />
                    <attribute name="exclude-dirs" value="org;META-INF" />
                </section>
                <!-- info section. ATTN: no blanks, no '.' in the names -->
                <section name="Build-Info">
                    <attribute name="svn-build" value="${do.checkout}" />
                    <attribute name="oracle" value="${oracle.present}" />
                    <attribute name="informix" value="${informix.present}" />
                    <attribute name="build-compiler" value="${build.compiler}" />
                    <attribute name="jdk-target-version" value="${jdk.target.version}" />
                    <attribute name="debug" value="${debug}" />
                    <attribute name="optimize" value="${optimize}" />
                </section>
            </manifest>
        </jar>
    </target>

    <target name="test" depends="javatest,launchertest,regrtest"/>
    <target name="javatest" depends="compile,expose">
        <junit fork="true" printsummary="true">
            <classpath refid="test.classpath"/>
            <batchtest todir="${dist.dir}/testreports">
                <fileset dir="${test.source.dir}" includes="**/*Test*.java">
                    <exclude name="javatests/**/*" />
                    <exclude name="**/InterpTestCase.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>
    <target name="launchertest" depends="developer-build" if="os.family.unix">
      <exec executable="${test.shell.dir}/test-jython.sh">
        <arg value="${dist.dir}"/>
      </exec>
    </target>
    <target name="regrtest" depends="developer-build,regrtest-unix,regrtest-windows"/>
    <target name="regrtest-unix" if="os.family.unix">
      <exec executable="${dist.dir}/bin/jython">
        <arg value="--verify"/>
        <arg value="-J${regrtest.Xmx}"/>
        <arg value="${dist.dir}/Lib/test/regrtest.py"/>
        <!-- Only run the tests that are expected to work on Jython -->
        <arg value="--expected"/>
      </exec>
    </target>
    <target name="regrtest-windows" if="os.family.windows">
      <exec executable="${dist.dir}/bin/jython.bat">
        <arg value="-J${regrtest.Xmx}"/>
        <arg value="${dist.dir}/Lib/test/regrtest.py"/>
        <!-- Only run the tests that are expected to work on Jython -->
        <arg value="--expected"/>
      </exec>
    </target>

    <!-- run bugtests, create a config if necessary -->
    <target name="bugtest" depends="create-bugtest-config">
         <java classname="org.python.util.jython" fork="true" dir="${bugtests.dir}">
            <classpath>
                <pathelement location="${dist.dir}/jython.jar"/>
            </classpath>
            <jvmarg value="-Dpython.home=${dist.dir}"/>
            <arg value="driver.py"/>
         	<!-- uncomment if you want to run only one test: -->
         	<!--
         	<arg value="386"/>
         	-->
        </java>
    </target>

    <!-- create support_config.py in the bugtset directory only if it doesn't already exist -->
    <target name="create-bugtest-config" depends="init, check-bugtest-config" unless="have_bugtest_config">
        <!-- doesn't seem to be a direct way to get at the path to javac,
        java.home points to the jre folder. The following assumes a standard
        jdk layout. Alternative is to try something like:

            <property environment="env"/>
            <property name="jdk.home" value="${env.JAVA_HOME}" />
  
        or set jdk.home explicitly
        -->
        <echo>creating ${bugtests.dir}/support_config.py</echo>
        <property name="jdk.home" value="${java.home}/.." />
        <echo file="${bugtests.dir}/support_config.py">
# this configuration was auto-generated by ant build script,
# safe to edit by hand (won't be overwritten)
java_home="${jdk.home}"
jython_home="${dist.dir}" 
classpath="${dist.dir}/jython.jar${path.separator}classes"
        </echo>
    </target>

    <!-- set property have_bugtest_config if support_config.py already exists in the bugtest directory -->
    <target name="check-bugtest-config">
        <available property="have_bugtest_config" file="${bugtests.dir}/support_config.py"/>
    </target>

</project>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.