~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/common-build.xml

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
 
3
 
<!--
4
 
                Licensed to the Apache Software Foundation (ASF) under one or more
5
 
                contributor license agreements.  See the NOTICE file distributed with
6
 
                this work for additional information regarding copyright ownership.
7
 
                The ASF licenses this file to You under the Apache License, Version 2.0
8
 
                the "License"); you may not use this file except in compliance with
9
 
                the License.  You may obtain a copy of the License at
10
 
 
11
 
                                http://www.apache.org/licenses/LICENSE-2.0
12
 
 
13
 
                Unless required by applicable law or agreed to in writing, software
14
 
                distributed under the License is distributed on an "AS IS" BASIS,
15
 
                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 
                See the License for the specific language governing permissions and
17
 
                limitations under the License.
18
 
-->
19
 
 
20
 
<project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
21
 
        <description>
22
 
                This file is designed for importing into a main build file, and not intended
23
 
                for standalone use.
24
 
        </description>
25
 
 
26
 
        <dirname file="${ant.file.common}" property="common.dir"/>
27
 
        <property name="dev-tools.dir" value="${common.dir}/../dev-tools"/>
28
 
        <property name="prettify.dir" value="${common.dir}/src/tools/prettify"/>
29
 
        <property name="maven.build.dir" value="${build.dir}/maven"/>
30
 
 
31
 
        <!-- Give user a chance to override without editing this file
