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
11 http://www.apache.org/licenses/LICENSE-2.0
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.
20 <project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
22 This file is designed for importing into a main build file, and not intended
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"/>
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"/>
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" />
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}"/>
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}"/>
62 <fileset dir="${common.dir}/lib" includes="ant-*.jar"/>
65 <path id="tools.runtime.classpath">
66 <pathelement location="${common.dir}/build/classes/tools"/>
69 <path id="maven-ant-tasks.classpath">
70 <fileset dir="${common.dir}/lib">
71 <include name="maven-ant-tasks-*.jar"/>
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">
81 <isset property="testcase"/>
82 <equals arg1="${tests.threadspercpu}" arg2="0"/>
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"/>
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
105 <property name="javac.includeAntRuntime" value="${run.clover}"/>
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"/>
117 <exclude name="build/**/*.jar"/>
118 <include name="**/lib/*.jar"/>
122 <property name="changes.src.dir" value="${common.dir}/src/site/changes"/>
123 <property name="changes.target.dir" value="${common.dir}/build/docs/changes"/>
125 <property name="project.name" value="site"/> <!-- todo: is this used by anakia or something else? -->
126 <property name="build.encoding" value="utf-8"/>
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"/>
139 <property name="javacc.home" location="${common.dir}"/>
140 <property name="jflex.home" location="${common.dir}"/>
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"/>
151 <path id="javacc.classpath">
152 <fileset dir="${javacc.home}/">
153 <include name="bin/lib/*.jar"/>
157 <property name="backwards.dir" location="backwards"/>
158 <property name="build.dir.backwards" location="${build.dir}/backwards"/>
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"/>
170 <property name="junit.parallel.selector" value="org.apache.lucene.util.LuceneJUnitDividingSelector"/>
172 <property name="manifest.file" location="${common.dir}/build/MANIFEST.MF"/>
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)
180 <property name="svnversion.exe" value="svnversion" />
181 <property name="svn.exe" value="svn" />
183 <property name="gpg.exe" value="gpg" />
184 <property name="gpg.key" value="CODE SIGNING KEY" />
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"/>
190 property="clover.present"
191 classname="com.cenqua.clover.tasks.CloverReportTask"
193 <condition property="clover.enabled">
195 <isset property="run.clover"/>
196 <isset property="clover.present"/>
200 <propertyset id="uptodate.and.compiled.properties" dynamic="true">
201 <propertyref regex=".*\.uptodate$$"/>
202 <propertyref regex=".*\.compiled$$"/>
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/"
211 description="Removes contents of build and dist directories">
212 <delete dir="${build.dir}"/>
213 <delete dir="${dist.dir}"/>
214 <delete file="velocity.log"/>
217 <!-- TODO: maybe make JavaCC checking specific to only the projects
218 that use it (Lucene core and contrib/misc
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"/>
227 <target name="javacc-notice" depends="javacc-uptodate-check" unless="javacc.files.uptodate">
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.
235 <!-- currently empty -->
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"/>
245 <target name="jflex-notice" depends="jflex-uptodate-check" unless="jflex.files.uptodate">
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.
252 <target name="javacc-check">
253 <available property="javacc.present" classname="org.javacc.parser.Main">
254 <classpath refid="javacc.classpath"/>
256 <fail unless="javacc.present">
257 ##################################################################
259 JavaCC Home: ${javacc.home}
261 Please download and install JavaCC 4.1 from:
263 <http://javacc.dev.java.net>
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:
271 javacc.home=/usr/local/java/javacc-4.1
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.
276 java.lang.NoClassDefFoundError: org.javacc.parser.Main
277 ##################################################################
282 <target name="jflex-check">
283 <available property="jflex.present" classname="jflex.anttask.JFlexTask">
284 <classpath refid="jflex.classpath"/>
286 <fail unless="jflex.present">
287 ##################################################################
289 JFlex Home: ${jflex.home}
291 Please install the jFlex 1.5 version (currently not released)
292 from its SVN repository:
294 svn co http://jflex.svn.sourceforge.net/svnroot/jflex/trunk jflex
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").
303 ##################################################################
307 <target name="compile-core" depends="init, clover"
308 description="Compiles core classes">
311 destdir="${build.dir}/classes/java">
312 <classpath refid="classpath"/>
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/**"/>
322 <target name="compile" depends="compile-core, validate-lucene">
323 <!-- convenience target to compile core -->
326 <target name="jar-core" depends="compile-core"
327 description="Packages the JAR file">
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"/>
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}"/>
343 <pom refid="maven.project"/>
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"/>
352 <copy file="@{pom.xml}" tofile="${maven.build.dir}/pom.xml" overwrite="true">
353 <filterset begintoken="@" endtoken="@">
354 <filter token="version" value="${version}"/>
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}"/>
363 <pom refid="maven.project"/>
368 <macrodef name="build-manifest" description="Builds a manifest file">
369 <attribute name="title"/>
370 <attribute name="implementation.title"/>
371 <attribute name="spec.version"/>
373 <manifest file="${manifest.file}">
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
381 <!-- Don't set 'Manifest-Version' it identifies the version of the
382 manifest file format, and should always be 1.0 (the default)
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.
388 Ant will happily override these with bogus strings if you
389 tell it to, so don't.
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.
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}"/>
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"/>
422 <!-- If possible, include the svnversion -->
423 <exec dir="." executable="${svnversion.exe}"
424 outputproperty="svnversion" failifexecutionfails="false">
428 <build-manifest title="@{title}"
429 implementation.title="@{implementation.title}"
430 spec.version="@{spec.version}"/>
432 <jar destfile="@{destfile}"
434 manifest="${manifest.file}"
435 excludes="@{excludes}">
436 <metainf dir="@{metainf.source.dir}" includes="LICENSE.txt,NOTICE.txt"/>
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"/>
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"/>
452 <property name="lucene-core.uptodate" value="true"/>
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"/>
458 <property name="core.compiled" value="true"/>
461 <path id="test-framework.classpath">
462 <path refid="ant-path"/>
463 <path refid="test.classpath"/>
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"/>
471 <target name="compile-tools">
473 srcdir="${common.dir}/src/tools/java"
474 destdir="${common.build.dir}/classes/tools">
475 <classpath refid="classpath"/>
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"/>
484 <property name="tests.verbose" value="false"/>
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}"/>
496 javac.source="@{javac.source}"
497 javac.target="@{javac.source}">
498 <classpath refid="@{test.classpath}"/>
501 <!-- Copy any data files present to the classpath -->
502 <copy todir="@{destdir}">
503 <fileset dir="@{srcdir}" excludes="**/*.java"/>
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}"/>
519 <condition property="runall">
521 <isset property="testcase" />
522 <isset property="testpackage" />
523 <isset property="testpackageroot" />
526 <!-- <mkdir dir="@{tempDir}/@{pattern}"/>
527 This is very loud and obnoxious. abuse touch instead for a "quiet" mkdir
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}"/>
534 <enable package="org.apache.lucene"/>
535 <enable package="org.apache.solr"/>
538 <jvmarg line="${args}"/>
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}"/>
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}"/>
569 <sysproperty key="lucene.version" value="${dev.version}"/>
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"/>
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}" />
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}" />
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}" />
602 <batchtest fork="yes" todir="@{junit.output.dir}" if="testcase">
603 <fileset dir="@{dataDir}" includes="**/${testcase}.java"/>
606 <fail if="tests.failed">Tests failed!</fail>
610 <target name="test" depends="compile-test,junit-mkdir,junit-sequential,junit-parallel" description="Runs unit tests"/>
612 <target name="junit-mkdir">
613 <mkdir dir="${junit.output.dir}"/>
616 <target name="junit-sequential" if="tests.sequential">
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"/>
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.
637 See http://issues.apache.org/jira/browse/LUCENE-721
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."/>
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" />
648 <testsources dir="${tests-framework.src.dir}">
649 <include name="org/apache/**/*.java" />
651 <testsources dir="${tests.src.dir}">
652 <include name="org/apache/**/*.java" />
657 <target name="clover.info" unless="clover.present">
659 Clover not found. Code coverage reports disabled.
663 <target name="clover.check">
664 <fail unless="clover.present">
665 ##################################################################
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 ##################################################################
673 Run after Junit tests.
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"/>
681 <fileset dir="${tests-framework.src.dir}" id="clover.test.src.files">
682 <include name="**/*.java" />
684 <fileset dir="${tests.src.dir}" id="clover.test.src.files">
685 <include name="**/*.java" />
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/**"/>
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"/>
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"/>
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
714 <fileset dir="${build.dir}">
715 <include name="**/test/TEST-*.xml"/>
717 <report format="frames" todir="${junit.reports}"/>
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
725 <fileset dir="${build.dir.backwards}">
726 <include name="**/test/TEST-*.xml"/>
728 <report format="frames" todir="${junit.reports.backwards}"/>
732 <target name="jar" depends="jar-core">
733 <!-- convenience target to package core JAR -->
736 <target name="jar-src" depends="init">
737 <jarify basedir="${src.dir}" destfile="${build.dir}/${final.name}-src.jar"/>
740 <target name="default" depends="jar-core"/>
742 <target name="rat-sources-typedef">
743 <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:rat.anttasks">
745 <fileset dir="." includes="rat*.jar"/>
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}"/>
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"/>
770 <mkdir dir="@{destdir}"/>
772 includeAntRuntime="${javac.includeAntRuntime}"
773 encoding="${build.encoding}"
776 deprecation="${javac.deprecation}"
777 debug="${javac.debug}"
778 source="@{javac.source}"
779 target="@{javac.target}">
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"/>
789 <macrodef name="invoke-javacc">
790 <attribute name="target"/>
791 <attribute name="outputDir"/>
793 <mkdir dir="@{outputDir}"/>
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}"
803 <fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
804 <containsregexp expression="Generated.*By.*JavaCC"/>
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"/>
816 <copy todir="@{destdir}/../prettify" overwrite="false">
817 <fileset dir="${prettify.dir}"/>
819 <record name="@{destdir}/log_javadoc.txt" action="start" append="no"/>
821 overview="@{overview}"
822 packagenames="org.apache.lucene.*,org.apache.solr.*"
824 access="${javadoc.access}"
825 encoding="${build.encoding}"
826 charset="${javadoc.charset}"
827 docencoding="${javadoc.charset}"
832 source="${ant.java.version}"
833 link="${javadoc.link}"
834 windowtitle="${Name} ${version} API"
836 stylesheetfile="@{destdir}/../prettify/stylesheet+prettify.css"
837 maxmemory="${javadoc.maxmemory}"
838 bottom="Copyright &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}"/>
845 <script src="{@docRoot}/../prettify/prettify.js" type="text/javascript"></script>
846 <script language="JavaScript">window.onload=function(){windowTitle();prettyPrint();}</script>
851 <classpath refid="javadoc.classpath"/>
853 <record name="@{destdir}/log_javadoc.txt" action="stop"/>
856 <fileset file="@{destdir}/log_javadoc.txt">
859 <containsregexp expression="\[javadoc\]\s*[1-9][0-9]*\s*warning"/>
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"/>
870 <fail message="Javadocs warnings were found!">
873 <available file="@{destdir}/log_javadoc.txt"/>
874 <istrue value="${failonjavadocwarning}"/>
883 <macrodef name="contrib-crawl">
884 <attribute name="target" default=""/>
885 <attribute name="failonerror" default="true"/>
887 <subant target="@{target}" failonerror="@{failonerror}" inheritall="false">
888 <propertyset refid="uptodate.and.compiled.properties"/>
889 <fileset dir="." includes="contrib/*/build.xml"/>
894 <!-- VALIDATION work -->
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
909 <target name="check-legal-lucene" depends="compile-tools">
910 <java classname="org.apache.lucene.validation.DependencyChecker" failonerror="true" fork="true">
912 <path refid="tools.runtime.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
920 <arg value="${common.dir}/lib" />
922 <arg value="${common.dir}/contrib/benchmark/lib" />
924 <arg value="${common.dir}/contrib/icu/lib" />
927 <arg value="${common.dir}/contrib/lucli/lib" />
929 <arg value="${common.dir}/contrib/queries/lib" />
933 <target name="check-legal" depends="check-legal-lucene"/>
935 <target name="validate-lucene" depends="check-legal-lucene" unless="validated-lucene"/>
937 <!-- Generic placeholder target for if we add other validation tasks -->
938 <target name="validate" depends="validate-lucene"/>
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"/>
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"/>
952 <arg value="${svn.Revision}"/>
953 <arg value="${svn.URL}"/>
954 <arg value="${svn.export.dir}"/>
959 <macrodef name="get-svn-info"
960 description="Populates properties svn.URL and svn.Revision using 'svn info'.">
961 <attribute name="directory"/>
963 <exec dir="." executable="${svnversion.exe}" outputproperty="svn.ver"/>
964 <fail message="A subversion checkout is required for this target">
966 <equals arg1="${svn.ver}" arg2="exported"/>
969 <exec dir="@{directory}" executable="${svn.exe}" outputproperty="svn.info" failonerror="true">
973 <propertyresource name="svn.info"/>
976 <regexp pattern="(URL|Revision):"/>
977 </linecontainsregexp>
978 <replacestring from=": " to="="/>
979 <prefixlines prefix="svn."/>
985 <macrodef name="make-checksums" description="Macro for building checksum files">
986 <attribute name="file"/>
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"/>
994 <macrodef name="sign-artifacts-macro">
995 <attribute name="artifacts.dir"/>
997 <delete failonerror="false">
998 <fileset dir="@{artifacts.dir}">
999 <include name="**/*.asc"/>
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}" />
1010 <apply executable="${gpg.exe}" inputstring="${gpg.passphrase}"
1011 dest="@{artifacts.dir}" type="file" maxparallel="1" verbose="yes">
1012 <arg value="--passphrase-fd"/>
1014 <arg value="--batch"/>
1015 <arg value="--armor"/>
1016 <arg value="--default-key"/>
1017 <arg value="${gpg.key}"/>
1018 <arg value="--output"/>
1020 <arg value="--detach-sig"/>
1023 <fileset dir="@{artifacts.dir}">
1024 <include name="**/*.jar"/>
1025 <include name="**/*.zip"/>
1026 <include name="**/*.tgz"/>
1027 <include name="**/*.pom"/>
1029 <globmapper from="*" to="*.asc"/>
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"/>
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}"
1052 <fileset dir="${artifacts.dir}"/>
1053 <fileset dir="${keys.dir}">
1054 <include name="KEYS"/>