|
Lucene example source code file (common-build.xml)
The Lucene common-build.xml source code<?xml version="1.0"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <description> This file is designed for importing into a main build file, and not intended for standalone use. </description> <dirname file="${ant.file.common}" property="common.dir"/> <property name="dev-tools.dir" value="${common.dir}/../dev-tools"/> <property name="prettify.dir" value="${common.dir}/src/tools/prettify"/> <property name="maven.build.dir" value="${common.dir}/build/maven"/> <!-- Give user a chance to override without editing this file (and without typing -D each time it compiles it --> <property file="${user.home}/lucene.build.properties"/> <property file="${user.home}/build.properties"/> <property file="${basedir}/build.properties"/> <property file="${common.dir}/build.properties"/> <tstamp> <format property="current.year" pattern="yyyy"/> <format property="DSTAMP" pattern="yyyy-MM-dd"/> <format property="TSTAMP" pattern="HH:mm:ss"/> </tstamp> <property name="name" value="${ant.project.name}"/> <property name="Name" value="Lucene"/> <property name="dev.version" value="3.3-SNAPSHOT"/> <property name="tests.luceneMatchVersion" value="3.3"/> <property name="version" value="${dev.version}"/> <property name="spec.version" value="${version}"/> <property name="year" value="2000-${current.year}"/> <property name="final.name" value="lucene-${name}-${version}"/> <property name="junit.jar" value="junit-4.7.jar"/> <property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/> <path id="junit-path"> <pathelement location="${junit-location.jar}"/> </path> <path id="ant-path"> <fileset dir="${common.dir}/lib" includes="ant-*.jar"/> </path> <path id="tools.runtime.classpath"> <pathelement location="${common.dir}/build/classes/tools"/> </path> <path id="maven-ant-tasks.classpath"> <fileset dir="${common.dir}/lib"> <include name="maven-ant-tasks-*.jar"/> </fileset> </path> <!-- default arguments to pass to JVM executing tests --> <property name="testmethod" value=""/> <property name="args" value=""/> <property name="tests.threadspercpu" value="1" /> <condition property="tests.sequential"> <or> <isset property="testcase"/> <equals arg1="${tests.threadspercpu}" arg2="0"/> </or> </condition> <property name="tests.multiplier" value="1" /> <property name="tests.locale" value="random" /> <property name="tests.timezone" value="random" /> <property name="tests.directory" value="random" /> <property name="tests.linedocsfile" value="europarl.lines.txt.gz" /> <property name="tests.iter" value="1" /> <property name="tests.iter.min" value="${tests.iter}" /> <property name="tests.seed" value="random" /> <property name="tests.loggingfile" value="/dev/null"/> <property name="tests.nightly" value="false" /> <property name="javac.deprecation" value="off"/> <property name="javac.debug" value="on"/> <property name="javac.source" value="1.5"/> <property name="javac.target" value="1.5"/> <property name="javac.source.backwards" value="1.5"/> <property name="javac.target.backwards" value="1.5"/> <!-- clover wants to run with -lib, otherwise we prefer a repeatable classpath --> <property name="javac.includeAntRuntime" value="${run.clover}"/> <property name="javadoc.link" value="http://java.sun.com/j2se/1.5/docs/api/"/> <property name="javadoc.access" value="protected"/> <property name="javadoc.charset" value="utf-8"/> <property name="javadoc.dir" value="${common.dir}/build/docs/api"/> <property name="javadoc.maxmemory" value="512m" /> <!-- Javadoc classpath --> <path id="javadoc.classpath"> <path refid="classpath"/> <pathelement location="${ant.home}/lib/ant.jar"/> <fileset dir="."> <exclude name="build/**/*.jar"/> <include name="**/lib/*.jar"/> </fileset> </path> <property name="changes.src.dir" value="${common.dir}/src/site/changes"/> <property name="changes.target.dir" value="${common.dir}/build/docs/changes"/> <property name="project.name" value="site"/> <property name="build.encoding" value="utf-8"/> <property name="src.dir" location="src/java"/> <property name="tests.src.dir" location="src/test"/> <property name="tests-framework.src.dir" location="${common.dir}/src/test-framework"/> <property name="build.dir" location="build"/> <!-- Needed in case a contrib needs the original build, also for compile-tools to be called from contrib --> <property name="common.build.dir" location="${common.dir}/build"/> <property name="dist.dir" location="dist"/> <property name="maven.dist.dir" location="dist/maven"/> <property name="m2.repository.url" value="file://${maven.dist.dir}"/> <property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/> <property name="javacc.home" location="${common.dir}"/> <property name="jflex.home" location="${common.dir}"/> <path id="jflex.classpath"> <fileset dir="${jflex.home}/"> <!-- for a JFlex trunk checkout: --> <include name="jflex/target/*.jar"/> <!-- for a JFlex distribution (not yet available): --> <include name="lib/*.jar"/> </fileset> </path> <path id="javacc.classpath"> <fileset dir="${javacc.home}/"> <include name="bin/lib/*.jar"/> </fileset> </path> <property name="backwards.dir" location="backwards"/> <property name="build.dir.backwards" location="${build.dir}/backwards"/> <property name="junit.output.dir" location="${build.dir}/test"/> <property name="junit.output.dir.backwards" location="${build.dir.backwards}/test"/> <property name="junit.reports" location="${build.dir}/test/reports"/> <property name="junit.reports.backwards" location="${build.dir.backwards}/test/reports"/> <property name="junit.excludes" value=""/> <condition property="junit.details.formatter" value="org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter" else="org.apache.lucene.util.LuceneJUnitResultFormatter"> <isset property="tests.sequential"/> </condition> <property name="junit.parallel.selector" value="org.apache.lucene.util.LuceneJUnitDividingSelector"/> <property name="manifest.file" location="${common.dir}/build/MANIFEST.MF"/> <!-- we attempt to exec svnversion to get details build information for jar manifests. this property can be set at runtime to an explicit path as needed, or ant will just try to find it in the default PATH. (this is useful for Hudson) --> <property name="svnversion.exe" value="svnversion" /> <property name="svn.exe" value="svn" /> <property name="gpg.exe" value="gpg" /> <property name="gpg.key" value="CODE SIGNING KEY" /> <property name="clover.db.dir" location="${common.dir}/build/test/clover/db"/> <property name="clover.report.dir" location="${common.dir}/build/test/clover/reports"/> <available property="clover.present" classname="com.cenqua.clover.tasks.CloverReportTask" /> <condition property="clover.enabled"> <and> <isset property="run.clover"/> <isset property="clover.present"/> </and> </condition> <target name="clean" description="Removes contents of build and dist directories"> <delete dir="${build.dir}"/> <delete dir="${dist.dir}"/> <delete file="velocity.log"/> </target> <!-- TODO: maybe make JavaCC checking specific to only the projects that use it (Lucene core and contrib/misc --> <target name="javacc-uptodate-check"> <uptodate property="javacc.files.uptodate"> <srcfiles dir="${src.dir}" includes="**/*.jj" /> <mapper type="glob" from="*.jj" to="*.java"/> </uptodate> </target> <target name="javacc-notice" depends="javacc-uptodate-check" unless="javacc.files.uptodate"> <echo> One or more of the JavaCC .jj files is newer than its corresponding .java file. Run the "javacc" target to regenerate the artifacts. </echo> </target> <target name="init"> <!-- currently empty --> </target> <target name="jflex-uptodate-check"> <uptodate property="jflex.files.uptodate"> <srcfiles dir="${src.dir}" includes="**/*.jflex" /> <mapper type="glob" from="*.jflex" to="*.java"/> </uptodate> </target> <target name="jflex-notice" depends="jflex-uptodate-check" unless="jflex.files.uptodate"> <echo> One or more of the JFlex .jflex files is newer than its corresponding .java file. Run the "jflex" target to regenerate the artifacts. </echo> </target> <target name="javacc-check"> <available property="javacc.present" classname="org.javacc.parser.Main"> <classpath refid="javacc.classpath"/> </available> <fail unless="javacc.present"> ################################################################## JavaCC not found. JavaCC Home: ${javacc.home} Please download and install JavaCC 4.1 from: <http://javacc.dev.java.net> Then, create a build.properties file either in your home directory, or within the Lucene directory and set the javacc.home property to the path where JavaCC is installed. For example, if you installed JavaCC in /usr/local/java/javacc-4.1, then set the javacc.home property to: javacc.home=/usr/local/java/javacc-4.1 If you get an error like the one below, then you have not installed things correctly. Please check all your paths and try again. java.lang.NoClassDefFoundError: org.javacc.parser.Main ################################################################## </fail> </target> <target name="jflex-check"> <available property="jflex.present" classname="jflex.anttask.JFlexTask"> <classpath refid="jflex.classpath"/> </available> <fail unless="jflex.present"> ################################################################## JFlex not found. JFlex Home: ${jflex.home} Please install the jFlex 1.5 version (currently not released) from its SVN repository: svn co http://jflex.svn.sourceforge.net/svnroot/jflex/trunk jflex cd jflex mvn install Then, create a build.properties file either in your home directory, or within the Lucene directory and set the jflex.home property to the path where the JFlex trunk checkout is located (in the above example its the directory called "jflex"). ################################################################## </fail> </target> <target name="compile-core" depends="init, clover" description="Compiles core classes"> <compile srcdir="${src.dir}" destdir="${build.dir}/classes/java"> <classpath refid="classpath"/> </compile> <!-- Copy the resources folder (if existent) --> <copy todir="${build.dir}/classes/java" includeEmptyDirs="false"> <globmapper from="resources/*" to="*" handledirsep="yes"/> <fileset dir="src" includes="resources/**"/> </copy> </target> <target name="compile" depends="compile-core, validate-lucene"> <!-- convenience target to compile core --> </target> <target name="jar-core" depends="compile-core" description="Packages the JAR file"> <jarify/> </target> <macrodef name="m2-deploy" description="Builds a Maven artifact"> <element name="artifact-attachments" optional="yes"/> <attribute name="pom.xml" default="pom.xml"/> <sequential> <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/> <artifact:pom id="maven.project" file="@{pom.xml}"/> <artifact:deploy file="${build.dir}/${maven.project.build.finalName}.jar"> <artifact-attachments/> <remoteRepository url="${m2.repository.url}"> <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}"/> </remoteRepository> <pom refid="maven.project"/> </artifact:deploy> </sequential> </macrodef> <macrodef name="m2-deploy-with-pom-template" description="Builds a Maven artifact given a POM template"> <attribute name="pom.xml"/> <attribute name="jar.file"/> <sequential> <copy file="@{pom.xml}" tofile="${maven.build.dir}/@{pom.xml}"> <filterset begintoken="@" endtoken="@"> <filter token="version" value="${version}"/> </filterset> </copy> <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7"/> <artifact:pom id="maven.project" file="${maven.build.dir}/@{pom.xml}" /> <artifact:deploy file="@{jar.file}"> <remoteRepository url="${m2.repository.url}"> <authentication username="${m2.repository.username}" privateKey="${m2.repository.private.key}"/> </remoteRepository> <pom refid="maven.project"/> </artifact:deploy> </sequential> </macrodef> <macrodef name="build-manifest" description="Builds a manifest file"> <attribute name="title" default="Lucene Search Engine: ${ant.project.name}" /> <sequential> <manifest file="${manifest.file}"> <attribute name="Specification-Title" value="@{title}"/> <!-- spec version must match "digit+{.digit+}*" --> <attribute name="Specification-Version" value="${spec.version}"/> <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> <attribute name="Implementation-Title" value="org.apache.lucene"/> <!-- impl version can be any string --> <attribute name="Implementation-Version" value="${version} ${svnversion} - ${DSTAMP} ${TSTAMP}"/> <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> <attribute name="X-Compile-Source-JDK" value="${javac.source}"/> <attribute name="X-Compile-Target-JDK" value="${javac.target}"/> </manifest> </sequential> </macrodef> <macrodef name="jarify" description="Builds a JAR file"> <attribute name="basedir" default="${build.dir}/classes/java"/> <attribute name="destfile" default="${build.dir}/${final.name}.jar"/> <attribute name="title" default="Lucene Search Engine: ${ant.project.name}"/> <attribute name="excludes" default="**/pom.xml"/> <element name="manifest-attributes" optional="yes"/> <element name="metainf-includes" optional="yes"/> <sequential> <!-- If possible, include the svnversion --> <exec dir="." executable="${svnversion.exe}" outputproperty="svnversion" failifexecutionfails="false"> <arg line="."/> </exec> <build-manifest title="@{title}"/> <jar destfile="@{destfile}" basedir="@{basedir}" manifest="${manifest.file}" excludes="@{excludes}"> <manifest> <manifest-attributes/> </manifest> <metainf dir="${common.dir}"> <include name="LICENSE.txt"/> <include name="NOTICE.txt"/> </metainf> <metainf-includes/> </jar> </sequential> </macrodef> <target name="compile-test-framework" depends="compile-core"> <compile-test-macro srcdir="${tests-framework.src.dir}" destdir="${common.dir}/build/classes/test-framework" test.classpath="test.classpath"/> </target> <target name="compile-tools"> <compile srcdir="${common.dir}/src/tools/java" destdir="${common.build.dir}/classes/tools"> <classpath refid="classpath"/> </compile> </target> <target name="compile-test" depends="compile-test-framework"> <compile-test-macro srcdir="${tests.src.dir}" destdir="${build.dir}/classes/test" test.classpath="test.classpath"/> </target> <property name="tests.verbose" value="false"/> <macrodef name="compile-test-macro" description="Compiles junit tests."> <attribute name="srcdir"/> <attribute name="destdir"/> <attribute name="test.classpath"/> <attribute name="javac.source" default="${javac.source}"/> <attribute name="javac.target" default="${javac.target}"/> <sequential> <compile srcdir="@{srcdir}" destdir="@{destdir}" javac.source="@{javac.source}" javac.target="@{javac.source}"> <classpath refid="@{test.classpath}"/> </compile> <!-- Copy any data files present to the classpath --> <copy todir="@{destdir}"> <fileset dir="@{srcdir}" excludes="**/*.java"/> </copy> </sequential> </macrodef> <macrodef name="test-macro" description="Executes junit tests."> <attribute name="junit.output.dir" default="${junit.output.dir}"/> <attribute name="junit.classpath" default="junit.classpath"/> <attribute name="dataDir" default="${tests.src.dir}"/> <attribute name="tempDir" default="${build.dir}/test"/> <attribute name="threadNum" default="1"/> <attribute name="threadTotal" default="1"/> <sequential> <condition property="runall"> <not> Other Lucene examples (source code examples)Here is a short list of links related to this Lucene common-build.xml source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.