32
 
                        (and without typing -D each time it compiles it -->
33
 
        <property file="${user.home}/lucene.build.properties"/>
34
 
        <property file="${user.home}/build.properties"/>
35
 
        <property file="${basedir}/build.properties"/>
36
 
        <property file="${common.dir}/build.properties"/>
37
 
 
38
 
        <tstamp>
39
 
                <format property="current.year" pattern="yyyy"/>
40
 
                <format property="DSTAMP" pattern="yyyy-MM-dd"/>
41
 
                <format property="TSTAMP" pattern="HH:mm:ss"/>
42
 
                <!-- datetime format that is safe to treat as part of a dotted version -->
43
 
                <format property="dateversion" pattern="yyyy.MM.dd.HH.mm.ss" />
44
 
        </tstamp>
45
 
 
46
 
        <property name="name" value="${ant.project.name}"/>
47
 
        <property name="Name" value="Lucene"/>
48
 
        <property name="dev.version" value="3.5.0-goobi"/>
49
 
        <property name="tests.luceneMatchVersion" value="3.5"/>
50
 
        <property name="version" value="${dev.version}"/>
51
 
        <property name="spec.version" value="${version}"/>
52
 
        <property name="year" value="2000-${current.year}"/>
53
 
        <property name="final.name" value="lucene-${name}-${version}"/>
54
 
 
55
 
        <property name="junit.jar" value="junit-4.7.jar"/>
56
 
        <property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/>
57
 
        <path id="junit-path">
58
 
                <pathelement location="${junit-location.jar}"/>
59
 
        </path>
60
 
 
61
 
        <path id="ant-path">
62
 
                <fileset dir="${common.dir}/lib" includes="ant-*.jar"/>
63
 
        </path>
64
 
 
65
 
        <path id="tools.runtime.classpath">
66
 
                <pathelement location="${common.dir}/build/classes/tools"/>
67
 
        </path>
68
 
 
69
 
        <path id="maven-ant-tasks.classpath">
70
 
                <fileset dir="${common.dir}/lib">
71
 
                        <include name="maven-ant-tasks-*.jar"/>
72
 
                </fileset>
73
 
        </path>
74
 
 
75
 
        <!-- default arguments to pass to JVM executing tests -->
76
 
        <property name="testmethod" value=""/>
77
 
        <property name="args" value=""/>
78
 
        <property name="tests.threadspercpu" value="1" />
79
 
        <condition property="tests.sequential">
80
 
                <or>
81
 
                        <isset property="testcase"/>
82
 
                        <equals arg1="${tests.threadspercpu}" arg2="0"/>
83
 
                </or>
84
 
        </condition>
85
 
        <property name="tests.multiplier" value="1" />
86
 
        <property name="tests.locale" value="random" />
87
 
        <property name="tests.timezone" value="random" />
88
 
        <property name="tests.directory" value="random" />
89
 
        <property name="tests.linedocsfile" value="europarl.lines.txt.gz" />
90
 
        <property name="tests.iter" value="1" />
91
 
        <property name="tests.iter.min" value="${tests.iter}" />
92
 
        <property name="tests.seed" value="random" />
93
 
        <property name="tests.loggingfile" value="/dev/null"/>
94
 
        <property name="tests.nightly" value="false" />
95
 
        <property name="tests.cleanthreads.sysprop" value="perMethod"/>
96
 
        <property name="tests.asserts.gracious" value="false"/>
97
 
 
98
 
        <property name="javac.deprecation" value="off"/>
99
 
        <property name="javac.debug" value="on"/>
100
 
        <property name="javac.source" value="1.5"/>
101
 
        <property name="javac.target" value="1.5"/>
102
 
        <property name="javac.source.backwards" value="1.5"/>
103
 
        <property name="javac.target.backwards" value="1.5"/>
104
 
        <!-- clover wants to run with -lib, otherwise we prefer a repeatable
105
 
                         classpath -->
106
 
        <property name="javac.includeAntRuntime" value="${run.clover}"/>
107
 
 
108
 
        <property name="javadoc.link" value="http://download.oracle.com/javase/1.5.0/docs/api/"/>
109
 
        <property name="javadoc.access" value="protected"/>
110
 
        <property name="javadoc.charset" value="utf-8"/>
111
 
        <property name="javadoc.dir" value="${common.dir}/build/docs/api"/>
112
 
        <property name="javadoc.maxmemory" value="512m" />
113
 
        <!-- Javadoc classpath -->
114
 
        <path id="javadoc.classpath">
115
 
                <path refid="classpath"/>
116
 
                <pathelement location="${ant.home}/lib/ant.jar"/>
117
 
                <fileset dir=".">
118
 
                        <exclude name="build/**/*.jar"/>
119
 
                        <include name="**/lib/*.jar"/>
120
 
                </fileset>
121
 
        </path>
122
 
 
123
 
        <property name="changes.src.dir" value="${common.dir}/src/site/changes"/>
124
 
        <property name="changes.target.dir" value="${common.dir}/build/docs/changes"/>
125
 
 
126
 
        <property name="project.name" value="site"/> <!-- todo: is this used by anakia or something else? -->
127
 
        <property name="build.encoding" value="utf-8"/>
128
 
 
129
 
        <property name="src.dir" location="src/java"/>
130
 
        <property name="tests.src.dir" location="src/test"/>
131
 
        <property name="tests-framework.src.dir" location="${common.dir}/src/test-framework/java"/>
132
 
        <property name="build.dir" location="build"/>
133
 
        <!-- Needed in case a contrib needs the original build, also for compile-tools to be called from contrib -->
134
 
        <property name="common.build.dir" location="${common.dir}/build"/>
135
 
        <property name="tests.lockdir" location="${common.build.dir}"/>
136
 
        <property name="dist.dir" location="dist"/>
137
 
        <property name="maven.dist.dir" location="dist/maven"/>
138
 
        <property name="m2.repository.url" value="file://${maven.dist.dir}"/>
139
 
        <property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
140
 
 
141
 
        <property name="javacc.home" location="${common.dir}"/>
142
 
        <property name="jflex.home" location="${common.dir}"/>
143
 
 
144
 
        <path id="jflex.classpath">
145
 
                <fileset dir="${jflex.home}/">
146
 
                        <!-- for a JFlex trunk checkout: -->
147
 
                        <include name="jflex/target/*.jar"/>
148
 
                        <!-- for a JFlex distribution (not yet available): -->
149
 
                        <include name="lib/*.jar"/>
150
 
                </fileset>
151
 
        </path>
152
 
 
153
 
        <path id="javacc.classpath">
154
 
                <fileset dir="${javacc.home}/">
155
 
                        <include name="bin/lib/*.jar"/>
156
 
                </fileset>
157
 
        </path>
158
 
 
159
 
        <property name="backwards.dir" location="backwards"/>
160
 
        <property name="build.dir.backwards" location="${build.dir}/backwards"/>
161
 
 
162
 
        <property name="junit.output.dir" location="${build.dir}/test"/>
163
 
        <property name="junit.output.dir.backwards" location="${build.dir.backwards}/test"/>
164
 
        <property name="junit.reports" location="${build.dir}/test/reports"/>
165
 
        <property name="junit.reports.backwards" location="${build.dir.backwards}/test/reports"/>
166
 
        <property name="junit.excludes" value=""/>
167
 
        <condition property="junit.details.formatter"
168
 
                        value="org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"
169
 
                        else="org.apache.lucene.util.LuceneJUnitResultFormatter">
170
 
                <isset property="tests.sequential"/>
171
 
        </condition>
172
 
        <property name="junit.parallel.selector" value="org.apache.lucene.util.LuceneJUnitDividingSelector"/>
173
 
 
174
 
        <property name="manifest.file" location="${common.dir}/build/MANIFEST.MF"/>
175
 
 
176
 
        <!--
177
 
                we attempt to exec svnversion to get details build information
178
 
                for jar manifests.  this property can be set at runtime to an
179
 
                explicit path as needed, or ant will just try to find it in the
180
 
                default PATH. (this is useful for Hudson)
181
 
        -->
182
 
        <property name="svnversion.exe" value="svnversion" />
183
 
        <property name="svn.exe" value="svn" />
184
 
 
185
 
        <property name="gpg.exe" value="gpg" />
186
 
        <property name="gpg.key" value="CODE SIGNING KEY" />
187
 
 
188
 
        <property name="clover.db.dir" location="${common.dir}/build/test/clover/db"/>
189
 
        <property name="clover.report.dir" location="${common.dir}/build/test/clover/reports"/>
190
 
 
191
 
                <available
192
 
                                                property="clover.present"
193
 
                                                classname="com.cenqua.clover.tasks.CloverReportTask"
194
 
                                                />
195
 
         <condition property="clover.enabled">
196
 
                         <and>
197
 
                                         <isset property="run.clover"/>
198
 
                                         <isset property="clover.present"/>
199
 
                         </and>
200
 
         </condition>
201
 
 
202
 
        <propertyset id="uptodate.and.compiled.properties" dynamic="true">
203
 
                <propertyref regex=".*\.uptodate$$"/>
204
 
                <propertyref regex=".*\.compiled$$"/>
205
 
        </propertyset>
206
 
 
207
 
        <patternset id="lucene.local.src.package.patterns"
208
 
                                                        includes="src/,index.html,*build*.xml,docs/,*.txt,contrib/,lib/,backwards/"
209
 
                                                        excludes="**/pom.xml,**/*.iml,src/site/build/"
210
 
        />
211
 
 
212
 
        <target name="clean"
213
 
                description="Removes contents of build and dist directories">
214
 
                <delete dir="${build.dir}"/>
215
 
                <delete dir="${dist.dir}"/>
216
 
                <delete file="velocity.log"/>
217
 
        </target>
218
 
 
219
 
        <!-- TODO: maybe make JavaCC checking specific to only the projects
220
 
                                                 that use it (Lucene core and contrib/misc
221
 
        -->
222
 
        <target name="javacc-uptodate-check">
223
 
                <uptodate property="javacc.files.uptodate">
224
 
                        <srcfiles dir="${src.dir}" includes="**/*.jj" />
225
 
                        <mapper type="glob" from="*.jj" to="*.java"/>
226
 
                </uptodate>
227
 
        </target>
228
 
 
229
 
        <target name="javacc-notice" depends="javacc-uptodate-check" unless="javacc.files.uptodate">
230
 
                <echo>
231
 
                        One or more of the JavaCC .jj files is newer than its corresponding
232
 
                        .java file.  Run the "javacc" target to regenerate the artifacts.
233
 
                </echo>
234
 
        </target>
235
 
 
236
 
        <target name="init">
237
 
                <!-- currently empty -->
238
 
        </target>
239
 
 
240
 
        <target name="jflex-uptodate-check">
241
 
                <uptodate property="jflex.files.uptodate">
242
 
                        <srcfiles dir="${src.dir}" includes="**/*.jflex" />
243
 
                        <mapper type="glob" from="*.jflex" to="*.java"/>
244
 
                </uptodate>
245
 
        </target>
246
 
 
247
 
        <target name="jflex-notice" depends="jflex-uptodate-check" unless="jflex.files.uptodate">
248
 
                <echo>
249
 
                        One or more of the JFlex .jflex files is newer than its corresponding
250
 
                        .java file.  Run the "jflex" target to regenerate the artifacts.
251
 
                </echo>
252
 
        </target>
253
 
 
254
 
        <target name="javacc-check">
255
 
                <available property="javacc.present" classname="org.javacc.parser.Main">
256
 
                        <classpath refid="javacc.classpath"/>
257
 
                </available>
258
 
                <fail unless="javacc.present">
259
 
                        ##################################################################
260
 
                        JavaCC not found.
261
 
                        JavaCC Home: ${javacc.home}
262
 
 
263
 
                        Please download and install JavaCC 4.1 from:
264
 
 
265
 
                        &lt;http://javacc.dev.java.net&gt;
266
 
 
267
 
                        Then, create a build.properties file either in your home
268
 
                        directory, or within the Lucene directory and set the javacc.home
269
 
                        property to the path where JavaCC is installed. For example,
270
 
                        if you installed JavaCC in /usr/local/java/javacc-4.1, then set the
271
 
                        javacc.home property to:
272
 
 
273
 
                        javacc.home=/usr/local/java/javacc-4.1
274
 
 
275
 
                        If you get an error like the one below, then you have not installed
276
 
                        things correctly. Please check all your paths and try again.
277
 
 
278
 
                        java.lang.NoClassDefFoundError: org.javacc.parser.Main
279
 
                        ##################################################################
280
 
                </fail>
281
 
 
282
 
        </target>
283
 
 
284
 
        <target name="jflex-check">
285
 
                <available property="jflex.present" classname="jflex.anttask.JFlexTask">
286
 
                        <classpath refid="jflex.classpath"/>
287
 
                </available>
288
 
                <fail unless="jflex.present">
289
 
                        ##################################################################
290
 
                        JFlex not found.
291
 
                        JFlex Home: ${jflex.home}
292
 
 
293
 
                        Please install the jFlex 1.5 version (currently not released)
294
 
                        from its SVN repository:
295
 
 
296
 
                         svn co http://jflex.svn.sourceforge.net/svnroot/jflex/trunk jflex
297
 
                         cd jflex
298
 
                         mvn install
299
 
 
300
 
                        Then, create a build.properties file either in your home
301
 
                        directory, or within the Lucene directory and set the jflex.home
302
 
                        property to the path where the JFlex trunk checkout is located
303
 
                        (in the above example its the directory called "jflex").
304
 
 
305
 
                        ##################################################################
306
 
                </fail>
307
 
        </target>
308
 
 
309
 
        <target name="compile-core" depends="init, clover"
310
 
                                        description="Compiles core classes">
311
 
                <compile
312
 
                        srcdir="${src.dir}"
313
 
                        destdir="${build.dir}/classes/java">
314
 
                        <classpath refid="classpath"/>
315
 
                </compile>
316
 
 
317
 
                <!-- Copy the resources folder (if existent) -->
318
 
                <copy todir="${build.dir}/classes/java">
319
 
                        <fileset dir="${src.dir}/../resources" erroronmissingdir="no"/>
320
 
                </copy>
321
 
        </target>
322
 
 
323
 
        <target name="compile" depends="compile-core, validate-lucene">
324
 
                <!-- convenience target to compile core -->
325
 
        </target>
326
 
 
327
 
        <target name="jar-core" depends="compile-core"
328
 
                description="Packages the JAR file">
329
 
                <jarify/>
330
 
        </target>
331
 
 
332
 
        <macrodef name="m2-deploy" description="Builds a Maven artifact">
333
 
                <element name="artifact-attachments" optional="yes"/>
334
 
                <attribute name="pom.xml" default="pom.xml"/>
335
 
                <attribute name="jar.file" default="${build.dir}/${final.name}.jar"/>
336
 
                <sequential>
337
 
                        <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
338
 
                        <artifact:pom id="maven.project" file="@{pom.xml}"/>
339
 
                        <artifact:deploy file="@{jar.file}">
340
 
                                <artifact-attachments/>
341
 
                                <remoteRepository url="${m2.repository.url}">
342
 
                                        <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}" password="${m2.repository.password}"/>
343
 
                                </remoteRepository>
344
 
                                <pom refid="maven.project"/>
345
 
                        </artifact:deploy>
346
 
                </sequential>
347
 
        </macrodef>
348
 
 
349
 
        <macrodef name="m2-deploy-with-pom-template" description="Builds a Maven artifact given a POM template">
350
 
                <attribute name="pom.xml"/>
351
 
                <attribute name="jar.file"/>
352
 
                <sequential>
353
 
                        <copy file="@{pom.xml}" tofile="${maven.build.dir}/pom.xml" overwrite="true">
354
 
                                <filterset begintoken="@" endtoken="@">
355
 
                                        <filter token="version" value="${version}"/>
356
 
                                </filterset>
357
 
                                <filterset begintoken="$${" endtoken="}">
358
 
                                        <filter token="project.version" value="${version}"/>
359
 
                                 </filterset>
360
 
                        </copy>
361
 
                        <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/>
362
 
                        <artifact:pom id="maven.project" file="${maven.build.dir}/pom.xml" />
363
 
                        <artifact:deploy file="@{jar.file}">
364
 
                                <remoteRepository url="${m2.repository.url}">
365
 
                                        <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}" password="${m2.repository.password}"/>
