LUCENE-4336: JavaCC tasks should use IVY

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1378381 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-08-28 23:29:44 +00:00
parent 0cd9b42034
commit 44410bc9a9
6 changed files with 42 additions and 132 deletions

View File

@ -66,35 +66,13 @@ system.
NOTE: the ~ character represents your user account home directory.
Step 3) Install JavaCC
Building the Lucene distribution from the source does not require the JavaCC
parser generator, but if you wish to regenerate any of the pre-generated
parser pieces, you will need to install JavaCC. Version 4.1 is tested to
work correctly.
http://javacc.dev.java.net
Follow the download links and download the zip file to a temporary
location on your file system.
After JavaCC is installed, create a build.properties file
(as in step 2), and add the line
javacc.home=/javacc
where this points to the root directory of your javacc installation
(the directory that contains bin/lib/javacc.jar).
Step 4) Run ant
Step 3) Run ant
Assuming you have ant in your PATH and have set ANT_HOME to the
location of your ant installation, typing "ant" at the shell prompt
and command prompt should run ant. Ant will by default look for the
"build.xml" file in your current directory, and compile Lucene.
To rebuild any of the JavaCC-based parsers, run "ant javacc".
For further information on Lucene, go to:
http://lucene.apache.org/

View File

@ -452,16 +452,6 @@
<sign-artifacts-macro artifacts.dir="${dist.dir}"/>
</target>
<!-- ================================================================== -->
<!-- Build the JavaCC files into the source tree -->
<!-- ================================================================== -->
<target name="javacc" depends="javacc-check">
<subant target="javacc" failonerror="true" inheritall="false">
<fileset dir="${common.dir}/queryparser" includes="build.xml"/>
</subant>
</target>
<target name="build-modules" depends="compile-test"
description="Builds all additional modules and their tests">
<modules-crawl target="build-artifacts-and-tests"/>

View File

@ -173,7 +173,6 @@
<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">
@ -185,12 +184,6 @@
</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"/>
@ -261,23 +254,6 @@
<delete file="velocity.log"/>
</target>
<!-- TODO: maybe make JavaCC checking specific to only the projects
that use it (Lucene core and queryparsers)
-->
<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" depends="resolve">
<!-- currently empty -->
</target>
@ -391,36 +367,6 @@
</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 5.0 from:
&lt;http://javacc.dev.java.net&gt;
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-5.0, then set the
javacc.home property to:
javacc.home=/usr/local/java/javacc-5.0
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"/>
@ -1379,31 +1325,11 @@ ${tests-output}/junit4-*.suites - per-JVM executed suites
<!-- <compilerarg line="-Xmaxwarns 10000000"/>
<compilerarg line="-Xmaxerrs 10000000"/> -->
<!-- for generics in Java 1.5: -->
<compilerarg line="${javac.args}"/>
<compilerarg line="${javac.args}"/>
</javac>
</sequential>
</macrodef>
<macrodef name="invoke-javacc">
<attribute name="target"/>
<attribute name="outputDir"/>
<sequential>
<mkdir dir="@{outputDir}"/>
<javacc
target="@{target}"
outputDirectory="@{outputDir}"
debugTokenManager="${javacc.debug.tokenmgr}"
debugParser="${javacc.debug.parser}"
debuglookahead="${javacc.debug.lookahead}"
javacchome="${javacc.home}"
jdkversion="${javac.source}"
/>
<fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fixcrlf>
</sequential>
</macrodef>
<property name="failonjavadocwarning" value="true"/>
<macrodef name="invoke-javadoc">
<element name="sources" optional="yes"/>

View File

@ -38,8 +38,6 @@
<pathelement path="${java.class.path}"/>
</path>
<target name="compile-core" depends="jflex-notice, javacc-notice, common.compile-core"/>
<target name="test-core" depends="common.test"/>
<target name="javadocs-core" depends="javadocs"/>

View File

@ -19,8 +19,6 @@
<project name="misc" default="default" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- TODO: add javacc capability for PrecedenceQueryParser -->
<description>
Index tools and other miscellaneous code
</description>

View File

@ -39,15 +39,10 @@
</invoke-module-javadoc>
</target>
<target name="javacc" depends="init,javacc-check,javacc-QueryParser,javacc-surround,javacc-flexible"/>
<target name="javacc-QueryParser" depends="init,javacc-check" if="javacc.present">
<target name="javacc" depends="javacc-QueryParser,javacc-surround,javacc-flexible"/>
<target name="javacc-QueryParser" depends="resolve-javacc">
<sequential>
<delete>
<fileset dir="src/java/org/apache/lucene/queryparser/classic" includes="*.java">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fileset>
</delete>
<invoke-javacc target="src/java/org/apache/lucene/queryparser/classic/QueryParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/classic"/>
@ -64,23 +59,13 @@
</sequential>
</target>
<target name="javacc-surround" depends="javacc-check" description="generate surround query parser from jj (requires javacc 4.1">
<delete>
<fileset dir="src/java/org/apache/lucene/queryparser/surround/parser" includes="*.java">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fileset>
</delete>
<target name="javacc-surround" depends="resolve-javacc" description="generate surround query parser">
<invoke-javacc target="src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/surround/parser"
/>
</target>
<target name="javacc-flexible" depends="javacc-check">
<delete>
<fileset dir="src/java/org/apache/lucene/queryparser/flexible/standard/parser" includes="*.java">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fileset>
</delete>
<target name="javacc-flexible" depends="resolve-javacc">
<invoke-javacc target="src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj"
outputDir="src/java/org/apache/lucene/queryparser/flexible/standard/parser"
/>
@ -138,4 +123,39 @@ import org.apache.lucene.queryparser.flexible.core.messages.*;"
byline="true"/>
</target>
<target name="resolve-javacc">
<!-- setup a "fake" JavaCC distribution folder in ${build.dir} to make javacc task happy: -->
<mkdir dir="${build.dir}/javacc/bin/lib" />
<ivy:cachefileset xmlns:ivy="antlib:org.apache.ivy.ant" organisation="net.java.dev.javacc" module="javacc" revision="5.0"
inline="true" conf="default" transitive="false" type="jar" setid="javacc.files"/>
<copy todir="${build.dir}/javacc/bin/lib" flatten="true">
<fileset refid="javacc.files"/>
<!-- file must be named: javacc.jar, otherwise task will not find it... -->
<mergemapper to="javacc.jar"/>
</copy>
</target>
<macrodef name="invoke-javacc">
<attribute name="target"/>
<attribute name="outputDir"/>
<sequential>
<!-- run javacc: -->
<mkdir dir="@{outputDir}"/>
<delete>
<fileset dir="@{outputDir}" includes="*.java">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fileset>
</delete>
<javacc
target="@{target}"
outputDirectory="@{outputDir}"
javacchome="${build.dir}/javacc"
jdkversion="${javac.source}"
/>
<fixcrlf srcdir="@{outputDir}" includes="*.java" encoding="UTF-8">
<containsregexp expression="Generated.*By.*JavaCC"/>
</fixcrlf>
</sequential>
</macrodef>
</project>