File: build.xml

package info (click to toggle)
lucene2 2.9.4+ds1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 25,000 kB
  • ctags: 22,923
  • sloc: java: 166,802; xml: 5,752; sh: 756; perl: 601; jsp: 311; makefile: 67; csh: 4
file content (753 lines) | stat: -rw-r--r-- 32,815 bytes parent folder | download | duplicates (3)
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
<?xml version="1.0"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 -->

<project name="core" default="default" basedir=".">

  <property name="junit.includes" value="**/Test*.java"/>

  <import file="common-build.xml"/>

  <property name="build.demo.template" value="src/demo/demo-build.template"/> 

  <property name="demo.name" value="lucene-demos-${version}"/>
  <property name="demo.war.name" value="luceneweb"/>

  <!-- Type of checksum to compute for distribution files -->
  <property name="checksum.algorithm" value="md5" />
	
  <!-- Build classpath -->
  <path id="classpath">
    <pathelement location="${build.dir}/classes/java"/>
  </path>

  <path id="tag.classpath">
    <pathelement location="${build.dir}/${tag}/classes/java"/>
  </path>

  <path id="demo.classpath">
    <path refid="classpath"/>
    <pathelement location="${build.dir}/classes/demo"/>
  </path>
  
  <path id="test.classpath">
    <path refid="demo.classpath"/>
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/classes/test"/>
  </path>


  <path id="junit.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/classes/test"/>
    <pathelement location="${build.dir}/classes/java"/>
    <pathelement location="${build.dir}/classes/demo"/>
    <pathelement path="${java.class.path}"/>
  </path>

  <patternset id="src.dist.patterns"
              includes="src/,build.xml,*build*.xml,docs/,*.txt,contrib/,*pom.xml*,lib/"
              excludes="contrib/db/*/lib/,contrib/*/ext-libs/,src/site/build/,contrib/benchmark/temp/**,contrib/benchmark/work/**"
  />
  <patternset id="binary.build.dist.patterns"
              includes="${final.name}.jar,${demo.war.name}.war,${demo.name}.jar,docs/,contrib/*/*.jar,contrib/*/*.war, contrib/*/*/*.jar"
  />
  <patternset id="binary.root.dist.patterns"
              includes="src/demo/,src/jsp/,docs/,*.txt,contrib/*/README*,**/CHANGES.txt,lib/servlet-api-*.jar"
              excludes="${build.demo.template}"
  />


  <!-- ================================================================== -->
  <!-- Prepares the build directory                                       -->
  <!-- ================================================================== -->

  <target name="test-core" depends="common.test"
          description="Runs unit tests for the core Lucene code"
  />
  <target name="test" depends="test-core, test-contrib, test-tag"
          description="Runs all unit tests (core, contrib and back-compat)"
  />

  <property name="tag" value="${compatibility.tag}"/>
	
  <path id="tag.test.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/classes/demo"/>
    <pathelement location="${build.dir}/${tag}/${tag}.jar"/>
  </path>
	
  <path id="tag.junit.classpath">
    <path refid="junit-path"/>
    <pathelement location="${build.dir}/${tag}/classes/test"/>
    <pathelement location="${build.dir}/${final.name}.jar"/>
    <pathelement location="${build.dir}/classes/demo"/>
    <pathelement path="${java.class.path}"/>
  </path>

  <target name="download-tag"
  	description="Downloads a previous Lucene version. Specify tag version like this: -Dtag=lucene_2_4_back_compat_tests_20090127">
	<sequential>
	  <mkdir dir="${tags.dir}/${tag}"/>
      <exec dir="${tags.dir}/${tag}" executable="${svn.exe}"
            failifexecutionfails="false">
        <arg line="checkout http://svn.apache.org/repos/asf/lucene/java/tags/${tag}/src/"/>
      </exec>
	</sequential>
  </target>
	
  <target name="test-tag" depends="download-tag, compile-core, compile-demo, jar-core"
  	description="Runs tests of a previous Lucene version. Specify tag version like this: -Dtag=branches/lucene_2_4_back_compat_tests">
	<sequential>
      <available property="tag.available" file="${tags.dir}/${tag}/src/test" />

	  <fail unless="tag.available">
	  	Specified tag '${tag}' could not be found in directory '${tags.dir}/${tag}'.
	  </fail>
	  <mkdir dir="${build.dir}/${tag}"/>	  
		
	  <!-- first compile tag classes -->
	  <compile
	    srcdir="${tags.dir}/${tag}/src/java"
	    destdir="${build.dir}/${tag}/classes/java">
	  <classpath refid="tag.classpath"/>
	  </compile>

	  <!-- compile jar for tag -->
      <jarify basedir="${build.dir}/${tag}/classes/java"
			  destfile="${build.dir}/${tag}/${tag}.jar" />
		  	
	  <!-- compile tag tests against tag jar -->	
	  <compile-test-macro srcdir="${tags.dir}/${tag}/src/test" destdir="${build.dir}/${tag}/classes/test"
			  			  test.classpath="tag.test.classpath"/>
		
	  <!-- run tag tests against trunk jar -->
      <test-macro dataDir="${tags.dir}/${tag}/src/test" 
      			  tempDir="${build.dir}/${tag}"
      			  junit.classpath="tag.junit.classpath"/>
  	</sequential>
  </target>	

	
  <target name="clean-tags"
    description="Removes contents of the tags directory">
    <delete dir="${tags.dir}"/>
  </target>
	
  <!-- ================================================================== -->
  <!-- J A R                                                              -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->

  <target name="jar-demo" depends="compile-demo">
  	<sequential>
  	  <build-manifest title="Lucene Search Engine: demos"/>
      <jar
        destfile="${build.dir}/${demo.name}.jar"
        basedir="${build.dir}/classes/demo"
        excludes="**/*.java"
      	manifest="${manifest.file}">
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </jar>
  	</sequential>
  </target>

  <target name="jar-demo-src" depends="compile-demo">
  	<sequential>
  	  <build-manifest title="Lucene Search Engine: demos"/>
      <jar
        destfile="${build.dir}/${demo.name}-src.jar"
        basedir="src/demo"
      	manifest="${manifest.file}">
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </jar>
  	</sequential>
  </target>

  <target name="war-demo" depends="jar-core,jar-demo">
    <sequential>
      <build-manifest title="Lucene Search Engine: demos"/>
  	  <war destfile="${build.dir}/${demo.war.name}.war"
           webxml="src/jsp/WEB-INF/web.xml"
      	   manifest="${manifest.file}">
        <fileset dir="src/jsp" excludes="WEB-INF/web.xml"/>
        <lib dir="${build.dir}" includes="${demo.name}.jar"/>
        <lib dir="${build.dir}" includes="${final.name}.jar"/>
        <metainf dir="${common.dir}">
          <include name="LICENSE.txt"/>
          <include name="NOTICE.txt"/>
        </metainf>
      </war>
    </sequential>
  </target>


  <!-- ================================================================== -->
  <!-- B U I L D  D E M O                                                 -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="compile-demo" depends="compile-core">
    <mkdir dir="${build.dir}/classes/demo"/>

    <compile
      srcdir="src/demo"
      destdir="${build.dir}/classes/demo">
      <classpath refid="demo.classpath"/>
    </compile>
  </target>

  <!-- TODO: Remove dependency on demo from test -->
  <target name="compile-test" depends="compile-demo,common.compile-test"/>



  <!-- ================================================================== -->
  <!-- D O C U M E N T A T I O N                                          -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="docs" description="Build the website">
      <echo>DEPRECATED - Doing Nothing.  See http://wiki.apache.org/lucene-java/HowToUpdateTheWebsite</echo>
  </target>

  <target name="javadocs" description="Generate javadoc" 
          depends="javadocs-all, javadocs-core, javadocs-demo, javadocs-contrib">
    <echo file="${javadoc.dir}/index.html" append="false">