366
 
                                </remoteRepository>
367
 
                                <pom refid="maven.project"/>
368
 
                        </artifact:deploy>
369
 
                </sequential>
370
 
        </macrodef>
371
 
 
372
 
        <macrodef name="build-manifest" description="Builds a manifest file">
373
 
                <attribute name="title"/>
374
 
                <attribute name="implementation.title"/>
375
 
                <attribute name="spec.version"/>
376
 
                <sequential>
377
 
                        <manifest file="${manifest.file}">
378
 
                                <!--
379
 
                                http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Manifest
380
 
                                http://java.sun.com/j2se/1.5.0/docs/guide/versioning/spec/versioning2.html
381
 
                                http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html
382
 
                                http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/package-summary.html
383
 
                                http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
384
 
                                -->
385
 
                                <!-- Don't set 'Manifest-Version' it identifies the version of the
386
 
                                                 manifest file format, and should always be 1.0 (the default)
387
 
 
388
 
                                                 Don't set 'Created-by' attribute, its purpose is
389
 
                                                 to identify the version of java used to build the jar,
390
 
                                                 which ant will do by default.
391
 
 
392
 
                                                 Ant will happily override these with bogus strings if you
393
 
                                                 tell it to, so don't.
394
 
 
395
 
                                                 NOTE: we don't use section info because all of our manifest data
396
 
                                                 applies to the entire jar/war ... no package specific info.
397
 
                                -->
398
 
                                <attribute name="Extension-Name" value="@{implementation.title}"/>
399
 
                                <attribute name="Specification-Title" value="@{title}"/>
400
 
                                <!-- spec version must match "digit+{.digit+}*" -->
401
 
                                <attribute name="Specification-Version" value="@{spec.version}"/>
402
 
                                <attribute name="Specification-Vendor"
403
 
                                                                         value="The Apache Software Foundation"/>
404
 
                                <attribute name="Implementation-Title" value="@{implementation.title}"/>
405
 
                                <!-- impl version can be any string -->
406
 
                                <attribute name="Implementation-Version"
407
 
                                                                         value="${version} ${svnversion} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
408
 
                                <attribute name="Implementation-Vendor"
409
 
                                                                         value="The Apache Software Foundation"/>
410
 
                                <attribute name="X-Compile-Source-JDK" value="${javac.source}"/>
411
 
                                <attribute name="X-Compile-Target-JDK" value="${javac.target}"/>
412
 
                        </manifest>
413
 
                </sequential>
414
 
        </macrodef>
415
 
 
416
 
        <macrodef name="jarify" description="Builds a JAR file">
417
 
                <attribute name="basedir" default="${build.dir}/classes/java"/>
418
 
                <attribute name="destfile" default="${build.dir}/${final.name}.jar"/>
