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