<![CDATA[<html><head><title>${Name} ${version} Javadoc Index</title></head>
<body>
<h1>${Name} ${version} Javadoc Index</h1>
<ul>
  <li><a href="all/index.html">All</a></li>
  <li><a href="core/index.html">Core</a></li>
  <li>Contrib packages:</li>
  <ul>
]]></echo>
    <contrib-crawl target="javadocs-index.html" failonerror="false"/>
    <echo file="${javadoc.dir}/index.html" append="true"><![CDATA[
  </ul>
  <li><a href="demo/index.html">Demo</a></li>
</ul></body>]]></echo>
  </target>
	
  <target name="javadocs-core" description="Generate javadoc for core classes">
  	<sequential>
      <mkdir dir="${javadoc.dir}/core"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/core"
      	title="${Name} ${version} core API">
        <sources>
          <packageset dir="src/java"/>
          <link href=""/>
        </sources>
      </invoke-javadoc>
     <jarify basedir="${javadoc.dir}/core" destfile="${build.dir}/${final.name}-javadoc.jar"/>
    </sequential>
  </target>

  <target name="javadocs-demo" description="Generate javadoc for demo classes">
  	<sequential>
      <mkdir dir="${javadoc.dir}/demo"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/demo"
      	title="${Name} ${version} demo API">
        <sources>
          <packageset dir="src/demo"/>
          <link href=""/>
        </sources>
      </invoke-javadoc>
      <jarify basedir="${javadoc.dir}/demo" destfile="${build.dir}/${demo.name}-javadoc.jar"/>
    </sequential>
  </target>
	
  <target name="javadocs-contrib" description="Generate javadoc for contrib classes">
    <contrib-crawl target="javadocs"
                   failonerror="false"/>
  </target>
  	
  <target name="javadocs-all" description="Generate javadoc for core, demo and contrib classes" depends="build-contrib">
  	<sequential>
      <mkdir dir="${javadoc.dir}/all"/>
      <invoke-javadoc
        destdir="${javadoc.dir}/all">
        <sources>
          <!-- TODO: find a dynamic way to do include multiple source roots -->
          <packageset dir="src/java"/>

          <packageset dir="src/demo"/>

          <!-- please keep this list up to date, and in alpha order...   -->
        
          <!-- ie: `find contrib/* -path \*src/java | sort` -->

          <!-- if you make changes to the list of package sets, also -->
          <!-- make sure the group list below is updated.            -->
          <!-- Also remember to keep site.xml in sync.            -->		  

          <packageset dir="contrib/analyzers/common/src/java"/>
          <packageset dir="contrib/analyzers/smartcn/src/java"/>
          <packageset dir="contrib/ant/src/java"/>
          <packageset dir="contrib/benchmark/src/java"/>
          <packageset dir="contrib/collation/src/java"/>
          <packageset dir="contrib/db/bdb-je/src/java"/>
          <packageset dir="contrib/db/bdb/src/java"/>
          <packageset dir="contrib/fast-vector-highlighter/src/java"/>
          <packageset dir="contrib/highlighter/src/java"/>
          <packageset dir="contrib/instantiated/src/java"/>
          <packageset dir="contrib/lucli/src/java"/>
          <packageset dir="contrib/memory/src/java"/>
          <packageset dir="contrib/misc/src/java"/>
          <packageset dir="contrib/queries/src/java"/>
          <packageset dir="contrib/regex/src/java"/>
          <packageset dir="contrib/remote/src/java"/>
          <packageset dir="contrib/snowball/src/java"/>
          <packageset dir="contrib/spatial/src/java"/>
          <packageset dir="contrib/spellchecker/src/java"/>
          <packageset dir="contrib/surround/src/java"/>
          <packageset dir="contrib/swing/src/java"/>
          <packageset dir="contrib/wikipedia/src/java"/>
          <packageset dir="contrib/wordnet/src/java"/>
          <packageset dir="contrib/xml-query-parser/src/java"/>
          <packageset dir="contrib/queryparser/src/java"/>
          <!-- end alpha sort -->

          <!-- If the main javadoc Group listing includes an "Other   -->
          <!-- Packages" group after the ones listed here, then those -->
          <!-- packages are not being matched by any of these rules   -->
  
          <group title="Core" packages="org.apache.*:org.apache.lucene.analysis:org.apache.lucene.analysis.standard*:org.apache.lucene.analysis.tokenattributes*"/>
  
          <group title="Demo" packages="org.apache.lucene.demo*"/>
  
          <group title="contrib: Analysis" packages="org.apache.lucene.analysis.*"/>
          <group title="contrib: Ant" packages="org.apache.lucene.ant*"/>
          <group title="contrib: Benchmark" packages="org.apache.lucene.benchmark*"/>
          <group title="contrib: Collation" packages="org.apache.lucene.collation*"/>
          <group title="contrib: DB" packages="org.apache.lucene.store.db*:org.apache.lucene.store.je*:com.sleepycat*"/>
          <group title="contrib: Fast Vector Highlighter" packages="org.apache.lucene.search.vectorhighlight*"/>
          <group title="contrib: Highlighter" packages="org.apache.lucene.search.highlight*"/>
          <group title="contrib: Instantiated" packages="org.apache.lucene.store.instantiated*"/>
          <group title="contrib: Lucli" packages="lucli*"/>
          <group title="contrib: Memory" packages="org.apache.lucene.index.memory*"/>
          <group title="contrib: Misc " packages="org.apache.lucene.misc*:org.apache.lucene.queryParser.analyzing*:org.apache.lucene.queryParser.precedence*"/>
          <group title="contrib: Queries" packages="org.apache.lucene.search.similar*"/>
          <group title="contrib: Query Parser" packages="org.apache.lucene.queryParser.*"/>
          <group title="contrib: RegEx" packages="org.apache.lucene.search.regex*:org.apache.regexp*"/>
          <group title="contrib: Snowball" packages="org.apache.lucene.analysis.snowball*:net.sf.snowball*"/>
          <group title="contrib: Spatial" packages="org.apache.lucene.spatial*"/>
          <group title="contrib: SpellChecker" packages="org.apache.lucene.search.spell*"/>
          <group title="contrib: Surround Parser" packages="org.apache.lucene.queryParser.surround*"/>
          <group title="contrib: Swing" packages="org.apache.lucene.swing*"/>
          <group title="contrib: Wikipedia" packages="org.apache.lucene.wikipedia*"/>
          <group title="contrib: WordNet" packages="org.apache.lucene.wordnet*"/>
          <group title="contrib: XML Query Parser" packages="org.apache.lucene.xmlparser*"/>
          
        </sources>
      </invoke-javadoc>
  	</sequential>
  </target>


  <!-- ================================================================== -->
  <!-- D I S T R I B U T I O N                                            -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package" depends="jar-core, javadocs, war-demo, build-contrib, init-dist, changes-to-html">
     <copy file="${build.demo.template}" tofile="${build.dir}/build-demo.xml">
        <filterset begintoken="@PLACEHOLDER_" endtoken="@"> 
	  <filter token="version" value="${version}"/>
	  <filter token="javac.source" value="${javac.source}"/>
	  <filter token="javac.target" value="${javac.target}"/>
        </filterset>
     </copy>
  </target>

  <target name="nightly" depends="test, package-tgz">
  </target>

  <!-- ================================================================== -->
  <!-- Packages the distribution with zip                                 -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-zip" depends="package"
    description="--> Generates the Lucene distribution as .zip">

    <delete file="${dist.dir}/lucene-${version}.zip"/>
    <zip destfile="${dist.dir}/lucene-${version}.zip">
      <zipfileset prefix="lucene-${version}" dir=".">
        <patternset refid="binary.root.dist.patterns"/>
      </zipfileset>
      <zipfileset dir="${build.dir}" includes="build-demo.xml" fullpath="lucene-${version}/build.xml"/>
      <zipfileset prefix="lucene-${version}" dir="${build.dir}">
        <patternset refid="binary.build.dist.patterns"/>
      </zipfileset>
    </zip>
	<lucene-checksum file="${dist.dir}/lucene-${version}.zip"/>
  </target>

  <!-- ================================================================== -->
  <!-- packages the distribution with tar-gzip                            -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-tgz" depends="package"
    description="--> Generates the lucene distribution as .tar.gz">

    <delete file="${build.dir}/lucene-${version}.tar"/>
    <delete file="${dist.dir}/lucene-${version}.tar.gz"/>
    <tar tarfile="${build.dir}/lucene-${version}.tar" longfile="gnu">
      <tarfileset prefix="lucene-${version}" dir=".">
        <patternset refid="binary.root.dist.patterns"/>
      </tarfileset>
      <tarfileset dir="${build.dir}" includes="build-demo.xml" fullpath="lucene-${version}/build.xml"/>
      <tarfileset prefix="lucene-${version}" dir="${build.dir}">
        <patternset refid="binary.build.dist.patterns"/>
      </tarfileset>
    </tar>

    <gzip zipfile="${dist.dir}/lucene-${version}.tar.gz"
      src="${build.dir}/lucene-${version}.tar"
      />
	<lucene-checksum file="${dist.dir}/lucene-${version}.tar.gz"/>
  </target>

  <!-- ================================================================== -->
  <!-- packages the distribution with zip and tar-gzip                    -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-all-binary" depends="package-zip, package-tgz"
    description="--> Generates the .tar.gz and .zip distributions"/>

  <!-- ================================================================== -->
  <!-- same as package-all. it is just here for compatibility.            -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="dist" depends="package-all-binary"/>

  <!-- ================================================================== -->
  <!-- S O U R C E  D I S T R I B U T I O N                               -->
  <!-- ================================================================== -->
    <target name="init-dist" >

        <!-- Package is not called first if packaging src standalone, so the dist.dir may not exist -->
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${maven.dist.dir}"/>
    </target>
  <!-- ================================================================== -->
  <!-- Packages the sources with zip                                      -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-zip-src" depends="init, init-dist"
    description="--> Generates the Lucene sources as .zip">
    <zip destfile="${dist.dir}/lucene-${version}-src.zip">
      <zipfileset prefix="lucene-${version}" dir=".">
        <patternset refid="src.dist.patterns"/>
      </zipfileset>
    </zip>
	<lucene-checksum file="${dist.dir}/lucene-${version}-src.zip"/>
  </target>

  <!-- ================================================================== -->
  <!-- Packages the sources with tar-gzip                                 -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-tgz-src" depends="init, init-dist"
    description="--> Generates the Lucene distribution as .tar.gz">

    <delete file="${build.dir}/lucene-${version}-src.tar"/>
    <delete file="${dist.dir}/lucene-${version}-src.tar.gz"/>
    <tar tarfile="${build.dir}/lucene-${version}-src.tar" longfile="gnu">
      <tarfileset prefix="lucene-${version}" dir=".">
        <patternset refid="src.dist.patterns"/>
      </tarfileset>
    </tar>

    <gzip zipfile="${dist.dir}/lucene-${version}-src.tar.gz"
          src="${build.dir}/lucene-${version}-src.tar"
    />
	<lucene-checksum file="${dist.dir}/lucene-${version}-src.tar.gz"/>
  </target>

  <!-- ================================================================== -->
  <!-- Packages the sources with zip and tar-gzip                         -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="package-all-src" depends="package-zip-src, package-tgz-src"
    description="--> Generates the .tar.gz and .zip source distributions"/>

  <!-- ================================================================== -->
  <!-- same as package-all-src. it is just here for compatibility.        -->
  <!-- ================================================================== -->
  <!--                                                                    -->
  <!-- ================================================================== -->
  <target name="dist-src" depends="package-all-src"/>

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

  <target name="generate-maven-artifacts" depends="maven.ant.tasks-check, package, jar-src, jar-demo-src, javadocs">
    <sequential>
      <m2-deploy pom.xml="lucene-parent-pom.xml.template"/>
      <m2-deploy pom.xml="lucene-core-pom.xml.template">
        <artifact-attachments>
          <attach file="${build.dir}/${final.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${final.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
      
      <m2-deploy pom.xml="lucene-demos-pom.xml.template">
        <artifact-attachments>
          <attach file="${build.dir}/${demo.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${demo.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
      
      <m2-deploy pom.xml="lucene-contrib-pom.xml.template"/>
      <contrib-crawl target="dist-maven"/>
    </sequential>
  </target>
	
  <!-- ================================================================== -->
  <!-- Build the JavaCC files into the source tree                        -->
  <!-- ================================================================== -->
  <target name="jjdoc">
    <mkdir dir="${build.dir}/docs/grammars"/>
    <jjdoc target="src/java/org/apache/lucene/queryParser/QueryParser.jj"
           outputfile="${build.dir}/docs/grammars/QueryParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="src/demo/org/apache/lucene/demo/html/HTMLParser.jj"
           outputfile="${build.dir}/docs/grammars/HTMLParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="contrib/surround/src/java/org/apache/lucene/queryParser/surround/parser/QueryParser.jj"
           outputfile="${build.dir}/docs/grammars/Surround_QueryParser.html"
           javacchome="${javacc.home}"
    />
    <jjdoc target="contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/parser/StandardSyntaxParser.jj"
           outputfile="${build.dir}/docs/grammars/StandardSyntaxParser.html"
           javacchome="${javacc.home}"
    />
  </target>

  <target name="clean-javacc">
    <delete>
      <fileset dir="src/java/org/apache/lucene/analysis/standard" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
        <exclude name="ParseException.java"/>
      </fileset>
      <fileset dir="src/java/org/apache/lucene/queryParser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="contrib/surround/src/java/org/apache/lucene/queryParser/surround/parser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/parser" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
      <fileset dir="src/demo/org/apache/lucene/demo/html" includes="*.java">
        <containsregexp expression="Generated.*By.*JavaCC"/>
      </fileset>
    </delete>
  </target>

  <target name="javacc" depends="clean-javacc,javacc-QueryParser,javacc-HTMLParser,javacc-contrib-queryparser, javacc-contrib-surround"/>

  <target name="javacc-QueryParser" depends="init,javacc-check" if="javacc.present">
    <sequential>
      <invoke-javacc target="src/java/org/apache/lucene/queryParser/QueryParser.jj"
                     outputDir="src/java/org/apache/lucene/queryParser"/>

      <!-- Change the inccorrect public ctors for QueryParser to be protected instead -->
      <replaceregexp file="src/java/org/apache/lucene/queryParser/QueryParser.java"
		     byline="true"
		     match="public QueryParser\(CharStream "
		     replace="protected QueryParser(CharStream "/>
      <replaceregexp file="src/java/org/apache/lucene/queryParser/QueryParser.java"
		     byline="true"
		     match="public QueryParser\(QueryParserTokenManager "
		     replace="protected QueryParser(QueryParserTokenManager "/>

    </sequential>
  </target>	
  
  <target name="javacc-HTMLParser" depends="init,javacc-check" if="javacc.present">
    <invoke-javacc target="src/demo/org/apache/lucene/demo/html/HTMLParser.jj"
                   outputDir="src/demo/org/apache/lucene/demo/html"
    />
  </target>
	
  <target name="javacc-contrib-queryparser" depends="init,javacc-check" if="javacc.present">
    <ant target="javacc"
      dir="contrib/queryparser"
      antfile="build.xml" 
    />
  </target>
	
  <target name="javacc-contrib-surround" depends="init,javacc-check" if="javacc.present">
    <ant target="javacc"
      dir="contrib/surround"
      antfile="build.xml" 
    />
  </target>
  
  <!-- ================================================================== -->
  <!-- Build the JFlex files into the source tree                         -->
  <!-- ================================================================== -->

  <target name="jflex" depends="clean-jflex,jflex-StandardAnalyzer" />

  <target name="jflex-StandardAnalyzer" depends="init,jflex-check" if="jflex.present">
    <taskdef classname="JFlex.anttask.JFlexTask" name="jflex">
      <classpath location="${jflex.home}/lib/JFlex.jar" />
    </taskdef>

    <jflex file="src/java/org/apache/lucene/analysis/standard/StandardTokenizerImpl.jflex"
           outdir="src/java/org/apache/lucene/analysis/standard"
           nobak="on" />
  </target>

  <target name="clean-jflex">
    <delete>
      <fileset dir="src/java/org/apache/lucene/analysis/standard" includes="*.java">
        <containsregexp expression="generated.*by.*JFlex"/>
      </fileset>
    </delete>
  </target>

  <macrodef name="contrib-crawl">
    <attribute name="target" default=""/>
    <attribute name="failonerror" default="true"/>
    <sequential>
      <subant target="@{target}" failonerror="@{failonerror}">
        <fileset dir="."
                 includes="contrib/*/build.xml"
        />
      </subant>
    </sequential>
  </macrodef>

  <target name="build-contrib"
          description="Builds all contrib modules and their tests">
    <contrib-crawl target="build-artifacts-and-tests"/>
  </target>

  <target name="test-contrib" depends="build-contrib">
    <!-- Don't fail on error, instead check for flag file so we run
         all the tests possible and can "ant generate-test-reports"
         for all of them.

         Because of this, we depend on "build-contrib" even though the
         Individual contrib "test" targets probably have the
         neccessary dependencies.  If they fail to compile, we won't
         know about it.
     -->
    <contrib-crawl target="test" failonerror="false"/>
    <available property="contribs.failed" file="junitfailed.flag">
      <filepath>
        <dirset dir="${build.dir}/contrib/">
          <include name="**/test/" />
        </dirset>
      </filepath>
    </available>
    <fail if="contribs.failed">Contrib tests failed!</fail>
  </target>

  <!-- Macro for building checksum files
       This is only needed until the "format" option is supported
       by ant's built in checksum task
   -->
  <macrodef name="lucene-checksum">
    <attribute name="file"/>
    <!-- NOTE: we use the value of @{file} in the names any properties
         set because macro's don't have variables, and otherwise we
         wouldn't be able to checksum more then one file per build
      -->
    <sequential>
      <echo>Building checksum for '@{file}'</echo>
      <checksum file="@{file}" property="@{file}.sum" algorithm="${checksum.algorithm}" readbuffersize="65536"/>
      <basename file="@{file}" property="@{file}.base" />
      <echo file="@{file}.${checksum.algorithm}" append="false" message="${@{file}.sum} *${@{file}.base}${line.separator}"/>
    </sequential>
  </macrodef>

  <!--
   compile changes.txt into an html file
   -->

  <target name="changes-to-html">
    <mkdir dir="${changes.target.dir}"/>
    <exec executable="perl" input="CHANGES.txt" output="${changes.target.dir}/Changes.html" failonerror="true">
      <arg value="${changes.src.dir}/changes2html.pl"/>
    </exec>
    <exec executable="perl" input="contrib/CHANGES.txt" output="${changes.target.dir}/Contrib-Changes.html" failonerror="true">
      <arg value="${changes.src.dir}/changes2html.pl"/>
    </exec>
    <copy todir="${changes.target.dir}">
      <fileset dir="${changes.src.dir}" includes="*.css"/>
    </copy>
  </target>

  <!--
   Committer helpers
   -->

  <property name="patch.file" value="${basedir}/../patches/${patch.name}"/>
  <!-- Apply a patch.  Assumes  patch can be applied in the basedir.
  -Dpatch.name assumes the patch is located in ${basedir}/../patches/${patch.name}
  -Dpatch.file means the patch can be located anywhere on the file system
  -->
  <target name="apply-patch" depends="clean" description="Apply a patch file.  Set -Dpatch.file, or -Dpatch.name when the patch is in the directory ../patches/">
    <patch patchfile="${patch.file}" strip="0"/>
  </target>

  <target name="rat-sources-typedef">
    <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:rat.anttasks">
      <classpath>
        <fileset dir="." includes="rat*.jar"/>
      </classpath>
    </typedef>
  </target>

  <target name="rat-sources" depends="rat-sources-typedef"
	  description="runs the tasks over src/java">
    <rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
      <fileset dir="src/java">
      </fileset>
    </rat:report>
  </target>

</project>