419
 
                <attribute name="title" default="Lucene Search Engine: ${ant.project.name}"/>
420
 
                <attribute name="excludes" default="**/pom.xml,**/*.iml"/>
421
 
                <attribute name="metainf.source.dir" default="${common.dir}"/>
422
 
                <attribute name="implementation.title" default="org.apache.lucene"/>
423
 
                <attribute name="spec.version" default="${spec.version}"/>
424
 
                <element name="nested" optional="true" implicit="true"/>
425
 
                <sequential>
426
 
                        <!-- If possible, include the svnversion -->
427
 
                        <exec dir="." executable="${svnversion.exe}"
428
 
                                                outputproperty="svnversion" failifexecutionfails="false">
429
 
                                <arg line="."/>
430
 
                        </exec>
431
 
 
432
 
                        <build-manifest title="@{title}"
433
 
                                                                                        implementation.title="@{implementation.title}"
434
 
                                                                                        spec.version="@{spec.version}"/>
435
 
 
436
 
                        <jar destfile="@{destfile}"
437
 
                                         basedir="@{basedir}"
438
 
                                         manifest="${manifest.file}"
439
 
                                         excludes="@{excludes}">
440
 
                                <metainf dir="@{metainf.source.dir}" includes="LICENSE.txt,NOTICE.txt"/>
441
 
                                <nested />
442
 
                        </jar>
443
 
                </sequential>
444
 
        </macrodef>
445
 
 
446
 
        <property name="lucene-core.jar" value="${common.dir}/build/lucene-core-${version}.jar"/>
447
 
        <target name="check-lucene-core-uptodate" unless="lucene-core.uptodate">
448
 
                <uptodate property="lucene-core.uptodate" targetfile="${lucene-core.jar}">
449
 
                         <srcfiles dir="${common.dir}/src/java" includes="**/*.java"/>
450
 
                </uptodate>
451
 
        </target>
452
 
        <target name="jar-lucene-core" unless="lucene-core.uptodate" depends="check-lucene-core-uptodate">
453
 
                <ant dir="${common.dir}" target="jar-core" inheritAll="false">
454
 
                        <propertyset refid="uptodate.and.compiled.properties"/>
455
 
                </ant>
456
 
                <property name="lucene-core.uptodate" value="true"/>
457
 
        </target>
458
 
        <target name="compile-lucene-core" unless="core.compiled">
459
 
                <ant dir="${common.dir}" target="compile-core" inheritAll="false">
460
 
                        <propertyset refid="uptodate.and.compiled.properties"/>
461
 
                </ant>
462
 
                <property name="core.compiled" value="true"/>
463
 
        </target>
464
 
 
465
 
        <path id="test-framework.classpath">
466
 
                <path refid="ant-path"/>
467
 
                <path refid="test.classpath"/>
468
 
        </path>
469
 
 
470
 
        <target name="compile-test-framework" depends="compile-core">
471
 
                <compile-test-macro srcdir="${tests-framework.src.dir}" destdir="${common.dir}/build/classes/test-framework"
472
 
                                                        test.classpath="test-framework.classpath"/>
473
 
                         <!-- Copy the resources folder (if existent) -->
474
 
                         <copy todir="${common.dir}/build/classes/test-framework">
475
 
                                        <fileset dir="${tests-framework.src.dir}/../resources" erroronmissingdir="no"/>
476
 
                         </copy>
477
 
        </target>
478
 
 
479
 
        <target name="compile-tools">
480
 
                <compile
481
 
                        srcdir="${common.dir}/src/tools/java"
482
 
                        destdir="${common.build.dir}/classes/tools">
483
 
                        <classpath refid="classpath"/>
484
 
                </compile>
485
 
        </target>
486
 
 
487
 
        <target name="compile-test" depends="compile-test-framework">
488
 
                <compile-test-macro srcdir="${tests.src.dir}" destdir="${build.dir}/classes/test"
489
 
                                                        test.classpath="test.classpath"/>
490
 
        </target>
491
 
 
492
 
        <property name="tests.verbose" value="false"/>
493
 
 
494
 
        <macrodef name="compile-test-macro" description="Compiles junit tests.">
495
 
                <attribute name="srcdir"/>
496
 
                <attribute name="destdir"/>
497
 
                <attribute name="test.classpath"/>
498
 
                <attribute name="javac.source" default="${javac.source}"/>
499
 
                <attribute name="javac.target" default="${javac.target}"/>
500
 
                 <sequential>
501
 
                        <compile
502
 
                                srcdir="@{srcdir}"
503
 
                                destdir="@{destdir}"
504
 
                                javac.source="@{javac.source}"
505
 
                                javac.target="@{javac.source}">
506
 
                                <classpath refid="@{test.classpath}"/>
507
 
                        </compile>
508
 
 
509
 
                        <!-- Copy any data files present to the classpath -->
510
 
                        <copy todir="@{destdir}">
511
 
                                <fileset dir="@{srcdir}" excludes="**/*.java"/>
512
 
                        </copy>
513
 
                </sequential>
514
 
        </macrodef>
515
 
 
516
 
        <macrodef name="test-macro" description="Executes junit tests.">
517
 
                <attribute name="junit.output.dir" default="${junit.output.dir}"/>
518
 
                <attribute name="junit.classpath" default="junit.classpath"/>
519
 
                <attribute name="dataDir" default="${tests.src.dir}"/>
520
 
                <attribute name="tempDir" default="${build.dir}/test"/>
521
 
                <attribute name="threadNum" default="1"/>
522
 
                <attribute name="threadTotal" default="1"/>
523
 
                                <attribute name="tests.nightly" default="${tests.nightly}"/>
524
 
                                <attribute name="tests.multiplier" default="${tests.multiplier}"/>
525
 
 
526
 
                <sequential>
527
 
                        <condition property="runall">
528
 
                                <not><or>
529
 
                                        <isset property="testcase" />
530
 
                                        <isset property="testpackage" />
531
 
                                        <isset property="testpackageroot" />
532
 
                                </or></not>
533
 
                        </condition>
534
 
                        <!-- <mkdir dir="@{tempDir}/@{pattern}"/>
535
 
                        This is very loud and obnoxious. abuse touch instead for a "quiet" mkdir
536
 
                        -->
537
 
                        <touch file="@{tempDir}/@{threadNum}/quiet.ant" verbose="false" mkdirs="true"/>
538
 
                        <junit printsummary="off" haltonfailure="no" maxmemory="512M" tempdir="@{tempDir}/@{threadNum}"
539
 
                                errorProperty="tests.failed" failureProperty="tests.failed" forkmode="perBatch" dir="@{tempDir}/@{threadNum}">
540
 
                                <classpath refid="@{junit.classpath}"/>
541
 
                                <assertions>
542
 
                                                                <enable package="org.apache.lucene"/>
543
 
                                        <enable package="org.apache.solr"/>
544
 
                                </assertions>
545
 
 
546
 
                                <jvmarg line="${args}"/>
547
 
 
548
 
                                <!-- allow tests to control debug prints -->
549
 
                                <sysproperty key="tests.verbose" value="${tests.verbose}"/>
550
 
                                                        <!-- directory for formatter lock -->
551
 
                                <sysproperty key="tests.lockdir" value="${tests.lockdir}"/>
552
 
                                                        <!-- set the locale tests should run with -->
553
 
                                <sysproperty key="tests.locale" value="${tests.locale}"/>
554
 
                                                        <!-- set the timezone tests should run with -->
555
 
                                <sysproperty key="tests.timezone" value="${tests.timezone}"/>
556
 
                                                        <!-- set the directory tests should run with -->
557
 
                                                        <sysproperty key="tests.directory" value="${tests.directory}"/>
558
 
                                                        <!-- set the line file source for oal.util.LineFileDocs -->
559
 
                                                        <sysproperty key="tests.linedocsfile" value="${tests.linedocsfile}"/>
560
 
                                                        <!-- set the number of times tests should run -->
561
 
                                                        <sysproperty key="tests.iter" value="${tests.iter}"/>
562
 
                                                        <!-- set the minimum number of times tests should run unless failure -->
563
 
                                                        <sysproperty key="tests.iter.min" value="${tests.iter.min}"/>
564
 
                                                        <!-- set the test seed -->
565
 
                                                        <sysproperty key="tests.seed" value="${tests.seed}"/>
566
 
                                                        <!-- set the Version that tests should run against -->
567
 
                                                        <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
568
 
                                                        <!-- for lucene we can be strict, and we don't want false fails even across methods -->
569
 
                                                        <sysproperty key="tests.cleanthreads" value="${tests.cleanthreads.sysprop}"/>
570
 
                                                        <!-- logging config file -->
571
 
                                                        <sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
572
 
                                        <!-- set whether or not nightly tests should run -->
573
 
                                        <sysproperty key="tests.nightly" value="@{tests.nightly}"/>
574
 
 
575
 
                                        <!-- set whether tests framework should not require java assertions enabled -->
576
 
                                        <sysproperty key="tests.asserts.gracious" value="${tests.asserts.gracious}"/>
577
 
 
578
 
                                <!-- TODO: create propertyset for test properties, so each project can have its own set -->
579
 
                                                        <sysproperty key="tests.multiplier" value="@{tests.multiplier}"/>
580
 
                                <sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
581
 
 
582
 
                                <sysproperty key="lucene.version" value="${dev.version}"/>
583
 
 
584
 
                                                        <sysproperty key="testmethod" value="${testmethod}"/>
585
 
                                                        <sysproperty key="jetty.testMode" value="1"/>
586
 
                                                        <sysproperty key="jetty.insecurerandom" value="1"/>
587
 
                                                <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
588
 
 
589
 
                                <formatter type="xml"/>
590
 
                                <formatter classname="${junit.details.formatter}" usefile="false"/>
591
 
                                <batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
592
 
                                        <fileset dir="@{dataDir}" includes="**/Test*.java,**/*Test.java" excludes="${junit.excludes}">
593
 
                                                <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
594
 
                                                        <param name="divisor" value="@{threadTotal}" />
595
 
                                                        <param name="part" value="@{threadNum}" />
596
 
                                                </custom>
597
 
                                        </fileset>
598
 
                                </batchtest>
599
 
                                <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackage">
600
 
                                        <fileset dir="@{dataDir}" includes="**/${testpackage}/**/Test*.java,**/${testpackage}/**/*Test.java" excludes="${junit.excludes}">
601
 
                                        <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
602
 
                                                <param name="divisor" value="@{threadTotal}" />
603
 
                                                <param name="part" value="@{threadNum}" />
604
 
                                        </custom>
605
 
                                        </fileset>
606
 
                                </batchtest>
607
 
                                <batchtest fork="yes" todir="@{junit.output.dir}" if="testpackageroot">
608
 
                                        <fileset dir="@{dataDir}" includes="**/${testpackageroot}/Test*.java,**/${testpackageroot}/*Test.java" excludes="${junit.excludes}">
609
 
                                <custom classname="${junit.parallel.selector}" classpathref="@{junit.classpath}">
610
 
                                        <param name="divisor" value="@{threadTotal}" />
611
 
                                        <param name="part" value="@{threadNum}" />
612
 
                                </custom>
613
 
                                        </fileset>
614
 
                                </batchtest>
615
 
                                <batchtest fork="yes" todir="@{junit.output.dir}" if="testcase">
616
 
                                        <fileset dir="@{dataDir}" includes="**/${testcase}.java"/>
617
 
                                </batchtest>
618
 
                        </junit>
619
 
                        <fail if="tests.failed">Tests failed!</fail>
620
 
                </sequential>
621
 
        </macrodef>
622
 
 
623
 
        <target name="test" depends="compile-test,junit-mkdir,junit-sequential,junit-parallel" description="Runs unit tests"/>
624
 
 
625
 
        <target name="junit-mkdir">
626
 
                <mkdir dir="${junit.output.dir}"/>
627
 
        </target>
628
 
 
629
 
        <target name="junit-sequential" if="tests.sequential">
630
 
                <test-macro/>
631
 
        </target>
632
 
 
633
 
        <target name="junit-parallel" unless="tests.sequential">
634
 
                <parallel threadsPerProcessor="${tests.threadspercpu}">
635
 
                 <test-macro threadNum="1" threadTotal="8"/>
636
 
                 <test-macro threadNum="2" threadTotal="8"/>
637
 
                 <test-macro threadNum="3" threadTotal="8"/>
638
 
                 <test-macro threadNum="4" threadTotal="8"/>
639
 
                 <test-macro threadNum="5" threadTotal="8"/>
640
 
                 <test-macro threadNum="6" threadTotal="8"/>
641
 
                 <test-macro threadNum="7" threadTotal="8"/>
642
 
                 <test-macro threadNum="8" threadTotal="8"/>
643
 
                </parallel>
644
 
        </target>
645
 
 
646
 
 
647
 
                <!--
648
 
                 If you want clover test code coverage, run this before the tests.  You need clover.jar and the license in your ANT classspath and you need to specify -Drun.clover=true on the command line.
649
 
 
650
 
                 See http://issues.apache.org/jira/browse/LUCENE-721
651
 
                 -->
652
 
        <target name="clover" depends="clover.setup, clover.info" description="Instrument the Unit tests using Clover.  Requires a Clover 2.x license and clover.jar in the ANT classpath.  To use, specify -Drun.clover=true on the command line."/>
653
 
 
654
 
        <target name="clover.setup" if="clover.enabled">
655
 
                <taskdef resource="cloverlib.xml"/>
656
 
                <mkdir dir="${clover.db.dir}"/>
657
 
                <clover-setup initString="${clover.db.dir}/lucene_coverage.db" encoding="${build.encoding}">
658
 
                        <fileset dir="${src.dir}">
659
 
                                <include name="org/apache/**/*.java" />
660
 
                        </fileset>
661
 
                        <testsources dir="${tests-framework.src.dir}">
662
 
                                <include name="org/apache/**/*.java" />
663
 
                        </testsources>
664
 
                        <testsources dir="${tests.src.dir}">
665
 
                                <include name="org/apache/**/*.java" />
666
 
                        </testsources>
667
 
                </clover-setup>
668
 
        </target>
669
 
 
670
 
        <target name="clover.info" unless="clover.present">
671
 
                <echo>
672
 
                        Clover not found. Code coverage reports disabled.
673
 
                </echo>
674
 
        </target>
675
 
 
676
 
        <target name="clover.check">
677
 
        <fail unless="clover.present">
678
 
                ##################################################################
679
 
                        Clover not found.
680
 
                        Please make sure clover.jar is in ANT_HOME/lib, or made available
681
 
                        to Ant using other mechanisms like -lib or CLASSPATH.
682
 
                        ##################################################################
683
 
                </fail>
684
 
        </target>
685
 
                <!--
686
 
                 Run after Junit tests.
687
 
                 -->
688
 
        <target name="generate-clover-reports" depends="clover.check, clover">
689
 
                <mkdir dir="${clover.report.dir}"/>
690
 
                <!-- This extra path is needed, because from a top-level ant run, the contrib tests would be not visible (report generation is only done on top-level not via subants) -->
691
 
                <fileset dir="contrib" id="clover.contrib.test.src.files">
692
 
                        <include name="**/test/**/*.java"/>
693
 
                </fileset>
694
 
                <fileset dir="${tests-framework.src.dir}" id="clover.test-framework.src.files">
695
 
                        <include name="**/*.java" />
696
 
                </fileset>
697
 
                <fileset dir="${tests.src.dir}" id="clover.test.src.files">
698
 
                        <include name="**/*.java" />
699
 
                </fileset>
700
 
                <fileset dir="${build.dir}" id="clover.test.result.files">
701
 
                        <include name="**/test/TEST-*.xml" />
702
 
                        <!-- do not include BW tests -->
703
 
                        <exclude name="backwards/**"/>
704
 
                </fileset>
705
 
                <clover-report>
706
 
                         <current outfile="${clover.report.dir}" title="${final.name}" numThreads="0">
707
 
                                        <format type="html" filter="assert"/>
708
 
                                        <testsources refid="clover.test.src.files"/>
709
 
                                        <testsources refid="clover.test-framework.src.files"/>
710
 
                                        <testsources refid="clover.contrib.test.src.files"/>
711
 
                                        <testresults refid="clover.test.result.files"/>
712
 
                         </current>
713
 
                         <current outfile="${clover.report.dir}/clover.xml" title="${final.name}">
714
 
                                        <format type="xml" filter="assert"/>
715
 
                                        <testsources refid="clover.test.src.files"/>
716
 
                                        <testsources refid="clover.test-framework.src.files"/>
717
 
                                        <testsources refid="clover.contrib.test.src.files"/>
718
 
                                        <testresults refid="clover.test.result.files"/>
719
 
                         </current>
720
 
                </clover-report>
721
 
        </target>
722
 
 
723
 
        <target name="generate-test-reports" description="Generates test reports">
724
 
                <mkdir dir="${junit.reports}"/>
725
 
                <junitreport todir="${junit.output.dir}">
726
 
                        <!-- this fileset let's the task work for individual contribs,
727
 
                                         as well as the project as a whole
728
 
                         -->
729
 
                        <fileset dir="${build.dir}">
730
 
                                <include name="**/test/TEST-*.xml"/>
731
 
                        </fileset>
732
 
                        <report format="frames" todir="${junit.reports}"/>
733
 
                </junitreport>
734
 
 
735
 
                <mkdir dir="${junit.reports.backwards}"/>
736
 
                <junitreport todir="${junit.output.dir.backwards}">
737
 
                        <!-- this fileset let's the task work for individual contribs,
738
 
                                         as well as the project as a whole
739
 
                         -->
740
 
                        <fileset dir="${build.dir.backwards}">
741
 
                                <include name="**/test/TEST-*.xml"/>
742
 
                        </fileset>
743
 
                        <report format="frames" todir="${junit.reports.backwards}"/>
744
 
                </junitreport>
745
 
        </target>
746
 
 
747
 
        <target name="jar" depends="jar-core">
748
 
                <!-- convenience target to package core JAR -->
749
 
        </target>
750
 
 
751
 
        <target name="jar-src" depends="init">
752
 
                <jarify basedir="${src.dir}" destfile="${build.dir}/${final.name}-src.jar">
753
 
                        <fileset dir="${src.dir}/../resources" erroronmissingdir="no"/>
754
 
                </jarify>
755
 
        </target>
756
 
 
757
 
        <target name="default" depends="jar-core"/>
758
 
 
759
 
        <target name="rat-sources-typedef">
760
 
                <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:rat.anttasks">
761
 
                        <classpath>
762
 
                                <fileset dir="." includes="rat*.jar"/>
763
 
                        </classpath>
764
 
                </typedef>
765
 
        </target>
766
 
 
767
 
        <target name="rat-sources" depends="rat-sources-typedef"
768
 
                description="runs the tasks over source and test files">
769
 
                <rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
770
 
                        <fileset dir="${src.dir}"/>
771
 
                        <fileset dir="${tests-framework.src.dir}"/>
772
 
                        <fileset dir="${tests.src.dir}"/>
773
 
                </rat:report>
774
 
        </target>
775
 
 
776
 
        <!--+
777
 
                        | M A C R O S
778
 
                        +-->
779
 
        <macrodef name="compile">
780
 
                <attribute name="srcdir"/>
781
 
                <attribute name="destdir"/>
782
 
                <attribute name="javac.source" default="${javac.source}"/>
783
 
                <attribute name="javac.target" default="${javac.target}"/>
784
 
                <element name="nested" implicit="yes" optional="yes"/>
785
 
 
786
 
                <sequential>
787
 
                        <mkdir dir="@{destdir}"/>
788
 
                        <javac
789
 
                                includeAntRuntime="${javac.includeAntRuntime}"
790
 
                                encoding="${build.encoding}"
791
 
                                srcdir="@{srcdir}"
792
 
                                destdir="@{destdir}"
793
 
                                deprecation="${javac.deprecation}"
794
 
                                debug="${javac.debug}"
795
 
                                source="@{javac.source}"
796
 
                                target="@{javac.target}">
797
 
                                <nested/>
798
 
                                <!-- <compilerarg line="-Xmaxwarns 10000000"/>
799
 
                                <compilerarg line="-Xmaxerrs 10000000"/> -->
800
 
                                <!-- for generics in Java 1.5: -->
801
 
                                <compilerarg line="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
802
 
                        </javac>
803
 
                </sequential>
804
 
        </macrodef>
805
 
 
806
 
        <macrodef name="invoke-javacc">
807
 
                <attribute name="target"/>
808
 
                <attribute name="outputDir"/>
809
 
                <sequential>
810
 
                        <mkdir dir="@{outputDir}"/>
811
 
                        <javacc
812
 
                                        target="@{target}"
813
 
                                        outputDirectory="@{outputDir}"
814
 
                                        debugTokenManager="${javacc.debug.tokenmgr}"
815
 
                                        debugParser="${javacc.debug.parser}"
816
 
                                        debuglookahead="${javacc.debug.lookahead}"
817
 
                                        javacchome="${javacc.home}"
818
 
                                        jdkversion="${javac.source}"
819
 
                        />
820
 
                        <fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
821
 
                                <containsregexp expression="Generated.*By.*JavaCC"/>
822
 
                        </fixcrlf>
823
 
                </sequential>
824
 
        </macrodef>
825
 
 
826
 
        <property name="failonjavadocwarning" value="true"/>
827
 
        <macrodef name="invoke-javadoc">
828
 
                <element name="sources" optional="yes"/>
829
 
                <attribute name="destdir"/>
830
 
                <attribute name="title" default="${Name} ${version} API"/>
831
 
                <attribute name="overview" default="${src.dir}/overview.html"/>
832
 
                <sequential>
833
 
                        <copy todir="@{destdir}" file="${prettify.dir}/prettify.js" overwrite="false" />
834
 
                        <copy todir="@{destdir}" file="${prettify.dir}/prettify.css" overwrite="false" />
835
 
                        <record name="@{destdir}/log_javadoc.txt" action="start" append="no"/>
836
 
                        <javadoc
837
 
                                        overview="@{overview}"
838
 
                                        packagenames="org.apache.lucene.*,org.apache.solr.*"
839
 
                                        destdir="@{destdir}"
840
 
                                        access="${javadoc.access}"
841
 
                                        encoding="${build.encoding}"
842
 
                                        charset="${javadoc.charset}"
843
 
                                        docencoding="${javadoc.charset}"
844
 
                                        author="true"
845
 
                                        version="true"
846
 
                                        use="true"
847
 
                                        failonerror="true"
848
 
                                        source="${ant.java.version}"
849
 
                                        link="${javadoc.link}"
850
 
                                        windowtitle="${Name} ${version} API"
851
 
                                        doctitle="@{title}"
852
 
                                        stylesheetfile="${prettify.dir}/stylesheet+prettify.css"
853
 
                                        maxmemory="${javadoc.maxmemory}"
854
 
                                        bottom="Copyright &amp;copy; ${year} Apache Software Foundation.  All Rights Reserved.">
855
 
                                <tag name="lucene.experimental"
856
 
                                description="WARNING: This API is experimental and might change in incompatible ways in the next release."/>
857
 
                                <tag name="lucene.internal"
858
 
                                description="NOTE: This API is for internal purposes only and might change in incompatible ways in the next release."/>
859
 
                                <link offline="true" packagelistLoc="${javadoc.dir}"/>
860
 
                                <header><![CDATA[
861
 
                                         <script src="{@docRoot}/prettify.js" type="text/javascript"></script>
862
 
                                         <script language="JavaScript">window.onload=function(){windowTitle();prettyPrint();}</script>
863
 
                                ]]></header>
864
 
 
865
 
                                <sources />
866
 
 
867
 
                                <classpath refid="javadoc.classpath"/>
868
 
                        </javadoc>
869
 
                        <record name="@{destdir}/log_javadoc.txt" action="stop"/>
870
 
 
871
 
                        <delete>
872
 
                                <fileset file="@{destdir}/log_javadoc.txt">
873
 
                                        <or>
874
 
                                                <not>
875
 
                                                        <containsregexp expression="\[javadoc\]\s*[1-9][0-9]*\s*warning"/>
876
 
                                                </not>
877
 
                                                <and>
878
 
                                                        <!-- allow 1 warning, if there is also a bootstrap warning generated by Java7 -->
879
 
                                                        <containsregexp expression="\[javadoc\]\s*warning.*bootstrap"/>
880
 
                                                        <containsregexp expression="\[javadoc\]\s*1\s*warning"/>
881
 
                                                </and>
882
 
                                        </or>
883
 
                                </fileset>
884
 
                        </delete>
885
 
 
886
 
                        <fail message="Javadocs warnings were found!">
887
 
                                <condition>
888
 
                                        <and>
889
 
                                                <available file="@{destdir}/log_javadoc.txt"/>
890
 
                                                <istrue value="${failonjavadocwarning}"/>
891
 
                                        </and>
892
 
                                </condition>
893
 
                        </fail>
894
 
 
895
 
 
896
 
         </sequential>
897
 
        </macrodef>
898
 
 
899
 
        <macrodef name="contrib-crawl">
900
 
                <attribute name="target" default=""/>
901
 
                <attribute name="failonerror" default="true"/>
902
 
                <sequential>
903
 
                        <subant target="@{target}" failonerror="@{failonerror}" inheritall="false">
904
 
                                <propertyset refid="uptodate.and.compiled.properties"/>
905
 
                                <fileset dir="." includes="contrib/*/build.xml"/>
906
 
                        </subant>
907
 
                </sequential>
908
 
        </macrodef>
909
 
 
910
 
        <!-- VALIDATION work -->
911
 
        <!--
912
 
         >find . -name lib
913
 
./lucene/backwards/lib
914
 
./lucene/contrib/ant/lib
915
 
./lucene/contrib/benchmark/lib
916
 
./lucene/contrib/db/bdb/lib
917
 
./lucene/contrib/db/bdb-je/lib
918
 
./lucene/contrib/icu/lib
919
 
./lucene/contrib/lucli/lib
920
 
./lucene/contrib/queries/lib
921
 
./lucene/lib
922
 
 
923
 
 
924
 
         -->
925
 
        <target name="check-legal-lucene" depends="compile-tools">
926
 
                <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
927
 
                        <classpath>
928
 
                                <path refid="tools.runtime.classpath" />
929
 
                        </classpath>
930
 
                        <!-- TODO: it might be better to just automatically find all directories that contain jar files, but that could take a
931
 
                         long time.  This should be faster, but we could miss a directory
932
 
                         TODO: convert this to just check whichever library is currently being built
933
 
                         -->
934
 
                        <!-- Lucene  -->
935
 
                        <arg value="-c" />
936
 
                        <arg value="${common.dir}/lib" />
937
 
                        <arg value="-c" />
938
 
                        <arg value="${common.dir}/contrib/benchmark/lib" />
939
 
                        <arg value="-c" />
940
 
                        <arg value="${common.dir}/contrib/icu/lib" />
941
 
 
942
 
                        <arg value="-c" />
943
 
                        <arg value="${common.dir}/contrib/lucli/lib" />
944
 
                        <arg value="-c" />
945
 
                        <arg value="${common.dir}/contrib/queries/lib" />
946
 
                </java>
947
 
        </target>
948
 
 
949
 
        <target name="check-legal" depends="check-legal-lucene"/>
950
 
 
951
 
        <target name="validate-lucene" depends="check-legal-lucene" unless="validated-lucene"/>
952
 
 
953
 
        <!-- Generic placeholder target for if we add other validation tasks -->
954
 
        <target name="validate" depends="validate-lucene"/>
955
 
 
956
 
        <property name="svn.export.dir" location="${build.dir}/svn-export"/>
957
 
        <macrodef name="svn-export-source"
958
 
                                                description="Runs 'svn export' with the same URL and revision as the current working copy.">
959
 
                <attribute name="source.dir"/>
960
 
                <sequential>
961
 
                        <delete dir="${svn.export.dir}" includeemptydirs="true" failonerror="false"/>
962
 
                        <get-svn-info directory="@{source.dir}"/>
963
 
                        <exec dir="@{source.dir}" executable="${svn.exe}" failonerror="true">
964
 
                                <arg value="export"/>
965
 
                                <arg value="--native-eol"/>
966
 
                                <arg value="LF"/>
967
 
                                <arg value="-r"/>
968
 
                                <arg value="${svn.Revision}"/>
969
 
                                <arg value="${svn.URL}"/>
970
 
                                <arg value="${svn.export.dir}"/>
971
 
                        </exec>
972
 
                </sequential>
973
 
        </macrodef>
974
 
 
975
 
        <macrodef name="get-svn-info"
976
 
                                                description="Populates properties svn.URL and svn.Revision using 'svn info'.">
977
 
                <attribute name="directory"/>
978
 
                <sequential>
979
 
                        <exec dir="." executable="${svnversion.exe}" outputproperty="svn.ver"/>
980
 
                        <fail message="A subversion checkout is required for this target">
981
 
                                <condition>
982
 
                                        <equals arg1="${svn.ver}" arg2="exported"/>
983
 
                                </condition>
984
 
                        </fail>
985
 
                        <exec dir="@{directory}" executable="${svn.exe}" outputproperty="svn.info" failonerror="true">
986
 
                                <arg value="info"/>
987
 
                        </exec>
988
 
                        <loadproperties>
989
 
                                <propertyresource name="svn.info"/>
990
 
                                <filterchain>
991
 
                                        <linecontainsregexp>
992
 
                                                <regexp pattern="(URL|Revision):"/>
993
 
                                        </linecontainsregexp>
994
 
                                        <replacestring from=": " to="="/>
995
 
                                        <prefixlines prefix="svn."/>
996
 
                                </filterchain>
997
 
                        </loadproperties>
998
 
                </sequential>
999
 
        </macrodef>
1000
 
 
1001
 
        <macrodef name="make-checksums" description="Macro for building checksum files">
1002
 
                <attribute name="file"/>
1003
 
                <sequential>
1004
 
                        <echo>Building checksums for '@{file}'</echo>
1005
 
                        <checksum file="@{file}" algorithm="md5" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
1006
 
                        <checksum file="@{file}" algorithm="sha1" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
1007
 
                </sequential>
1008
 
        </macrodef>
1009
 
 
1010
 
        <macrodef name="sign-artifacts-macro">
1011
 
                <attribute name="artifacts.dir"/>
1012
 
                <sequential>
1013
 
                        <delete failonerror="false">
1014
 
                                <fileset dir="@{artifacts.dir}">
1015
 
                                        <include name="**/*.asc"/>
1016
 
                                </fileset>
1017
 
                        </delete>
1018
 
 
1019
 
                        <available property="gpg.input.handler" classname="org.apache.tools.ant.input.SecureInputHandler"
1020
 
                                                                 value="org.apache.tools.ant.input.SecureInputHandler"/>
1021
 
                        <!--else:--><property name="gpg.input.handler" value="org.apache.tools.ant.input.DefaultInputHandler"/>
1022
 
                        <input message="Enter GPG keystore password: >" addproperty="gpg.passphrase">
1023
 
                                <handler classname="${gpg.input.handler}" />
1024
 
                        </input>
1025
 
 
1026
 
                        <apply executable="${gpg.exe}" inputstring="${gpg.passphrase}"
1027
 
                                                 dest="@{artifacts.dir}" type="file" maxparallel="1" verbose="yes">
1028
 
                                <arg value="--passphrase-fd"/>
1029
 
                                <arg value="0"/>
1030
 
                                <arg value="--batch"/>
1031
 
                                <arg value="--armor"/>
1032
 
                                <arg value="--default-key"/>
1033
 
                                <arg value="${gpg.key}"/>
1034
 
                                <arg value="--output"/>
1035
 
                                <targetfile/>
1036
 
                                <arg value="--detach-sig"/>
1037
 
                                <srcfile/>
1038
 
 
1039
 
                                <fileset dir="@{artifacts.dir}">
1040
 
                                        <include name="**/*.jar"/>
1041
 
                                        <include name="**/*.zip"/>
1042
 
                                        <include name="**/*.tgz"/>
1043
 
                                        <include name="**/*.pom"/>
1044
 
                                </fileset>
1045
 
                                <globmapper from="*" to="*.asc"/>
1046
 
                        </apply>
1047
 
                </sequential>
1048
 
        </macrodef>
1049
 
 
1050
 
        <property name="rc" value="rc0"/>
1051
 
        <property name="remote.staging.dir" value="public_html/staging_area/${rc}/${version}"/>
1052
 
        <property name="keyfile" value="${user.home}/.ssh/id_rsa"/>
1053
 
        <property name="scp.user" value="${user.name}"/>
1054
 
        <!--keys.dir is the location of the https://svn.apache.org/repos/asf/lucene/java/dist/ directory-->
1055
 
        <property name="keys.dir" value="${common.dir}/../../dist"/>
1056
 
        <macrodef name="copy-to-stage-macro">
1057
 
                <attribute name="artifacts.dir"/>
1058
 
                <sequential>
1059
 
                        <sshexec host="people.apache.org"
1060
 
                                                         username="${scp.user}"
1061
 
                                                         keyfile="${keyfile}"
1062
 
                                                         command="mkdir -p ${remote.staging.dir}"/>
1063
 
                        <echo>Uploading artifacts to ${scp.user}@people.apache.org:${remote.staging.dir}</echo>
1064
 
                        <scp todir="${scp.user}@people.apache.org:${remote.staging.dir}"
1065
 
                                         username="${scp.user}"
1066
 
                                         keyfile="${keyfile}"
1067
 
                                         verbose="true">
1068
 
                                <fileset dir="${artifacts.dir}"/>
1069
 
                                <fileset dir="${keys.dir}">
1070
 
                                        <include name="KEYS"/>
1071
 
                                </fileset>
1072
 
                        </scp>
1073
 
                </sequential>
1074
 
        </macrodef>
1075
 
 
1076
 
</project>